1 /* Generated by Cython 0.29.23 */
2 
3 #ifndef PY_SSIZE_T_CLEAN
4 #define PY_SSIZE_T_CLEAN
5 #endif /* PY_SSIZE_T_CLEAN */
6 #include "Python.h"
7 #ifndef Py_PYTHON_H
8     #error Python headers needed to compile C extensions, please install development version of Python.
9 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
10     #error Cython requires Python 2.6+ or Python 3.3+.
11 #else
12 #define CYTHON_ABI "0_29_23"
13 #define CYTHON_HEX_VERSION 0x001D17F0
14 #define CYTHON_FUTURE_DIVISION 1
15 #include <stddef.h>
16 #ifndef offsetof
17   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
18 #endif
19 #if !defined(WIN32) && !defined(MS_WINDOWS)
20   #ifndef __stdcall
21     #define __stdcall
22   #endif
23   #ifndef __cdecl
24     #define __cdecl
25   #endif
26   #ifndef __fastcall
27     #define __fastcall
28   #endif
29 #endif
30 #ifndef DL_IMPORT
31   #define DL_IMPORT(t) t
32 #endif
33 #ifndef DL_EXPORT
34   #define DL_EXPORT(t) t
35 #endif
36 #define __PYX_COMMA ,
37 #ifndef HAVE_LONG_LONG
38   #if PY_VERSION_HEX >= 0x02070000
39     #define HAVE_LONG_LONG
40   #endif
41 #endif
42 #ifndef PY_LONG_LONG
43   #define PY_LONG_LONG LONG_LONG
44 #endif
45 #ifndef Py_HUGE_VAL
46   #define Py_HUGE_VAL HUGE_VAL
47 #endif
48 #ifdef PYPY_VERSION
49   #define CYTHON_COMPILING_IN_PYPY 1
50   #define CYTHON_COMPILING_IN_PYSTON 0
51   #define CYTHON_COMPILING_IN_CPYTHON 0
52   #undef CYTHON_USE_TYPE_SLOTS
53   #define CYTHON_USE_TYPE_SLOTS 0
54   #undef CYTHON_USE_PYTYPE_LOOKUP
55   #define CYTHON_USE_PYTYPE_LOOKUP 0
56   #if PY_VERSION_HEX < 0x03050000
57     #undef CYTHON_USE_ASYNC_SLOTS
58     #define CYTHON_USE_ASYNC_SLOTS 0
59   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
60     #define CYTHON_USE_ASYNC_SLOTS 1
61   #endif
62   #undef CYTHON_USE_PYLIST_INTERNALS
63   #define CYTHON_USE_PYLIST_INTERNALS 0
64   #undef CYTHON_USE_UNICODE_INTERNALS
65   #define CYTHON_USE_UNICODE_INTERNALS 0
66   #undef CYTHON_USE_UNICODE_WRITER
67   #define CYTHON_USE_UNICODE_WRITER 0
68   #undef CYTHON_USE_PYLONG_INTERNALS
69   #define CYTHON_USE_PYLONG_INTERNALS 0
70   #undef CYTHON_AVOID_BORROWED_REFS
71   #define CYTHON_AVOID_BORROWED_REFS 1
72   #undef CYTHON_ASSUME_SAFE_MACROS
73   #define CYTHON_ASSUME_SAFE_MACROS 0
74   #undef CYTHON_UNPACK_METHODS
75   #define CYTHON_UNPACK_METHODS 0
76   #undef CYTHON_FAST_THREAD_STATE
77   #define CYTHON_FAST_THREAD_STATE 0
78   #undef CYTHON_FAST_PYCALL
79   #define CYTHON_FAST_PYCALL 0
80   #undef CYTHON_PEP489_MULTI_PHASE_INIT
81   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
82   #undef CYTHON_USE_TP_FINALIZE
83   #define CYTHON_USE_TP_FINALIZE 0
84   #undef CYTHON_USE_DICT_VERSIONS
85   #define CYTHON_USE_DICT_VERSIONS 0
86   #undef CYTHON_USE_EXC_INFO_STACK
87   #define CYTHON_USE_EXC_INFO_STACK 0
88 #elif defined(PYSTON_VERSION)
89   #define CYTHON_COMPILING_IN_PYPY 0
90   #define CYTHON_COMPILING_IN_PYSTON 1
91   #define CYTHON_COMPILING_IN_CPYTHON 0
92   #ifndef CYTHON_USE_TYPE_SLOTS
93     #define CYTHON_USE_TYPE_SLOTS 1
94   #endif
95   #undef CYTHON_USE_PYTYPE_LOOKUP
96   #define CYTHON_USE_PYTYPE_LOOKUP 0
97   #undef CYTHON_USE_ASYNC_SLOTS
98   #define CYTHON_USE_ASYNC_SLOTS 0
99   #undef CYTHON_USE_PYLIST_INTERNALS
100   #define CYTHON_USE_PYLIST_INTERNALS 0
101   #ifndef CYTHON_USE_UNICODE_INTERNALS
102     #define CYTHON_USE_UNICODE_INTERNALS 1
103   #endif
104   #undef CYTHON_USE_UNICODE_WRITER
105   #define CYTHON_USE_UNICODE_WRITER 0
106   #undef CYTHON_USE_PYLONG_INTERNALS
107   #define CYTHON_USE_PYLONG_INTERNALS 0
108   #ifndef CYTHON_AVOID_BORROWED_REFS
109     #define CYTHON_AVOID_BORROWED_REFS 0
110   #endif
111   #ifndef CYTHON_ASSUME_SAFE_MACROS
112     #define CYTHON_ASSUME_SAFE_MACROS 1
113   #endif
114   #ifndef CYTHON_UNPACK_METHODS
115     #define CYTHON_UNPACK_METHODS 1
116   #endif
117   #undef CYTHON_FAST_THREAD_STATE
118   #define CYTHON_FAST_THREAD_STATE 0
119   #undef CYTHON_FAST_PYCALL
120   #define CYTHON_FAST_PYCALL 0
121   #undef CYTHON_PEP489_MULTI_PHASE_INIT
122   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
123   #undef CYTHON_USE_TP_FINALIZE
124   #define CYTHON_USE_TP_FINALIZE 0
125   #undef CYTHON_USE_DICT_VERSIONS
126   #define CYTHON_USE_DICT_VERSIONS 0
127   #undef CYTHON_USE_EXC_INFO_STACK
128   #define CYTHON_USE_EXC_INFO_STACK 0
129 #else
130   #define CYTHON_COMPILING_IN_PYPY 0
131   #define CYTHON_COMPILING_IN_PYSTON 0
132   #define CYTHON_COMPILING_IN_CPYTHON 1
133   #ifndef CYTHON_USE_TYPE_SLOTS
134     #define CYTHON_USE_TYPE_SLOTS 1
135   #endif
136   #if PY_VERSION_HEX < 0x02070000
137     #undef CYTHON_USE_PYTYPE_LOOKUP
138     #define CYTHON_USE_PYTYPE_LOOKUP 0
139   #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
140     #define CYTHON_USE_PYTYPE_LOOKUP 1
141   #endif
142   #if PY_MAJOR_VERSION < 3
143     #undef CYTHON_USE_ASYNC_SLOTS
144     #define CYTHON_USE_ASYNC_SLOTS 0
145   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
146     #define CYTHON_USE_ASYNC_SLOTS 1
147   #endif
148   #if PY_VERSION_HEX < 0x02070000
149     #undef CYTHON_USE_PYLONG_INTERNALS
150     #define CYTHON_USE_PYLONG_INTERNALS 0
151   #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
152     #define CYTHON_USE_PYLONG_INTERNALS 1
153   #endif
154   #ifndef CYTHON_USE_PYLIST_INTERNALS
155     #define CYTHON_USE_PYLIST_INTERNALS 1
156   #endif
157   #ifndef CYTHON_USE_UNICODE_INTERNALS
158     #define CYTHON_USE_UNICODE_INTERNALS 1
159   #endif
160   #if PY_VERSION_HEX < 0x030300F0
161     #undef CYTHON_USE_UNICODE_WRITER
162     #define CYTHON_USE_UNICODE_WRITER 0
163   #elif !defined(CYTHON_USE_UNICODE_WRITER)
164     #define CYTHON_USE_UNICODE_WRITER 1
165   #endif
166   #ifndef CYTHON_AVOID_BORROWED_REFS
167     #define CYTHON_AVOID_BORROWED_REFS 0
168   #endif
169   #ifndef CYTHON_ASSUME_SAFE_MACROS
170     #define CYTHON_ASSUME_SAFE_MACROS 1
171   #endif
172   #ifndef CYTHON_UNPACK_METHODS
173     #define CYTHON_UNPACK_METHODS 1
174   #endif
175   #ifndef CYTHON_FAST_THREAD_STATE
176     #define CYTHON_FAST_THREAD_STATE 1
177   #endif
178   #ifndef CYTHON_FAST_PYCALL
179     #define CYTHON_FAST_PYCALL 1
180   #endif
181   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
182     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
183   #endif
184   #ifndef CYTHON_USE_TP_FINALIZE
185     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
186   #endif
187   #ifndef CYTHON_USE_DICT_VERSIONS
188     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
189   #endif
190   #ifndef CYTHON_USE_EXC_INFO_STACK
191     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
192   #endif
193 #endif
194 #if !defined(CYTHON_FAST_PYCCALL)
195 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
196 #endif
197 #if CYTHON_USE_PYLONG_INTERNALS
198   #include "longintrepr.h"
199   #undef SHIFT
200   #undef BASE
201   #undef MASK
202   #ifdef SIZEOF_VOID_P
203     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
204   #endif
205 #endif
206 #ifndef __has_attribute
207   #define __has_attribute(x) 0
208 #endif
209 #ifndef __has_cpp_attribute
210   #define __has_cpp_attribute(x) 0
211 #endif
212 #ifndef CYTHON_RESTRICT
213   #if defined(__GNUC__)
214     #define CYTHON_RESTRICT __restrict__
215   #elif defined(_MSC_VER) && _MSC_VER >= 1400
216     #define CYTHON_RESTRICT __restrict
217   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
218     #define CYTHON_RESTRICT restrict
219   #else
220     #define CYTHON_RESTRICT
221   #endif
222 #endif
223 #ifndef CYTHON_UNUSED
224 # if defined(__GNUC__)
225 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
226 #     define CYTHON_UNUSED __attribute__ ((__unused__))
227 #   else
228 #     define CYTHON_UNUSED
229 #   endif
230 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
231 #   define CYTHON_UNUSED __attribute__ ((__unused__))
232 # else
233 #   define CYTHON_UNUSED
234 # endif
235 #endif
236 #ifndef CYTHON_MAYBE_UNUSED_VAR
237 #  if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)238      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
239 #  else
240 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
241 #  endif
242 #endif
243 #ifndef CYTHON_NCP_UNUSED
244 # if CYTHON_COMPILING_IN_CPYTHON
245 #  define CYTHON_NCP_UNUSED
246 # else
247 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
248 # endif
249 #endif
250 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
251 #ifdef _MSC_VER
252     #ifndef _MSC_STDINT_H_
253         #if _MSC_VER < 1300
254            typedef unsigned char     uint8_t;
255            typedef unsigned int      uint32_t;
256         #else
257            typedef unsigned __int8   uint8_t;
258            typedef unsigned __int32  uint32_t;
259         #endif
260     #endif
261 #else
262    #include <stdint.h>
263 #endif
264 #ifndef CYTHON_FALLTHROUGH
265   #if defined(__cplusplus) && __cplusplus >= 201103L
266     #if __has_cpp_attribute(fallthrough)
267       #define CYTHON_FALLTHROUGH [[fallthrough]]
268     #elif __has_cpp_attribute(clang::fallthrough)
269       #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
270     #elif __has_cpp_attribute(gnu::fallthrough)
271       #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
272     #endif
273   #endif
274   #ifndef CYTHON_FALLTHROUGH
275     #if __has_attribute(fallthrough)
276       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
277     #else
278       #define CYTHON_FALLTHROUGH
279     #endif
280   #endif
281   #if defined(__clang__ ) && defined(__apple_build_version__)
282     #if __apple_build_version__ < 7000000
283       #undef  CYTHON_FALLTHROUGH
284       #define CYTHON_FALLTHROUGH
285     #endif
286   #endif
287 #endif
288 
289 #ifndef CYTHON_INLINE
290   #if defined(__clang__)
291     #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
292   #elif defined(__GNUC__)
293     #define CYTHON_INLINE __inline__
294   #elif defined(_MSC_VER)
295     #define CYTHON_INLINE __inline
296   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
297     #define CYTHON_INLINE inline
298   #else
299     #define CYTHON_INLINE
300   #endif
301 #endif
302 
303 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
304   #define Py_OptimizeFlag 0
305 #endif
306 #define __PYX_BUILD_PY_SSIZE_T "n"
307 #define CYTHON_FORMAT_SSIZE_T "z"
308 #if PY_MAJOR_VERSION < 3
309   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
310   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
311           PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
312   #define __Pyx_DefaultClassType PyClass_Type
313 #else
314   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
315 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
316   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
317           PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
318 #else
319   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
320           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
321 #endif
322   #define __Pyx_DefaultClassType PyType_Type
323 #endif
324 #ifndef Py_TPFLAGS_CHECKTYPES
325   #define Py_TPFLAGS_CHECKTYPES 0
326 #endif
327 #ifndef Py_TPFLAGS_HAVE_INDEX
328   #define Py_TPFLAGS_HAVE_INDEX 0
329 #endif
330 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
331   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
332 #endif
333 #ifndef Py_TPFLAGS_HAVE_FINALIZE
334   #define Py_TPFLAGS_HAVE_FINALIZE 0
335 #endif
336 #ifndef METH_STACKLESS
337   #define METH_STACKLESS 0
338 #endif
339 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
340   #ifndef METH_FASTCALL
341      #define METH_FASTCALL 0x80
342   #endif
343   typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
344   typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
345                                                           Py_ssize_t nargs, PyObject *kwnames);
346 #else
347   #define __Pyx_PyCFunctionFast _PyCFunctionFast
348   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
349 #endif
350 #if CYTHON_FAST_PYCCALL
351 #define __Pyx_PyFastCFunction_Check(func)\
352     ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
353 #else
354 #define __Pyx_PyFastCFunction_Check(func) 0
355 #endif
356 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
357   #define PyObject_Malloc(s)   PyMem_Malloc(s)
358   #define PyObject_Free(p)     PyMem_Free(p)
359   #define PyObject_Realloc(p)  PyMem_Realloc(p)
360 #endif
361 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
362   #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
363   #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
364   #define PyMem_RawFree(p)             PyMem_Free(p)
365 #endif
366 #if CYTHON_COMPILING_IN_PYSTON
367   #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
368   #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
369 #else
370   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
371   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
372 #endif
373 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
374   #define __Pyx_PyThreadState_Current PyThreadState_GET()
375 #elif PY_VERSION_HEX >= 0x03060000
376   #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
377 #elif PY_VERSION_HEX >= 0x03000000
378   #define __Pyx_PyThreadState_Current PyThreadState_GET()
379 #else
380   #define __Pyx_PyThreadState_Current _PyThreadState_Current
381 #endif
382 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
383 #include "pythread.h"
384 #define Py_tss_NEEDS_INIT 0
385 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)386 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
387   *key = PyThread_create_key();
388   return 0;
389 }
PyThread_tss_alloc(void)390 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
391   Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
392   *key = Py_tss_NEEDS_INIT;
393   return key;
394 }
PyThread_tss_free(Py_tss_t * key)395 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
396   PyObject_Free(key);
397 }
PyThread_tss_is_created(Py_tss_t * key)398 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
399   return *key != Py_tss_NEEDS_INIT;
400 }
PyThread_tss_delete(Py_tss_t * key)401 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
402   PyThread_delete_key(*key);
403   *key = Py_tss_NEEDS_INIT;
404 }
PyThread_tss_set(Py_tss_t * key,void * value)405 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
406   return PyThread_set_key_value(*key, value);
407 }
PyThread_tss_get(Py_tss_t * key)408 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
409   return PyThread_get_key_value(*key);
410 }
411 #endif
412 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
413 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
414 #else
415 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
416 #endif
417 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
418   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
419   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
420 #else
421   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
422   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
423 #endif
424 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
425 #define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
426 #else
427 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
428 #endif
429 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
430   #define CYTHON_PEP393_ENABLED 1
431   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
432                                               0 : _PyUnicode_Ready((PyObject *)(op)))
433   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
434   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
435   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
436   #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
437   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
438   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
439   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
440   #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
441   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
442   #else
443   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
444   #endif
445 #else
446   #define CYTHON_PEP393_ENABLED 0
447   #define PyUnicode_1BYTE_KIND  1
448   #define PyUnicode_2BYTE_KIND  2
449   #define PyUnicode_4BYTE_KIND  4
450   #define __Pyx_PyUnicode_READY(op)       (0)
451   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
452   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
453   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
454   #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
455   #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
456   #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
457   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
458   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
459 #endif
460 #if CYTHON_COMPILING_IN_PYPY
461   #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
462   #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
463 #else
464   #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
465   #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
466       PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
467 #endif
468 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
469   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
470 #endif
471 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
472   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
473 #endif
474 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
475   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
476 #endif
477 #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))
478 #define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
479 #if PY_MAJOR_VERSION >= 3
480   #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
481 #else
482   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
483 #endif
484 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
485   #define PyObject_ASCII(o)            PyObject_Repr(o)
486 #endif
487 #if PY_MAJOR_VERSION >= 3
488   #define PyBaseString_Type            PyUnicode_Type
489   #define PyStringObject               PyUnicodeObject
490   #define PyString_Type                PyUnicode_Type
491   #define PyString_Check               PyUnicode_Check
492   #define PyString_CheckExact          PyUnicode_CheckExact
493 #ifndef PyObject_Unicode
494   #define PyObject_Unicode             PyObject_Str
495 #endif
496 #endif
497 #if PY_MAJOR_VERSION >= 3
498   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
499   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
500 #else
501   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
502   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
503 #endif
504 #ifndef PySet_CheckExact
505   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
506 #endif
507 #if PY_VERSION_HEX >= 0x030900A4
508   #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
509   #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
510 #else
511   #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
512   #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
513 #endif
514 #if CYTHON_ASSUME_SAFE_MACROS
515   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
516 #else
517   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
518 #endif
519 #if PY_MAJOR_VERSION >= 3
520   #define PyIntObject                  PyLongObject
521   #define PyInt_Type                   PyLong_Type
522   #define PyInt_Check(op)              PyLong_Check(op)
523   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
524   #define PyInt_FromString             PyLong_FromString
525   #define PyInt_FromUnicode            PyLong_FromUnicode
526   #define PyInt_FromLong               PyLong_FromLong
527   #define PyInt_FromSize_t             PyLong_FromSize_t
528   #define PyInt_FromSsize_t            PyLong_FromSsize_t
529   #define PyInt_AsLong                 PyLong_AsLong
530   #define PyInt_AS_LONG                PyLong_AS_LONG
531   #define PyInt_AsSsize_t              PyLong_AsSsize_t
532   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
533   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
534   #define PyNumber_Int                 PyNumber_Long
535 #endif
536 #if PY_MAJOR_VERSION >= 3
537   #define PyBoolObject                 PyLongObject
538 #endif
539 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
540   #ifndef PyUnicode_InternFromString
541     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
542   #endif
543 #endif
544 #if PY_VERSION_HEX < 0x030200A4
545   typedef long Py_hash_t;
546   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
547   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
548 #else
549   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
550   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
551 #endif
552 #if PY_MAJOR_VERSION >= 3
553   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
554 #else
555   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
556 #endif
557 #if CYTHON_USE_ASYNC_SLOTS
558   #if PY_VERSION_HEX >= 0x030500B1
559     #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
560     #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
561   #else
562     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
563   #endif
564 #else
565   #define __Pyx_PyType_AsAsync(obj) NULL
566 #endif
567 #ifndef __Pyx_PyAsyncMethodsStruct
568     typedef struct {
569         unaryfunc am_await;
570         unaryfunc am_aiter;
571         unaryfunc am_anext;
572     } __Pyx_PyAsyncMethodsStruct;
573 #endif
574 
575 #if defined(WIN32) || defined(MS_WINDOWS)
576   #define _USE_MATH_DEFINES
577 #endif
578 #include <math.h>
579 #ifdef NAN
580 #define __PYX_NAN() ((float) NAN)
581 #else
__PYX_NAN()582 static CYTHON_INLINE float __PYX_NAN() {
583   float value;
584   memset(&value, 0xFF, sizeof(value));
585   return value;
586 }
587 #endif
588 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
589 #define __Pyx_truncl trunc
590 #else
591 #define __Pyx_truncl truncl
592 #endif
593 
594 #define __PYX_MARK_ERR_POS(f_index, lineno) \
595     { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
596 #define __PYX_ERR(f_index, lineno, Ln_error) \
597     { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
598 
599 #ifndef __PYX_EXTERN_C
600   #ifdef __cplusplus
601     #define __PYX_EXTERN_C extern "C"
602   #else
603     #define __PYX_EXTERN_C extern
604   #endif
605 #endif
606 
607 #define __PYX_HAVE__dipy__align__sumsqdiff
608 #define __PYX_HAVE_API__dipy__align__sumsqdiff
609 /* Early includes */
610 #include <string.h>
611 #include <stdio.h>
612 #include "numpy/arrayobject.h"
613 #include "numpy/ndarrayobject.h"
614 #include "numpy/ndarraytypes.h"
615 #include "numpy/arrayscalars.h"
616 #include "numpy/ufuncobject.h"
617 
618     /* NumPy API declarations from "numpy/__init__.pxd" */
619 
620 #include "dpy_math.h"
621 #include "pythread.h"
622 #include <stdlib.h>
623 #include "pystate.h"
624 #ifdef _OPENMP
625 #include <omp.h>
626 #endif /* _OPENMP */
627 
628 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
629 #define CYTHON_WITHOUT_ASSERTIONS
630 #endif
631 
632 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
633                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
634 
635 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
636 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
637 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
638 #define __PYX_DEFAULT_STRING_ENCODING ""
639 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
640 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
641 #define __Pyx_uchar_cast(c) ((unsigned char)c)
642 #define __Pyx_long_cast(x) ((long)x)
643 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
644     (sizeof(type) < sizeof(Py_ssize_t))  ||\
645     (sizeof(type) > sizeof(Py_ssize_t) &&\
646           likely(v < (type)PY_SSIZE_T_MAX ||\
647                  v == (type)PY_SSIZE_T_MAX)  &&\
648           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
649                                 v == (type)PY_SSIZE_T_MIN)))  ||\
650     (sizeof(type) == sizeof(Py_ssize_t) &&\
651           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
652                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)653 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
654     return (size_t) i < (size_t) limit;
655 }
656 #if defined (__cplusplus) && __cplusplus >= 201103L
657     #include <cstdlib>
658     #define __Pyx_sst_abs(value) std::abs(value)
659 #elif SIZEOF_INT >= SIZEOF_SIZE_T
660     #define __Pyx_sst_abs(value) abs(value)
661 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
662     #define __Pyx_sst_abs(value) labs(value)
663 #elif defined (_MSC_VER)
664     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
665 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
666     #define __Pyx_sst_abs(value) llabs(value)
667 #elif defined (__GNUC__)
668     #define __Pyx_sst_abs(value) __builtin_llabs(value)
669 #else
670     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
671 #endif
672 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
673 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
674 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
675 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
676 #define __Pyx_PyBytes_FromString        PyBytes_FromString
677 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
678 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
679 #if PY_MAJOR_VERSION < 3
680     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
681     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
682 #else
683     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
684     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
685 #endif
686 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
687 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
688 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
689 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
690 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
691 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
692 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
693 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
694 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
695 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
696 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
697 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
698 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
699 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
700 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
701 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)702 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
703     const Py_UNICODE *u_end = u;
704     while (*u_end++) ;
705     return (size_t)(u_end - u - 1);
706 }
707 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
708 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
709 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
710 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
711 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
712 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
713 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
714 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
715 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
716 #define __Pyx_PySequence_Tuple(obj)\
717     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
718 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
719 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
720 #if CYTHON_ASSUME_SAFE_MACROS
721 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
722 #else
723 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
724 #endif
725 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
726 #if PY_MAJOR_VERSION >= 3
727 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
728 #else
729 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
730 #endif
731 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
732 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
733 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)734 static int __Pyx_init_sys_getdefaultencoding_params(void) {
735     PyObject* sys;
736     PyObject* default_encoding = NULL;
737     PyObject* ascii_chars_u = NULL;
738     PyObject* ascii_chars_b = NULL;
739     const char* default_encoding_c;
740     sys = PyImport_ImportModule("sys");
741     if (!sys) goto bad;
742     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
743     Py_DECREF(sys);
744     if (!default_encoding) goto bad;
745     default_encoding_c = PyBytes_AsString(default_encoding);
746     if (!default_encoding_c) goto bad;
747     if (strcmp(default_encoding_c, "ascii") == 0) {
748         __Pyx_sys_getdefaultencoding_not_ascii = 0;
749     } else {
750         char ascii_chars[128];
751         int c;
752         for (c = 0; c < 128; c++) {
753             ascii_chars[c] = c;
754         }
755         __Pyx_sys_getdefaultencoding_not_ascii = 1;
756         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
757         if (!ascii_chars_u) goto bad;
758         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
759         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
760             PyErr_Format(
761                 PyExc_ValueError,
762                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
763                 default_encoding_c);
764             goto bad;
765         }
766         Py_DECREF(ascii_chars_u);
767         Py_DECREF(ascii_chars_b);
768     }
769     Py_DECREF(default_encoding);
770     return 0;
771 bad:
772     Py_XDECREF(default_encoding);
773     Py_XDECREF(ascii_chars_u);
774     Py_XDECREF(ascii_chars_b);
775     return -1;
776 }
777 #endif
778 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
779 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
780 #else
781 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
782 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
783 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)784 static int __Pyx_init_sys_getdefaultencoding_params(void) {
785     PyObject* sys;
786     PyObject* default_encoding = NULL;
787     char* default_encoding_c;
788     sys = PyImport_ImportModule("sys");
789     if (!sys) goto bad;
790     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
791     Py_DECREF(sys);
792     if (!default_encoding) goto bad;
793     default_encoding_c = PyBytes_AsString(default_encoding);
794     if (!default_encoding_c) goto bad;
795     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
796     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
797     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
798     Py_DECREF(default_encoding);
799     return 0;
800 bad:
801     Py_XDECREF(default_encoding);
802     return -1;
803 }
804 #endif
805 #endif
806 
807 
808 /* Test for GCC > 2.95 */
809 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
810   #define likely(x)   __builtin_expect(!!(x), 1)
811   #define unlikely(x) __builtin_expect(!!(x), 0)
812 #else /* !__GNUC__ or GCC < 2.95 */
813   #define likely(x)   (x)
814   #define unlikely(x) (x)
815 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)816 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
817 
818 static PyObject *__pyx_m = NULL;
819 static PyObject *__pyx_d;
820 static PyObject *__pyx_b;
821 static PyObject *__pyx_cython_runtime = NULL;
822 static PyObject *__pyx_empty_tuple;
823 static PyObject *__pyx_empty_bytes;
824 static PyObject *__pyx_empty_unicode;
825 static int __pyx_lineno;
826 static int __pyx_clineno = 0;
827 static const char * __pyx_cfilenm= __FILE__;
828 static const char *__pyx_filename;
829 
830 /* Header.proto */
831 #if !defined(CYTHON_CCOMPLEX)
832   #if defined(__cplusplus)
833     #define CYTHON_CCOMPLEX 1
834   #elif defined(_Complex_I)
835     #define CYTHON_CCOMPLEX 1
836   #else
837     #define CYTHON_CCOMPLEX 0
838   #endif
839 #endif
840 #if CYTHON_CCOMPLEX
841   #ifdef __cplusplus
842     #include <complex>
843   #else
844     #include <complex.h>
845   #endif
846 #endif
847 #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
848   #undef _Complex_I
849   #define _Complex_I 1.0fj
850 #endif
851 
852 
853 static const char *__pyx_f[] = {
854   "dipy/align/sumsqdiff.pyx",
855   "__init__.pxd",
856   "stringsource",
857   "type.pxd",
858 };
859 /* NoFastGil.proto */
860 #define __Pyx_PyGILState_Ensure PyGILState_Ensure
861 #define __Pyx_PyGILState_Release PyGILState_Release
862 #define __Pyx_FastGIL_Remember()
863 #define __Pyx_FastGIL_Forget()
864 #define __Pyx_FastGilFuncInit()
865 
866 /* MemviewSliceStruct.proto */
867 struct __pyx_memoryview_obj;
868 typedef struct {
869   struct __pyx_memoryview_obj *memview;
870   char *data;
871   Py_ssize_t shape[8];
872   Py_ssize_t strides[8];
873   Py_ssize_t suboffsets[8];
874 } __Pyx_memviewslice;
875 #define __Pyx_MemoryView_Len(m)  (m.shape[0])
876 
877 /* Atomics.proto */
878 #include <pythread.h>
879 #ifndef CYTHON_ATOMICS
880     #define CYTHON_ATOMICS 1
881 #endif
882 #define __pyx_atomic_int_type int
883 #if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\
884                     (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\
885                     !defined(__i386__)
886     #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1)
887     #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1)
888     #ifdef __PYX_DEBUG_ATOMICS
889         #warning "Using GNU atomics"
890     #endif
891 #elif CYTHON_ATOMICS && defined(_MSC_VER) && 0
892     #include <Windows.h>
893     #undef __pyx_atomic_int_type
894     #define __pyx_atomic_int_type LONG
895     #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value)
896     #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value)
897     #ifdef __PYX_DEBUG_ATOMICS
898         #pragma message ("Using MSVC atomics")
899     #endif
900 #elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0
901     #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value)
902     #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value)
903     #ifdef __PYX_DEBUG_ATOMICS
904         #warning "Using Intel atomics"
905     #endif
906 #else
907     #undef CYTHON_ATOMICS
908     #define CYTHON_ATOMICS 0
909     #ifdef __PYX_DEBUG_ATOMICS
910         #warning "Not using atomics"
911     #endif
912 #endif
913 typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
914 #if CYTHON_ATOMICS
915     #define __pyx_add_acquisition_count(memview)\
916              __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
917     #define __pyx_sub_acquisition_count(memview)\
918             __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
919 #else
920     #define __pyx_add_acquisition_count(memview)\
921             __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
922     #define __pyx_sub_acquisition_count(memview)\
923             __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
924 #endif
925 
926 /* ForceInitThreads.proto */
927 #ifndef __PYX_FORCE_INIT_THREADS
928   #define __PYX_FORCE_INIT_THREADS 0
929 #endif
930 
931 /* BufferFormatStructs.proto */
932 #define IS_UNSIGNED(type) (((type) -1) > 0)
933 struct __Pyx_StructField_;
934 #define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
935 typedef struct {
936   const char* name;
937   struct __Pyx_StructField_* fields;
938   size_t size;
939   size_t arraysize[8];
940   int ndim;
941   char typegroup;
942   char is_unsigned;
943   int flags;
944 } __Pyx_TypeInfo;
945 typedef struct __Pyx_StructField_ {
946   __Pyx_TypeInfo* type;
947   const char* name;
948   size_t offset;
949 } __Pyx_StructField;
950 typedef struct {
951   __Pyx_StructField* field;
952   size_t parent_offset;
953 } __Pyx_BufFmt_StackElem;
954 typedef struct {
955   __Pyx_StructField root;
956   __Pyx_BufFmt_StackElem* head;
957   size_t fmt_offset;
958   size_t new_count, enc_count;
959   size_t struct_alignment;
960   int is_complex;
961   char enc_type;
962   char new_packmode;
963   char enc_packmode;
964   char is_valid_array;
965 } __Pyx_BufFmt_Context;
966 
967 
968 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":690
969  * # in Cython to enable them only on the right systems.
970  *
971  * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
972  * ctypedef npy_int16      int16_t
973  * ctypedef npy_int32      int32_t
974  */
975 typedef npy_int8 __pyx_t_5numpy_int8_t;
976 
977 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":691
978  *
979  * ctypedef npy_int8       int8_t
980  * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
981  * ctypedef npy_int32      int32_t
982  * ctypedef npy_int64      int64_t
983  */
984 typedef npy_int16 __pyx_t_5numpy_int16_t;
985 
986 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":692
987  * ctypedef npy_int8       int8_t
988  * ctypedef npy_int16      int16_t
989  * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
990  * ctypedef npy_int64      int64_t
991  * #ctypedef npy_int96      int96_t
992  */
993 typedef npy_int32 __pyx_t_5numpy_int32_t;
994 
995 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":693
996  * ctypedef npy_int16      int16_t
997  * ctypedef npy_int32      int32_t
998  * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
999  * #ctypedef npy_int96      int96_t
1000  * #ctypedef npy_int128     int128_t
1001  */
1002 typedef npy_int64 __pyx_t_5numpy_int64_t;
1003 
1004 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":697
1005  * #ctypedef npy_int128     int128_t
1006  *
1007  * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
1008  * ctypedef npy_uint16     uint16_t
1009  * ctypedef npy_uint32     uint32_t
1010  */
1011 typedef npy_uint8 __pyx_t_5numpy_uint8_t;
1012 
1013 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":698
1014  *
1015  * ctypedef npy_uint8      uint8_t
1016  * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
1017  * ctypedef npy_uint32     uint32_t
1018  * ctypedef npy_uint64     uint64_t
1019  */
1020 typedef npy_uint16 __pyx_t_5numpy_uint16_t;
1021 
1022 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":699
1023  * ctypedef npy_uint8      uint8_t
1024  * ctypedef npy_uint16     uint16_t
1025  * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
1026  * ctypedef npy_uint64     uint64_t
1027  * #ctypedef npy_uint96     uint96_t
1028  */
1029 typedef npy_uint32 __pyx_t_5numpy_uint32_t;
1030 
1031 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":700
1032  * ctypedef npy_uint16     uint16_t
1033  * ctypedef npy_uint32     uint32_t
1034  * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
1035  * #ctypedef npy_uint96     uint96_t
1036  * #ctypedef npy_uint128    uint128_t
1037  */
1038 typedef npy_uint64 __pyx_t_5numpy_uint64_t;
1039 
1040 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":704
1041  * #ctypedef npy_uint128    uint128_t
1042  *
1043  * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
1044  * ctypedef npy_float64    float64_t
1045  * #ctypedef npy_float80    float80_t
1046  */
1047 typedef npy_float32 __pyx_t_5numpy_float32_t;
1048 
1049 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":705
1050  *
1051  * ctypedef npy_float32    float32_t
1052  * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
1053  * #ctypedef npy_float80    float80_t
1054  * #ctypedef npy_float128   float128_t
1055  */
1056 typedef npy_float64 __pyx_t_5numpy_float64_t;
1057 
1058 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":714
1059  * # The int types are mapped a bit surprising --
1060  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1061  * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
1062  * ctypedef npy_longlong   long_t
1063  * ctypedef npy_longlong   longlong_t
1064  */
1065 typedef npy_long __pyx_t_5numpy_int_t;
1066 
1067 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":715
1068  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1069  * ctypedef npy_long       int_t
1070  * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
1071  * ctypedef npy_longlong   longlong_t
1072  *
1073  */
1074 typedef npy_longlong __pyx_t_5numpy_long_t;
1075 
1076 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":716
1077  * ctypedef npy_long       int_t
1078  * ctypedef npy_longlong   long_t
1079  * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
1080  *
1081  * ctypedef npy_ulong      uint_t
1082  */
1083 typedef npy_longlong __pyx_t_5numpy_longlong_t;
1084 
1085 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":718
1086  * ctypedef npy_longlong   longlong_t
1087  *
1088  * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
1089  * ctypedef npy_ulonglong  ulong_t
1090  * ctypedef npy_ulonglong  ulonglong_t
1091  */
1092 typedef npy_ulong __pyx_t_5numpy_uint_t;
1093 
1094 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":719
1095  *
1096  * ctypedef npy_ulong      uint_t
1097  * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
1098  * ctypedef npy_ulonglong  ulonglong_t
1099  *
1100  */
1101 typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
1102 
1103 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":720
1104  * ctypedef npy_ulong      uint_t
1105  * ctypedef npy_ulonglong  ulong_t
1106  * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
1107  *
1108  * ctypedef npy_intp       intp_t
1109  */
1110 typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
1111 
1112 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":722
1113  * ctypedef npy_ulonglong  ulonglong_t
1114  *
1115  * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
1116  * ctypedef npy_uintp      uintp_t
1117  *
1118  */
1119 typedef npy_intp __pyx_t_5numpy_intp_t;
1120 
1121 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":723
1122  *
1123  * ctypedef npy_intp       intp_t
1124  * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
1125  *
1126  * ctypedef npy_double     float_t
1127  */
1128 typedef npy_uintp __pyx_t_5numpy_uintp_t;
1129 
1130 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":725
1131  * ctypedef npy_uintp      uintp_t
1132  *
1133  * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
1134  * ctypedef npy_double     double_t
1135  * ctypedef npy_longdouble longdouble_t
1136  */
1137 typedef npy_double __pyx_t_5numpy_float_t;
1138 
1139 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":726
1140  *
1141  * ctypedef npy_double     float_t
1142  * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
1143  * ctypedef npy_longdouble longdouble_t
1144  *
1145  */
1146 typedef npy_double __pyx_t_5numpy_double_t;
1147 
1148 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":727
1149  * ctypedef npy_double     float_t
1150  * ctypedef npy_double     double_t
1151  * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
1152  *
1153  * ctypedef npy_cfloat      cfloat_t
1154  */
1155 typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
1156 /* Declarations.proto */
1157 #if CYTHON_CCOMPLEX
1158   #ifdef __cplusplus
1159     typedef ::std::complex< float > __pyx_t_float_complex;
1160   #else
1161     typedef float _Complex __pyx_t_float_complex;
1162   #endif
1163 #else
1164     typedef struct { float real, imag; } __pyx_t_float_complex;
1165 #endif
1166 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
1167 
1168 /* Declarations.proto */
1169 #if CYTHON_CCOMPLEX
1170   #ifdef __cplusplus
1171     typedef ::std::complex< double > __pyx_t_double_complex;
1172   #else
1173     typedef double _Complex __pyx_t_double_complex;
1174   #endif
1175 #else
1176     typedef struct { double real, imag; } __pyx_t_double_complex;
1177 #endif
1178 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
1179 
1180 
1181 /*--- Type declarations ---*/
1182 struct __pyx_array_obj;
1183 struct __pyx_MemviewEnum_obj;
1184 struct __pyx_memoryview_obj;
1185 struct __pyx_memoryviewslice_obj;
1186 
1187 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":729
1188  * ctypedef npy_longdouble longdouble_t
1189  *
1190  * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
1191  * ctypedef npy_cdouble     cdouble_t
1192  * ctypedef npy_clongdouble clongdouble_t
1193  */
1194 typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
1195 
1196 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":730
1197  *
1198  * ctypedef npy_cfloat      cfloat_t
1199  * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
1200  * ctypedef npy_clongdouble clongdouble_t
1201  *
1202  */
1203 typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
1204 
1205 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":731
1206  * ctypedef npy_cfloat      cfloat_t
1207  * ctypedef npy_cdouble     cdouble_t
1208  * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
1209  *
1210  * ctypedef npy_cdouble     complex_t
1211  */
1212 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
1213 
1214 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":733
1215  * ctypedef npy_clongdouble clongdouble_t
1216  *
1217  * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
1218  *
1219  * cdef inline object PyArray_MultiIterNew1(a):
1220  */
1221 typedef npy_cdouble __pyx_t_5numpy_complex_t;
1222 
1223 /* "View.MemoryView":105
1224  *
1225  * @cname("__pyx_array")
1226  * cdef class array:             # <<<<<<<<<<<<<<
1227  *
1228  *     cdef:
1229  */
1230 struct __pyx_array_obj {
1231   PyObject_HEAD
1232   struct __pyx_vtabstruct_array *__pyx_vtab;
1233   char *data;
1234   Py_ssize_t len;
1235   char *format;
1236   int ndim;
1237   Py_ssize_t *_shape;
1238   Py_ssize_t *_strides;
1239   Py_ssize_t itemsize;
1240   PyObject *mode;
1241   PyObject *_format;
1242   void (*callback_free_data)(void *);
1243   int free_data;
1244   int dtype_is_object;
1245 };
1246 
1247 
1248 /* "View.MemoryView":279
1249  *
1250  * @cname('__pyx_MemviewEnum')
1251  * cdef class Enum(object):             # <<<<<<<<<<<<<<
1252  *     cdef object name
1253  *     def __init__(self, name):
1254  */
1255 struct __pyx_MemviewEnum_obj {
1256   PyObject_HEAD
1257   PyObject *name;
1258 };
1259 
1260 
1261 /* "View.MemoryView":330
1262  *
1263  * @cname('__pyx_memoryview')
1264  * cdef class memoryview(object):             # <<<<<<<<<<<<<<
1265  *
1266  *     cdef object obj
1267  */
1268 struct __pyx_memoryview_obj {
1269   PyObject_HEAD
1270   struct __pyx_vtabstruct_memoryview *__pyx_vtab;
1271   PyObject *obj;
1272   PyObject *_size;
1273   PyObject *_array_interface;
1274   PyThread_type_lock lock;
1275   __pyx_atomic_int acquisition_count[2];
1276   __pyx_atomic_int *acquisition_count_aligned_p;
1277   Py_buffer view;
1278   int flags;
1279   int dtype_is_object;
1280   __Pyx_TypeInfo *typeinfo;
1281 };
1282 
1283 
1284 /* "View.MemoryView":965
1285  *
1286  * @cname('__pyx_memoryviewslice')
1287  * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
1288  *     "Internal class for passing memoryview slices to Python"
1289  *
1290  */
1291 struct __pyx_memoryviewslice_obj {
1292   struct __pyx_memoryview_obj __pyx_base;
1293   __Pyx_memviewslice from_slice;
1294   PyObject *from_object;
1295   PyObject *(*to_object_func)(char *);
1296   int (*to_dtype_func)(char *, PyObject *);
1297 };
1298 
1299 
1300 
1301 /* "View.MemoryView":105
1302  *
1303  * @cname("__pyx_array")
1304  * cdef class array:             # <<<<<<<<<<<<<<
1305  *
1306  *     cdef:
1307  */
1308 
1309 struct __pyx_vtabstruct_array {
1310   PyObject *(*get_memview)(struct __pyx_array_obj *);
1311 };
1312 static struct __pyx_vtabstruct_array *__pyx_vtabptr_array;
1313 
1314 
1315 /* "View.MemoryView":330
1316  *
1317  * @cname('__pyx_memoryview')
1318  * cdef class memoryview(object):             # <<<<<<<<<<<<<<
1319  *
1320  *     cdef object obj
1321  */
1322 
1323 struct __pyx_vtabstruct_memoryview {
1324   char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *);
1325   PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *);
1326   PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
1327   PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *);
1328   PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
1329   PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *);
1330   PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *);
1331 };
1332 static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview;
1333 
1334 
1335 /* "View.MemoryView":965
1336  *
1337  * @cname('__pyx_memoryviewslice')
1338  * cdef class _memoryviewslice(memoryview):             # <<<<<<<<<<<<<<
1339  *     "Internal class for passing memoryview slices to Python"
1340  *
1341  */
1342 
1343 struct __pyx_vtabstruct__memoryviewslice {
1344   struct __pyx_vtabstruct_memoryview __pyx_base;
1345 };
1346 static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice;
1347 
1348 /* --- Runtime support code (head) --- */
1349 /* Refnanny.proto */
1350 #ifndef CYTHON_REFNANNY
1351   #define CYTHON_REFNANNY 0
1352 #endif
1353 #if CYTHON_REFNANNY
1354   typedef struct {
1355     void (*INCREF)(void*, PyObject*, int);
1356     void (*DECREF)(void*, PyObject*, int);
1357     void (*GOTREF)(void*, PyObject*, int);
1358     void (*GIVEREF)(void*, PyObject*, int);
1359     void* (*SetupContext)(const char*, int, const char*);
1360     void (*FinishContext)(void**);
1361   } __Pyx_RefNannyAPIStruct;
1362   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1363   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1364   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1365 #ifdef WITH_THREAD
1366   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1367           if (acquire_gil) {\
1368               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1369               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1370               PyGILState_Release(__pyx_gilstate_save);\
1371           } else {\
1372               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1373           }
1374 #else
1375   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1376           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1377 #endif
1378   #define __Pyx_RefNannyFinishContext()\
1379           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1380   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1381   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1382   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1383   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1384   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1385   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1386   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1387   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1388 #else
1389   #define __Pyx_RefNannyDeclarations
1390   #define __Pyx_RefNannySetupContext(name, acquire_gil)
1391   #define __Pyx_RefNannyFinishContext()
1392   #define __Pyx_INCREF(r) Py_INCREF(r)
1393   #define __Pyx_DECREF(r) Py_DECREF(r)
1394   #define __Pyx_GOTREF(r)
1395   #define __Pyx_GIVEREF(r)
1396   #define __Pyx_XINCREF(r) Py_XINCREF(r)
1397   #define __Pyx_XDECREF(r) Py_XDECREF(r)
1398   #define __Pyx_XGOTREF(r)
1399   #define __Pyx_XGIVEREF(r)
1400 #endif
1401 #define __Pyx_XDECREF_SET(r, v) do {\
1402         PyObject *tmp = (PyObject *) r;\
1403         r = v; __Pyx_XDECREF(tmp);\
1404     } while (0)
1405 #define __Pyx_DECREF_SET(r, v) do {\
1406         PyObject *tmp = (PyObject *) r;\
1407         r = v; __Pyx_DECREF(tmp);\
1408     } while (0)
1409 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1410 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1411 
1412 /* PyObjectGetAttrStr.proto */
1413 #if CYTHON_USE_TYPE_SLOTS
1414 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1415 #else
1416 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1417 #endif
1418 
1419 /* GetBuiltinName.proto */
1420 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1421 
1422 /* RaiseArgTupleInvalid.proto */
1423 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1424     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1425 
1426 /* RaiseDoubleKeywords.proto */
1427 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1428 
1429 /* ParseKeywords.proto */
1430 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1431     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1432     const char* function_name);
1433 
1434 /* PyDictVersioning.proto */
1435 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1436 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
1437 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
1438 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1439     (version_var) = __PYX_GET_DICT_VERSION(dict);\
1440     (cache_var) = (value);
1441 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1442     static PY_UINT64_T __pyx_dict_version = 0;\
1443     static PyObject *__pyx_dict_cached_value = NULL;\
1444     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1445         (VAR) = __pyx_dict_cached_value;\
1446     } else {\
1447         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1448         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1449     }\
1450 }
1451 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1452 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1453 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1454 #else
1455 #define __PYX_GET_DICT_VERSION(dict)  (0)
1456 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1457 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1458 #endif
1459 
1460 /* GetModuleGlobalName.proto */
1461 #if CYTHON_USE_DICT_VERSIONS
1462 #define __Pyx_GetModuleGlobalName(var, name)  {\
1463     static PY_UINT64_T __pyx_dict_version = 0;\
1464     static PyObject *__pyx_dict_cached_value = NULL;\
1465     (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1466         (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1467         __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1468 }
1469 #define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
1470     PY_UINT64_T __pyx_dict_version;\
1471     PyObject *__pyx_dict_cached_value;\
1472     (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1473 }
1474 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1475 #else
1476 #define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1477 #define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1478 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1479 #endif
1480 
1481 /* PyObjectCall.proto */
1482 #if CYTHON_COMPILING_IN_CPYTHON
1483 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1484 #else
1485 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1486 #endif
1487 
1488 /* ExtTypeTest.proto */
1489 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1490 
1491 /* PyFunctionFastCall.proto */
1492 #if CYTHON_FAST_PYCALL
1493 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1494     __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1495 #if 1 || PY_VERSION_HEX < 0x030600B1
1496 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1497 #else
1498 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1499 #endif
1500 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1501     (sizeof(char [1 - 2*!(cond)]) - 1)
1502 #ifndef Py_MEMBER_SIZE
1503 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1504 #endif
1505   static size_t __pyx_pyframe_localsplus_offset = 0;
1506   #include "frameobject.h"
1507   #define __Pxy_PyFrame_Initialize_Offsets()\
1508     ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1509      (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1510   #define __Pyx_PyFrame_GetLocalsplus(frame)\
1511     (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1512 #endif
1513 
1514 /* PyCFunctionFastCall.proto */
1515 #if CYTHON_FAST_PYCCALL
1516 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1517 #else
1518 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
1519 #endif
1520 
1521 /* PyObjectCall2Args.proto */
1522 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1523 
1524 /* PyObjectCallMethO.proto */
1525 #if CYTHON_COMPILING_IN_CPYTHON
1526 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1527 #endif
1528 
1529 /* PyObjectCallOneArg.proto */
1530 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1531 
1532 /* PyDictContains.proto */
__Pyx_PyDict_ContainsTF(PyObject * item,PyObject * dict,int eq)1533 static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
1534     int result = PyDict_Contains(dict, item);
1535     return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
1536 }
1537 
1538 /* DictGetItem.proto */
1539 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
1540 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
1541 #define __Pyx_PyObject_Dict_GetItem(obj, name)\
1542     (likely(PyDict_CheckExact(obj)) ?\
1543      __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
1544 #else
1545 #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
1546 #define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
1547 #endif
1548 
1549 /* PyThreadStateGet.proto */
1550 #if CYTHON_FAST_THREAD_STATE
1551 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
1552 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
1553 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
1554 #else
1555 #define __Pyx_PyThreadState_declare
1556 #define __Pyx_PyThreadState_assign
1557 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1558 #endif
1559 
1560 /* PyErrFetchRestore.proto */
1561 #if CYTHON_FAST_THREAD_STATE
1562 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1563 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1564 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1565 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1566 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1567 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1568 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1569 #if CYTHON_COMPILING_IN_CPYTHON
1570 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1571 #else
1572 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1573 #endif
1574 #else
1575 #define __Pyx_PyErr_Clear() PyErr_Clear()
1576 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1577 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
1578 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
1579 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
1580 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
1581 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
1582 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
1583 #endif
1584 
1585 /* RaiseException.proto */
1586 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1587 
1588 /* UnicodeAsUCS4.proto */
1589 static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject*);
1590 
1591 /* object_ord.proto */
1592 #if PY_MAJOR_VERSION >= 3
1593 #define __Pyx_PyObject_Ord(c)\
1594     (likely(PyUnicode_Check(c)) ? (long)__Pyx_PyUnicode_AsPy_UCS4(c) : __Pyx__PyObject_Ord(c))
1595 #else
1596 #define __Pyx_PyObject_Ord(c) __Pyx__PyObject_Ord(c)
1597 #endif
1598 static long __Pyx__PyObject_Ord(PyObject* c);
1599 
1600 /* SetItemInt.proto */
1601 #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1602     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1603     __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
1604     (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
1605                __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
1606 static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
1607 static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
1608                                                int is_list, int wraparound, int boundscheck);
1609 
1610 /* IterFinish.proto */
1611 static CYTHON_INLINE int __Pyx_IterFinish(void);
1612 
1613 /* PyObjectCallNoArg.proto */
1614 #if CYTHON_COMPILING_IN_CPYTHON
1615 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1616 #else
1617 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1618 #endif
1619 
1620 /* PyObjectGetMethod.proto */
1621 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
1622 
1623 /* PyObjectCallMethod0.proto */
1624 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
1625 
1626 /* RaiseNeedMoreValuesToUnpack.proto */
1627 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1628 
1629 /* RaiseTooManyValuesToUnpack.proto */
1630 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1631 
1632 /* UnpackItemEndCheck.proto */
1633 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
1634 
1635 /* RaiseNoneIterError.proto */
1636 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
1637 
1638 /* UnpackTupleError.proto */
1639 static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);
1640 
1641 /* UnpackTuple2.proto */
1642 #define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
1643     (likely(is_tuple || PyTuple_Check(tuple)) ?\
1644         (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
1645             __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
1646             (__Pyx_UnpackTupleError(tuple, 2), -1)) :\
1647         __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
1648 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
1649     PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
1650 static int __Pyx_unpack_tuple2_generic(
1651     PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);
1652 
1653 /* dict_iter.proto */
1654 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
1655                                                    Py_ssize_t* p_orig_length, int* p_is_dict);
1656 static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
1657                                               PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);
1658 
1659 /* GetItemInt.proto */
1660 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1661     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1662     __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1663     (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1664                __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1665 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1666     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1667     __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1668     (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1669 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1670                                                               int wraparound, int boundscheck);
1671 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1672     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1673     __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1674     (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1675 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1676                                                               int wraparound, int boundscheck);
1677 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1678 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1679                                                      int is_list, int wraparound, int boundscheck);
1680 
1681 /* ListAppend.proto */
1682 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)1683 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1684     PyListObject* L = (PyListObject*) list;
1685     Py_ssize_t len = Py_SIZE(list);
1686     if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1687         Py_INCREF(x);
1688         PyList_SET_ITEM(list, len, x);
1689         __Pyx_SET_SIZE(list, len + 1);
1690         return 0;
1691     }
1692     return PyList_Append(list, x);
1693 }
1694 #else
1695 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1696 #endif
1697 
1698 /* WriteUnraisableException.proto */
1699 static void __Pyx_WriteUnraisable(const char *name, int clineno,
1700                                   int lineno, const char *filename,
1701                                   int full_traceback, int nogil);
1702 
1703 /* None.proto */
1704 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
1705 
1706 /* MemviewSliceInit.proto */
1707 #define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d
1708 #define __Pyx_MEMVIEW_DIRECT   1
1709 #define __Pyx_MEMVIEW_PTR      2
1710 #define __Pyx_MEMVIEW_FULL     4
1711 #define __Pyx_MEMVIEW_CONTIG   8
1712 #define __Pyx_MEMVIEW_STRIDED  16
1713 #define __Pyx_MEMVIEW_FOLLOW   32
1714 #define __Pyx_IS_C_CONTIG 1
1715 #define __Pyx_IS_F_CONTIG 2
1716 static int __Pyx_init_memviewslice(
1717                 struct __pyx_memoryview_obj *memview,
1718                 int ndim,
1719                 __Pyx_memviewslice *memviewslice,
1720                 int memview_is_new_reference);
1721 static CYTHON_INLINE int __pyx_add_acquisition_count_locked(
1722     __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
1723 static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(
1724     __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
1725 #define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p)
1726 #define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview))
1727 #define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__)
1728 #define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
1729 static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int);
1730 static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int);
1731 
1732 /* GetTopmostException.proto */
1733 #if CYTHON_USE_EXC_INFO_STACK
1734 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1735 #endif
1736 
1737 /* SaveResetException.proto */
1738 #if CYTHON_FAST_THREAD_STATE
1739 #define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1740 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1741 #define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1742 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1743 #else
1744 #define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
1745 #define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
1746 #endif
1747 
1748 /* PyErrExceptionMatches.proto */
1749 #if CYTHON_FAST_THREAD_STATE
1750 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1751 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1752 #else
1753 #define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
1754 #endif
1755 
1756 /* GetException.proto */
1757 #if CYTHON_FAST_THREAD_STATE
1758 #define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
1759 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1760 #else
1761 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1762 #endif
1763 
1764 /* ArgTypeTest.proto */
1765 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
1766     ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
1767         __Pyx__ArgTypeTest(obj, type, name, exact))
1768 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
1769 
1770 /* IncludeStringH.proto */
1771 #include <string.h>
1772 
1773 /* BytesEquals.proto */
1774 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
1775 
1776 /* UnicodeEquals.proto */
1777 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
1778 
1779 /* StrEquals.proto */
1780 #if PY_MAJOR_VERSION >= 3
1781 #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
1782 #else
1783 #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
1784 #endif
1785 
1786 /* None.proto */
1787 static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
1788 
1789 /* UnaryNegOverflows.proto */
1790 #define UNARY_NEG_WOULD_OVERFLOW(x)\
1791         (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
1792 
1793 static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
1794 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/
1795 /* GetAttr.proto */
1796 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
1797 
1798 /* ObjectGetItem.proto */
1799 #if CYTHON_USE_TYPE_SLOTS
1800 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
1801 #else
1802 #define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
1803 #endif
1804 
1805 /* decode_c_string_utf16.proto */
__Pyx_PyUnicode_DecodeUTF16(const char * s,Py_ssize_t size,const char * errors)1806 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
1807     int byteorder = 0;
1808     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1809 }
__Pyx_PyUnicode_DecodeUTF16LE(const char * s,Py_ssize_t size,const char * errors)1810 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
1811     int byteorder = -1;
1812     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1813 }
__Pyx_PyUnicode_DecodeUTF16BE(const char * s,Py_ssize_t size,const char * errors)1814 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
1815     int byteorder = 1;
1816     return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1817 }
1818 
1819 /* decode_c_string.proto */
1820 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
1821          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
1822          const char* encoding, const char* errors,
1823          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
1824 
1825 /* GetAttr3.proto */
1826 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
1827 
1828 /* SwapException.proto */
1829 #if CYTHON_FAST_THREAD_STATE
1830 #define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
1831 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1832 #else
1833 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
1834 #endif
1835 
1836 /* Import.proto */
1837 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1838 
1839 /* FastTypeChecks.proto */
1840 #if CYTHON_COMPILING_IN_CPYTHON
1841 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1842 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1843 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1844 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1845 #else
1846 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1847 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1848 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1849 #endif
1850 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1851 
1852 static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
1853 /* ListCompAppend.proto */
1854 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_ListComp_Append(PyObject * list,PyObject * x)1855 static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
1856     PyListObject* L = (PyListObject*) list;
1857     Py_ssize_t len = Py_SIZE(list);
1858     if (likely(L->allocated > len)) {
1859         Py_INCREF(x);
1860         PyList_SET_ITEM(list, len, x);
1861         __Pyx_SET_SIZE(list, len + 1);
1862         return 0;
1863     }
1864     return PyList_Append(list, x);
1865 }
1866 #else
1867 #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
1868 #endif
1869 
1870 /* PyIntBinop.proto */
1871 #if !CYTHON_COMPILING_IN_PYPY
1872 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1873 #else
1874 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
1875     (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
1876 #endif
1877 
1878 /* ListExtend.proto */
__Pyx_PyList_Extend(PyObject * L,PyObject * v)1879 static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
1880 #if CYTHON_COMPILING_IN_CPYTHON
1881     PyObject* none = _PyList_Extend((PyListObject*)L, v);
1882     if (unlikely(!none))
1883         return -1;
1884     Py_DECREF(none);
1885     return 0;
1886 #else
1887     return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
1888 #endif
1889 }
1890 
1891 /* None.proto */
1892 static CYTHON_INLINE long __Pyx_div_long(long, long);
1893 
1894 /* ImportFrom.proto */
1895 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1896 
1897 /* HasAttr.proto */
1898 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
1899 
1900 /* PyObject_GenericGetAttrNoDict.proto */
1901 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1902 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
1903 #else
1904 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1905 #endif
1906 
1907 /* PyObject_GenericGetAttr.proto */
1908 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1909 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
1910 #else
1911 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1912 #endif
1913 
1914 /* SetVTable.proto */
1915 static int __Pyx_SetVtable(PyObject *dict, void *vtable);
1916 
1917 /* PyObjectGetAttrStrNoError.proto */
1918 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1919 
1920 /* SetupReduce.proto */
1921 static int __Pyx_setup_reduce(PyObject* type_obj);
1922 
1923 /* TypeImport.proto */
1924 #ifndef __PYX_HAVE_RT_ImportType_proto
1925 #define __PYX_HAVE_RT_ImportType_proto
1926 enum __Pyx_ImportType_CheckSize {
1927    __Pyx_ImportType_CheckSize_Error = 0,
1928    __Pyx_ImportType_CheckSize_Warn = 1,
1929    __Pyx_ImportType_CheckSize_Ignore = 2
1930 };
1931 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1932 #endif
1933 
1934 /* FetchCommonType.proto */
1935 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
1936 
1937 /* CythonFunctionShared.proto */
1938 #define __Pyx_CyFunction_USED 1
1939 #define __Pyx_CYFUNCTION_STATICMETHOD  0x01
1940 #define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
1941 #define __Pyx_CYFUNCTION_CCLASS        0x04
1942 #define __Pyx_CyFunction_GetClosure(f)\
1943     (((__pyx_CyFunctionObject *) (f))->func_closure)
1944 #define __Pyx_CyFunction_GetClassObj(f)\
1945     (((__pyx_CyFunctionObject *) (f))->func_classobj)
1946 #define __Pyx_CyFunction_Defaults(type, f)\
1947     ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
1948 #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
1949     ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
1950 typedef struct {
1951     PyCFunctionObject func;
1952 #if PY_VERSION_HEX < 0x030500A0
1953     PyObject *func_weakreflist;
1954 #endif
1955     PyObject *func_dict;
1956     PyObject *func_name;
1957     PyObject *func_qualname;
1958     PyObject *func_doc;
1959     PyObject *func_globals;
1960     PyObject *func_code;
1961     PyObject *func_closure;
1962     PyObject *func_classobj;
1963     void *defaults;
1964     int defaults_pyobjects;
1965     size_t defaults_size;  // used by FusedFunction for copying defaults
1966     int flags;
1967     PyObject *defaults_tuple;
1968     PyObject *defaults_kwdict;
1969     PyObject *(*defaults_getter)(PyObject *);
1970     PyObject *func_annotations;
1971 } __pyx_CyFunctionObject;
1972 static PyTypeObject *__pyx_CyFunctionType = 0;
1973 #define __Pyx_CyFunction_Check(obj)  (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
1974 static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
1975                                       int flags, PyObject* qualname,
1976                                       PyObject *self,
1977                                       PyObject *module, PyObject *globals,
1978                                       PyObject* code);
1979 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
1980                                                          size_t size,
1981                                                          int pyobjects);
1982 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
1983                                                             PyObject *tuple);
1984 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
1985                                                              PyObject *dict);
1986 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
1987                                                               PyObject *dict);
1988 static int __pyx_CyFunction_init(void);
1989 
1990 /* FusedFunction.proto */
1991 typedef struct {
1992     __pyx_CyFunctionObject func;
1993     PyObject *__signatures__;
1994     PyObject *type;
1995     PyObject *self;
1996 } __pyx_FusedFunctionObject;
1997 static PyObject *__pyx_FusedFunction_New(PyMethodDef *ml, int flags,
1998                                          PyObject *qualname, PyObject *closure,
1999                                          PyObject *module, PyObject *globals,
2000                                          PyObject *code);
2001 static int __pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self);
2002 static PyTypeObject *__pyx_FusedFunctionType = NULL;
2003 static int __pyx_FusedFunction_init(void);
2004 #define __Pyx_FusedFunction_USED
2005 
2006 /* CLineInTraceback.proto */
2007 #ifdef CYTHON_CLINE_IN_TRACEBACK
2008 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
2009 #else
2010 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
2011 #endif
2012 
2013 /* CodeObjectCache.proto */
2014 typedef struct {
2015     PyCodeObject* code_object;
2016     int code_line;
2017 } __Pyx_CodeObjectCacheEntry;
2018 struct __Pyx_CodeObjectCache {
2019     int count;
2020     int max_count;
2021     __Pyx_CodeObjectCacheEntry* entries;
2022 };
2023 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
2024 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
2025 static PyCodeObject *__pyx_find_code_object(int code_line);
2026 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
2027 
2028 /* AddTraceback.proto */
2029 static void __Pyx_AddTraceback(const char *funcname, int c_line,
2030                                int py_line, const char *filename);
2031 
2032 #if PY_MAJOR_VERSION < 3
2033     static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
2034     static void __Pyx_ReleaseBuffer(Py_buffer *view);
2035 #else
2036     #define __Pyx_GetBuffer PyObject_GetBuffer
2037     #define __Pyx_ReleaseBuffer PyBuffer_Release
2038 #endif
2039 
2040 
2041 /* BufferStructDeclare.proto */
2042 typedef struct {
2043   Py_ssize_t shape, strides, suboffsets;
2044 } __Pyx_Buf_DimInfo;
2045 typedef struct {
2046   size_t refcount;
2047   Py_buffer pybuffer;
2048 } __Pyx_Buffer;
2049 typedef struct {
2050   __Pyx_Buffer *rcbuffer;
2051   char *data;
2052   __Pyx_Buf_DimInfo diminfo[8];
2053 } __Pyx_LocalBuf_ND;
2054 
2055 /* MemviewSliceIsContig.proto */
2056 static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim);
2057 
2058 /* OverlappingSlices.proto */
2059 static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
2060                                 __Pyx_memviewslice *slice2,
2061                                 int ndim, size_t itemsize);
2062 
2063 /* Capsule.proto */
2064 static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);
2065 
2066 /* IsLittleEndian.proto */
2067 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
2068 
2069 /* BufferFormatCheck.proto */
2070 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
2071 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
2072                               __Pyx_BufFmt_StackElem* stack,
2073                               __Pyx_TypeInfo* type);
2074 
2075 /* TypeInfoCompare.proto */
2076 static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);
2077 
2078 /* MemviewSliceValidateAndInit.proto */
2079 static int __Pyx_ValidateAndInit_memviewslice(
2080                 int *axes_specs,
2081                 int c_or_f_flag,
2082                 int buf_flags,
2083                 int ndim,
2084                 __Pyx_TypeInfo *dtype,
2085                 __Pyx_BufFmt_StackElem stack[],
2086                 __Pyx_memviewslice *memviewslice,
2087                 PyObject *original_obj);
2088 
2089 /* ObjectToMemviewSlice.proto */
2090 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_float(PyObject *, int writable_flag);
2091 
2092 /* ObjectToMemviewSlice.proto */
2093 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_double(PyObject *, int writable_flag);
2094 
2095 /* ObjectToMemviewSlice.proto */
2096 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(PyObject *, int writable_flag);
2097 
2098 /* ObjectToMemviewSlice.proto */
2099 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(PyObject *, int writable_flag);
2100 
2101 /* ObjectToMemviewSlice.proto */
2102 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(PyObject *, int writable_flag);
2103 
2104 /* ObjectToMemviewSlice.proto */
2105 static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(PyObject *, int writable_flag);
2106 
2107 /* GCCDiagnostics.proto */
2108 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
2109 #define __Pyx_HAS_GCC_DIAGNOSTIC
2110 #endif
2111 
2112 /* MemviewDtypeToObject.proto */
2113 static CYTHON_INLINE PyObject *__pyx_memview_get_float(const char *itemp);
2114 static CYTHON_INLINE int __pyx_memview_set_float(const char *itemp, PyObject *obj);
2115 
2116 /* MemviewDtypeToObject.proto */
2117 static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp);
2118 static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj);
2119 
2120 /* RealImag.proto */
2121 #if CYTHON_CCOMPLEX
2122   #ifdef __cplusplus
2123     #define __Pyx_CREAL(z) ((z).real())
2124     #define __Pyx_CIMAG(z) ((z).imag())
2125   #else
2126     #define __Pyx_CREAL(z) (__real__(z))
2127     #define __Pyx_CIMAG(z) (__imag__(z))
2128   #endif
2129 #else
2130     #define __Pyx_CREAL(z) ((z).real)
2131     #define __Pyx_CIMAG(z) ((z).imag)
2132 #endif
2133 #if defined(__cplusplus) && CYTHON_CCOMPLEX\
2134         && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
2135     #define __Pyx_SET_CREAL(z,x) ((z).real(x))
2136     #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
2137 #else
2138     #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
2139     #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
2140 #endif
2141 
2142 /* Arithmetic.proto */
2143 #if CYTHON_CCOMPLEX
2144     #define __Pyx_c_eq_float(a, b)   ((a)==(b))
2145     #define __Pyx_c_sum_float(a, b)  ((a)+(b))
2146     #define __Pyx_c_diff_float(a, b) ((a)-(b))
2147     #define __Pyx_c_prod_float(a, b) ((a)*(b))
2148     #define __Pyx_c_quot_float(a, b) ((a)/(b))
2149     #define __Pyx_c_neg_float(a)     (-(a))
2150   #ifdef __cplusplus
2151     #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
2152     #define __Pyx_c_conj_float(z)    (::std::conj(z))
2153     #if 1
2154         #define __Pyx_c_abs_float(z)     (::std::abs(z))
2155         #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
2156     #endif
2157   #else
2158     #define __Pyx_c_is_zero_float(z) ((z)==0)
2159     #define __Pyx_c_conj_float(z)    (conjf(z))
2160     #if 1
2161         #define __Pyx_c_abs_float(z)     (cabsf(z))
2162         #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
2163     #endif
2164  #endif
2165 #else
2166     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
2167     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
2168     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
2169     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
2170     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
2171     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
2172     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
2173     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
2174     #if 1
2175         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
2176         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
2177     #endif
2178 #endif
2179 
2180 /* Arithmetic.proto */
2181 #if CYTHON_CCOMPLEX
2182     #define __Pyx_c_eq_double(a, b)   ((a)==(b))
2183     #define __Pyx_c_sum_double(a, b)  ((a)+(b))
2184     #define __Pyx_c_diff_double(a, b) ((a)-(b))
2185     #define __Pyx_c_prod_double(a, b) ((a)*(b))
2186     #define __Pyx_c_quot_double(a, b) ((a)/(b))
2187     #define __Pyx_c_neg_double(a)     (-(a))
2188   #ifdef __cplusplus
2189     #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
2190     #define __Pyx_c_conj_double(z)    (::std::conj(z))
2191     #if 1
2192         #define __Pyx_c_abs_double(z)     (::std::abs(z))
2193         #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
2194     #endif
2195   #else
2196     #define __Pyx_c_is_zero_double(z) ((z)==0)
2197     #define __Pyx_c_conj_double(z)    (conj(z))
2198     #if 1
2199         #define __Pyx_c_abs_double(z)     (cabs(z))
2200         #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
2201     #endif
2202  #endif
2203 #else
2204     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
2205     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
2206     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
2207     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
2208     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
2209     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
2210     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
2211     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
2212     #if 1
2213         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
2214         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
2215     #endif
2216 #endif
2217 
2218 /* MemviewSliceCopyTemplate.proto */
2219 static __Pyx_memviewslice
2220 __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
2221                                  const char *mode, int ndim,
2222                                  size_t sizeof_dtype, int contig_flag,
2223                                  int dtype_is_object);
2224 
2225 /* CIntToPy.proto */
2226 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
2227 
2228 /* CIntToPy.proto */
2229 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
2230 
2231 /* BytesContains.proto */
2232 static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character);
2233 
2234 /* CIntToPy.proto */
2235 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value);
2236 
2237 /* CIntFromPy.proto */
2238 static CYTHON_INLINE Py_intptr_t __Pyx_PyInt_As_Py_intptr_t(PyObject *);
2239 
2240 /* CIntFromPy.proto */
2241 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
2242 
2243 /* ImportNumPyArray.proto */
2244 static PyObject *__pyx_numpy_ndarray = NULL;
2245 static PyObject* __Pyx_ImportNumPyArrayTypeIfAvailable(void);
2246 
2247 /* CIntFromPy.proto */
2248 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
2249 
2250 /* CIntFromPy.proto */
2251 static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
2252 
2253 /* CheckBinaryVersion.proto */
2254 static int __Pyx_check_binary_version(void);
2255 
2256 /* InitStrings.proto */
2257 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
2258 
2259 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/
2260 static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/
2261 static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/
2262 static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/
2263 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*/
2264 static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/
2265 static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
2266 static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
2267 static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
2268 static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
2269 
2270 /* Module declarations from 'cython.view' */
2271 
2272 /* Module declarations from 'cython' */
2273 
2274 /* Module declarations from 'cpython.buffer' */
2275 
2276 /* Module declarations from 'libc.string' */
2277 
2278 /* Module declarations from 'libc.stdio' */
2279 
2280 /* Module declarations from '__builtin__' */
2281 
2282 /* Module declarations from 'cpython.type' */
2283 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
2284 
2285 /* Module declarations from 'cpython' */
2286 
2287 /* Module declarations from 'cpython.object' */
2288 
2289 /* Module declarations from 'cpython.ref' */
2290 
2291 /* Module declarations from 'cpython.mem' */
2292 
2293 /* Module declarations from 'numpy' */
2294 
2295 /* Module declarations from 'numpy' */
2296 static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
2297 static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
2298 static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
2299 static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
2300 static PyTypeObject *__pyx_ptype_5numpy_generic = 0;
2301 static PyTypeObject *__pyx_ptype_5numpy_number = 0;
2302 static PyTypeObject *__pyx_ptype_5numpy_integer = 0;
2303 static PyTypeObject *__pyx_ptype_5numpy_signedinteger = 0;
2304 static PyTypeObject *__pyx_ptype_5numpy_unsignedinteger = 0;
2305 static PyTypeObject *__pyx_ptype_5numpy_inexact = 0;
2306 static PyTypeObject *__pyx_ptype_5numpy_floating = 0;
2307 static PyTypeObject *__pyx_ptype_5numpy_complexfloating = 0;
2308 static PyTypeObject *__pyx_ptype_5numpy_flexible = 0;
2309 static PyTypeObject *__pyx_ptype_5numpy_character = 0;
2310 static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
2311 
2312 /* Module declarations from 'dipy.align.fused_types' */
2313 
2314 /* Module declarations from 'dipy.align.sumsqdiff' */
2315 static PyTypeObject *__pyx_array_type = 0;
2316 static PyTypeObject *__pyx_MemviewEnum_type = 0;
2317 static PyTypeObject *__pyx_memoryview_type = 0;
2318 static PyTypeObject *__pyx_memoryviewslice_type = 0;
2319 static PyObject *generic = 0;
2320 static PyObject *strided = 0;
2321 static PyObject *indirect = 0;
2322 static PyObject *contiguous = 0;
2323 static PyObject *indirect_contiguous = 0;
2324 static int __pyx_memoryview_thread_locks_used;
2325 static PyThread_type_lock __pyx_memoryview_thread_locks[8];
2326 static void __pyx_f_4dipy_5align_9sumsqdiff__solve_2d_symmetric_positive_definite(double *, double *, double, double *); /*proto*/
2327 static int __pyx_f_4dipy_5align_9sumsqdiff__solve_3d_symmetric_positive_definite(double *, double *, double, double *); /*proto*/
2328 static double __pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_2d(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, double, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2329 static double __pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_2d(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, double, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2330 static double __pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_2d(__Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2331 static double __pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_2d(__Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2332 static double __pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_3d(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, double, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2333 static double __pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_3d(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, double, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2334 static double __pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_3d(__Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2335 static double __pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_3d(__Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2336 static PyObject *__pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_residual_displacement_field_ssd_2d(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, double, __Pyx_memviewslice, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2337 static PyObject *__pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_residual_displacement_field_ssd_2d(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, double, __Pyx_memviewslice, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
2338 static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
2339 static void *__pyx_align_pointer(void *, size_t); /*proto*/
2340 static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/
2341 static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/
2342 static PyObject *_unellipsify(PyObject *, int); /*proto*/
2343 static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/
2344 static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/
2345 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*/
2346 static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/
2347 static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/
2348 static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/
2349 static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2350 static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2351 static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/
2352 static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
2353 static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/
2354 static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/
2355 static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/
2356 static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/
2357 static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/
2358 static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/
2359 static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/
2360 static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/
2361 static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/
2362 static int __pyx_memoryview_err(PyObject *, char *); /*proto*/
2363 static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/
2364 static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/
2365 static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/
2366 static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
2367 static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
2368 static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/
2369 static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
2370 static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/
2371 static __Pyx_TypeInfo __Pyx_TypeInfo_float = { "float", NULL, sizeof(float), { 0 }, 0, 'R', 0, 0 };
2372 static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 };
2373 #define __Pyx_MODULE_NAME "dipy.align.sumsqdiff"
2374 extern int __pyx_module_is_main_dipy__align__sumsqdiff;
2375 int __pyx_module_is_main_dipy__align__sumsqdiff = 0;
2376 
2377 /* Implementation of 'dipy.align.sumsqdiff' */
2378 static PyObject *__pyx_builtin_TypeError;
2379 static PyObject *__pyx_builtin_range;
2380 static PyObject *__pyx_builtin_ImportError;
2381 static PyObject *__pyx_builtin_ValueError;
2382 static PyObject *__pyx_builtin_MemoryError;
2383 static PyObject *__pyx_builtin_enumerate;
2384 static PyObject *__pyx_builtin_Ellipsis;
2385 static PyObject *__pyx_builtin_id;
2386 static PyObject *__pyx_builtin_IndexError;
2387 static const char __pyx_k_A[] = "A";
2388 static const char __pyx_k_O[] = "O";
2389 static const char __pyx_k_b[] = "b";
2390 static const char __pyx_k_c[] = "c";
2391 static const char __pyx_k_d[] = "d";
2392 static const char __pyx_k_g[] = "g";
2393 static const char __pyx_k_i[] = "i";
2394 static const char __pyx_k_j[] = "j";
2395 static const char __pyx_k_k[] = "k";
2396 static const char __pyx_k_r[] = "r";
2397 static const char __pyx_k_s[] = "s";
2398 static const char __pyx_k_y[] = "y";
2399 static const char __pyx_k__3[] = "()";
2400 static const char __pyx_k__4[] = "|";
2401 static const char __pyx_k__7[] = "";
2402 static const char __pyx_k_dc[] = "dc";
2403 static const char __pyx_k_dr[] = "dr";
2404 static const char __pyx_k_ds[] = "ds";
2405 static const char __pyx_k_id[] = "id";
2406 static const char __pyx_k_nc[] = "nc";
2407 static const char __pyx_k_np[] = "np";
2408 static const char __pyx_k_nr[] = "nr";
2409 static const char __pyx_k_ns[] = "ns";
2410 static const char __pyx_k_den[] = "den";
2411 static const char __pyx_k_det[] = "det";
2412 static const char __pyx_k_new[] = "__new__";
2413 static const char __pyx_k_obj[] = "obj";
2414 static const char __pyx_k_out[] = "out";
2415 static const char __pyx_k_tau[] = "tau";
2416 static const char __pyx_k_args[] = "args";
2417 static const char __pyx_k_base[] = "base";
2418 static const char __pyx_k_dCol[] = "dCol";
2419 static const char __pyx_k_dRow[] = "dRow";
2420 static const char __pyx_k_dict[] = "__dict__";
2421 static const char __pyx_k_disp[] = "disp";
2422 static const char __pyx_k_dotP[] = "dotP";
2423 static const char __pyx_k_grad[] = "grad";
2424 static const char __pyx_k_kind[] = "kind";
2425 static const char __pyx_k_main[] = "__main__";
2426 static const char __pyx_k_mode[] = "mode";
2427 static const char __pyx_k_name[] = "name";
2428 static const char __pyx_k_ndim[] = "ndim";
2429 static const char __pyx_k_nrm2[] = "nrm2";
2430 static const char __pyx_k_pack[] = "pack";
2431 static const char __pyx_k_size[] = "size";
2432 static const char __pyx_k_step[] = "step";
2433 static const char __pyx_k_stop[] = "stop";
2434 static const char __pyx_k_test[] = "__test__";
2435 static const char __pyx_k_ASCII[] = "ASCII";
2436 static const char __pyx_k_class[] = "__class__";
2437 static const char __pyx_k_delta[] = "delta";
2438 static const char __pyx_k_dtype[] = "dtype";
2439 static const char __pyx_k_empty[] = "empty";
2440 static const char __pyx_k_error[] = "error";
2441 static const char __pyx_k_flags[] = "flags";
2442 static const char __pyx_k_float[] = "float";
2443 static const char __pyx_k_ftype[] = "ftype";
2444 static const char __pyx_k_ncols[] = "ncols";
2445 static const char __pyx_k_nrows[] = "nrows";
2446 static const char __pyx_k_numpy[] = "numpy";
2447 static const char __pyx_k_range[] = "range";
2448 static const char __pyx_k_shape[] = "shape";
2449 static const char __pyx_k_split[] = "split";
2450 static const char __pyx_k_start[] = "start";
2451 static const char __pyx_k_strip[] = "strip";
2452 static const char __pyx_k_zeros[] = "zeros";
2453 static const char __pyx_k_dSlice[] = "dSlice";
2454 static const char __pyx_k_double[] = "double";
2455 static const char __pyx_k_encode[] = "encode";
2456 static const char __pyx_k_energy[] = "energy";
2457 static const char __pyx_k_format[] = "format";
2458 static const char __pyx_k_import[] = "__import__";
2459 static const char __pyx_k_kwargs[] = "kwargs";
2460 static const char __pyx_k_name_2[] = "__name__";
2461 static const char __pyx_k_pickle[] = "pickle";
2462 static const char __pyx_k_reduce[] = "__reduce__";
2463 static const char __pyx_k_struct[] = "struct";
2464 static const char __pyx_k_target[] = "target";
2465 static const char __pyx_k_unpack[] = "unpack";
2466 static const char __pyx_k_update[] = "update";
2467 static const char __pyx_k_asarray[] = "asarray";
2468 static const char __pyx_k_delta_2[] = "delta_2";
2469 static const char __pyx_k_fortran[] = "fortran";
2470 static const char __pyx_k_memview[] = "memview";
2471 static const char __pyx_k_nslices[] = "nslices";
2472 static const char __pyx_k_sigmasq[] = "sigmasq";
2473 static const char __pyx_k_Ellipsis[] = "Ellipsis";
2474 static const char __pyx_k_defaults[] = "defaults";
2475 static const char __pyx_k_getstate[] = "__getstate__";
2476 static const char __pyx_k_itemsize[] = "itemsize";
2477 static const char __pyx_k_pyx_type[] = "__pyx_type";
2478 static const char __pyx_k_residual[] = "residual";
2479 static const char __pyx_k_setstate[] = "__setstate__";
2480 static const char __pyx_k_TypeError[] = "TypeError";
2481 static const char __pyx_k_enumerate[] = "enumerate";
2482 static const char __pyx_k_pyx_state[] = "__pyx_state";
2483 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
2484 static const char __pyx_k_IndexError[] = "IndexError";
2485 static const char __pyx_k_ValueError[] = "ValueError";
2486 static const char __pyx_k_pyx_result[] = "__pyx_result";
2487 static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
2488 static const char __pyx_k_sigma_sq_x[] = "sigma_sq_x";
2489 static const char __pyx_k_signatures[] = "signatures";
2490 static const char __pyx_k_ImportError[] = "ImportError";
2491 static const char __pyx_k_MemoryError[] = "MemoryError";
2492 static const char __pyx_k_PickleError[] = "PickleError";
2493 static const char __pyx_k_delta_field[] = "delta_field";
2494 static const char __pyx_k_is_singular[] = "is_singular";
2495 static const char __pyx_k_lambda_param[] = "lambda_param";
2496 static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
2497 static const char __pyx_k_stringsource[] = "stringsource";
2498 static const char __pyx_k_NUM_NEIGHBORS[] = "NUM_NEIGHBORS";
2499 static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
2500 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
2501 static const char __pyx_k_sigmasq_field[] = "sigmasq_field";
2502 static const char __pyx_k_gradient_field[] = "gradient_field";
2503 static const char __pyx_k_View_MemoryView[] = "View.MemoryView";
2504 static const char __pyx_k_allocate_buffer[] = "allocate_buffer";
2505 static const char __pyx_k_dtype_is_object[] = "dtype_is_object";
2506 static const char __pyx_k_gradient_moving[] = "gradient_moving";
2507 static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
2508 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
2509 static const char __pyx_k_ascontiguousarray[] = "ascontiguousarray";
2510 static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum";
2511 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
2512 static const char __pyx_k_displacement_field[] = "displacement_field";
2513 static const char __pyx_k_strided_and_direct[] = "<strided and direct>";
2514 static const char __pyx_k_dipy_align_sumsqdiff[] = "dipy.align.sumsqdiff";
2515 static const char __pyx_k_strided_and_indirect[] = "<strided and indirect>";
2516 static const char __pyx_k_compute_energy_ssd_2d[] = "compute_energy_ssd_2d";
2517 static const char __pyx_k_compute_energy_ssd_3d[] = "compute_energy_ssd_3d";
2518 static const char __pyx_k_contiguous_and_direct[] = "<contiguous and direct>";
2519 static const char __pyx_k_MemoryView_of_r_object[] = "<MemoryView of %r object>";
2520 static const char __pyx_k_MemoryView_of_r_at_0x_x[] = "<MemoryView of %r at 0x%x>";
2521 static const char __pyx_k_contiguous_and_indirect[] = "<contiguous and indirect>";
2522 static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
2523 static const char __pyx_k_dipy_align_sumsqdiff_pyx[] = "dipy/align/sumsqdiff.pyx";
2524 static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
2525 static const char __pyx_k_compute_ssd_demons_step_2d[] = "compute_ssd_demons_step_2d";
2526 static const char __pyx_k_compute_ssd_demons_step_3d[] = "compute_ssd_demons_step_3d";
2527 static const char __pyx_k_No_matching_signature_found[] = "No matching signature found";
2528 static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
2529 static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
2530 static const char __pyx_k_pyx_fuse_0compute_energy_ssd_2[] = "__pyx_fuse_0compute_energy_ssd_2d";
2531 static const char __pyx_k_pyx_fuse_0compute_energy_ssd_3[] = "__pyx_fuse_0compute_energy_ssd_3d";
2532 static const char __pyx_k_pyx_fuse_0compute_residual_dis[] = "__pyx_fuse_0compute_residual_displacement_field_ssd_2d";
2533 static const char __pyx_k_pyx_fuse_0iterate_residual_dis[] = "__pyx_fuse_0iterate_residual_displacement_field_ssd_2d";
2534 static const char __pyx_k_pyx_fuse_1compute_energy_ssd_2[] = "__pyx_fuse_1compute_energy_ssd_2d";
2535 static const char __pyx_k_pyx_fuse_1compute_energy_ssd_3[] = "__pyx_fuse_1compute_energy_ssd_3d";
2536 static const char __pyx_k_pyx_fuse_1compute_residual_dis[] = "__pyx_fuse_1compute_residual_displacement_field_ssd_2d";
2537 static const char __pyx_k_pyx_fuse_1iterate_residual_dis[] = "__pyx_fuse_1iterate_residual_displacement_field_ssd_2d";
2538 static const char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
2539 static const char __pyx_k_Utility_functions_used_by_the_S[] = " Utility functions used by the Sum of Squared Differences (SSD) metric ";
2540 static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
2541 static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
2542 static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
2543 static const char __pyx_k_Cannot_assign_to_read_only_memor[] = "Cannot assign to read-only memoryview";
2544 static const char __pyx_k_Cannot_create_writable_memory_vi[] = "Cannot create writable memory view from read-only memoryview";
2545 static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
2546 static const char __pyx_k_Expected_at_least_d_argument_s_g[] = "Expected at least %d argument%s, got %d";
2547 static const char __pyx_k_Function_call_with_ambiguous_arg[] = "Function call with ambiguous argument types";
2548 static const char __pyx_k_Incompatible_checksums_s_vs_0xb0[] = "Incompatible checksums (%s vs 0xb068931 = (name))";
2549 static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported";
2550 static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s";
2551 static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)";
2552 static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
2553 static const char __pyx_k_compute_residual_displacement_fi[] = "compute_residual_displacement_field_ssd_3d";
2554 static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)";
2555 static const char __pyx_k_iterate_residual_displacement_fi[] = "iterate_residual_displacement_field_ssd_2d";
2556 static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
2557 static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
2558 static const char __pyx_k_pyx_fuse_0iterate_residual_dis_2[] = "__pyx_fuse_0iterate_residual_displacement_field_ssd_3d";
2559 static const char __pyx_k_pyx_fuse_1iterate_residual_dis_2[] = "__pyx_fuse_1iterate_residual_displacement_field_ssd_3d";
2560 static const char __pyx_k_solve_2d_symmetric_positive_defi[] = "solve_2d_symmetric_positive_definite";
2561 static const char __pyx_k_solve_3d_symmetric_positive_defi[] = "solve_3d_symmetric_positive_definite";
2562 static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
2563 static const char __pyx_k_compute_residual_displacement_fi_2[] = "compute_residual_displacement_field_ssd_2d";
2564 static const char __pyx_k_iterate_residual_displacement_fi_2[] = "iterate_residual_displacement_field_ssd_3d";
2565 static PyObject *__pyx_n_s_A;
2566 static PyObject *__pyx_n_s_ASCII;
2567 static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri;
2568 static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is;
2569 static PyObject *__pyx_kp_s_Cannot_assign_to_read_only_memor;
2570 static PyObject *__pyx_kp_s_Cannot_create_writable_memory_vi;
2571 static PyObject *__pyx_kp_s_Cannot_index_with_type_s;
2572 static PyObject *__pyx_n_s_Ellipsis;
2573 static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr;
2574 static PyObject *__pyx_kp_s_Expected_at_least_d_argument_s_g;
2575 static PyObject *__pyx_kp_s_Function_call_with_ambiguous_arg;
2576 static PyObject *__pyx_n_s_ImportError;
2577 static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xb0;
2578 static PyObject *__pyx_n_s_IndexError;
2579 static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte;
2580 static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr;
2581 static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d;
2582 static PyObject *__pyx_n_s_MemoryError;
2583 static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x;
2584 static PyObject *__pyx_kp_s_MemoryView_of_r_object;
2585 static PyObject *__pyx_n_s_NUM_NEIGHBORS;
2586 static PyObject *__pyx_kp_s_No_matching_signature_found;
2587 static PyObject *__pyx_n_b_O;
2588 static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
2589 static PyObject *__pyx_n_s_PickleError;
2590 static PyObject *__pyx_n_s_TypeError;
2591 static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object;
2592 static PyObject *__pyx_n_s_ValueError;
2593 static PyObject *__pyx_n_s_View_MemoryView;
2594 static PyObject *__pyx_kp_s__3;
2595 static PyObject *__pyx_kp_s__4;
2596 static PyObject *__pyx_kp_s__7;
2597 static PyObject *__pyx_n_s_allocate_buffer;
2598 static PyObject *__pyx_n_s_args;
2599 static PyObject *__pyx_n_s_asarray;
2600 static PyObject *__pyx_n_s_ascontiguousarray;
2601 static PyObject *__pyx_n_s_b;
2602 static PyObject *__pyx_n_s_base;
2603 static PyObject *__pyx_n_s_c;
2604 static PyObject *__pyx_n_u_c;
2605 static PyObject *__pyx_n_s_class;
2606 static PyObject *__pyx_n_s_cline_in_traceback;
2607 static PyObject *__pyx_n_s_compute_energy_ssd_2d;
2608 static PyObject *__pyx_n_s_compute_energy_ssd_3d;
2609 static PyObject *__pyx_n_s_compute_residual_displacement_fi;
2610 static PyObject *__pyx_n_s_compute_residual_displacement_fi_2;
2611 static PyObject *__pyx_n_s_compute_ssd_demons_step_2d;
2612 static PyObject *__pyx_n_s_compute_ssd_demons_step_3d;
2613 static PyObject *__pyx_kp_s_contiguous_and_direct;
2614 static PyObject *__pyx_kp_s_contiguous_and_indirect;
2615 static PyObject *__pyx_n_s_d;
2616 static PyObject *__pyx_n_s_dCol;
2617 static PyObject *__pyx_n_s_dRow;
2618 static PyObject *__pyx_n_s_dSlice;
2619 static PyObject *__pyx_n_s_dc;
2620 static PyObject *__pyx_n_s_defaults;
2621 static PyObject *__pyx_n_s_delta;
2622 static PyObject *__pyx_n_s_delta_2;
2623 static PyObject *__pyx_n_s_delta_field;
2624 static PyObject *__pyx_n_s_den;
2625 static PyObject *__pyx_n_s_det;
2626 static PyObject *__pyx_n_s_dict;
2627 static PyObject *__pyx_n_s_dipy_align_sumsqdiff;
2628 static PyObject *__pyx_kp_s_dipy_align_sumsqdiff_pyx;
2629 static PyObject *__pyx_n_s_disp;
2630 static PyObject *__pyx_n_s_displacement_field;
2631 static PyObject *__pyx_n_s_dotP;
2632 static PyObject *__pyx_n_s_double;
2633 static PyObject *__pyx_n_s_dr;
2634 static PyObject *__pyx_n_s_ds;
2635 static PyObject *__pyx_n_s_dtype;
2636 static PyObject *__pyx_n_s_dtype_is_object;
2637 static PyObject *__pyx_n_s_empty;
2638 static PyObject *__pyx_n_s_encode;
2639 static PyObject *__pyx_n_s_energy;
2640 static PyObject *__pyx_n_s_enumerate;
2641 static PyObject *__pyx_n_s_error;
2642 static PyObject *__pyx_n_s_flags;
2643 static PyObject *__pyx_n_s_float;
2644 static PyObject *__pyx_n_s_format;
2645 static PyObject *__pyx_n_s_fortran;
2646 static PyObject *__pyx_n_u_fortran;
2647 static PyObject *__pyx_n_s_ftype;
2648 static PyObject *__pyx_n_s_g;
2649 static PyObject *__pyx_n_s_getstate;
2650 static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
2651 static PyObject *__pyx_n_s_grad;
2652 static PyObject *__pyx_n_s_gradient_field;
2653 static PyObject *__pyx_n_s_gradient_moving;
2654 static PyObject *__pyx_n_s_i;
2655 static PyObject *__pyx_n_s_id;
2656 static PyObject *__pyx_n_s_import;
2657 static PyObject *__pyx_n_s_is_singular;
2658 static PyObject *__pyx_n_s_itemsize;
2659 static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
2660 static PyObject *__pyx_n_s_iterate_residual_displacement_fi;
2661 static PyObject *__pyx_n_s_iterate_residual_displacement_fi_2;
2662 static PyObject *__pyx_n_s_j;
2663 static PyObject *__pyx_n_s_k;
2664 static PyObject *__pyx_n_s_kind;
2665 static PyObject *__pyx_n_s_kwargs;
2666 static PyObject *__pyx_n_s_lambda_param;
2667 static PyObject *__pyx_n_s_main;
2668 static PyObject *__pyx_n_s_memview;
2669 static PyObject *__pyx_n_s_mode;
2670 static PyObject *__pyx_n_s_name;
2671 static PyObject *__pyx_n_s_name_2;
2672 static PyObject *__pyx_n_s_nc;
2673 static PyObject *__pyx_n_s_ncols;
2674 static PyObject *__pyx_n_s_ndim;
2675 static PyObject *__pyx_n_s_new;
2676 static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
2677 static PyObject *__pyx_n_s_np;
2678 static PyObject *__pyx_n_s_nr;
2679 static PyObject *__pyx_n_s_nrm2;
2680 static PyObject *__pyx_n_s_nrows;
2681 static PyObject *__pyx_n_s_ns;
2682 static PyObject *__pyx_n_s_nslices;
2683 static PyObject *__pyx_n_s_numpy;
2684 static PyObject *__pyx_kp_u_numpy_core_multiarray_failed_to;
2685 static PyObject *__pyx_kp_u_numpy_core_umath_failed_to_impor;
2686 static PyObject *__pyx_n_s_obj;
2687 static PyObject *__pyx_n_s_out;
2688 static PyObject *__pyx_n_s_pack;
2689 static PyObject *__pyx_n_s_pickle;
2690 static PyObject *__pyx_n_s_pyx_PickleError;
2691 static PyObject *__pyx_n_s_pyx_checksum;
2692 static PyObject *__pyx_n_s_pyx_fuse_0compute_energy_ssd_2;
2693 static PyObject *__pyx_n_s_pyx_fuse_0compute_energy_ssd_3;
2694 static PyObject *__pyx_n_s_pyx_fuse_0compute_residual_dis;
2695 static PyObject *__pyx_n_s_pyx_fuse_0iterate_residual_dis;
2696 static PyObject *__pyx_n_s_pyx_fuse_0iterate_residual_dis_2;
2697 static PyObject *__pyx_n_s_pyx_fuse_1compute_energy_ssd_2;
2698 static PyObject *__pyx_n_s_pyx_fuse_1compute_energy_ssd_3;
2699 static PyObject *__pyx_n_s_pyx_fuse_1compute_residual_dis;
2700 static PyObject *__pyx_n_s_pyx_fuse_1iterate_residual_dis;
2701 static PyObject *__pyx_n_s_pyx_fuse_1iterate_residual_dis_2;
2702 static PyObject *__pyx_n_s_pyx_getbuffer;
2703 static PyObject *__pyx_n_s_pyx_result;
2704 static PyObject *__pyx_n_s_pyx_state;
2705 static PyObject *__pyx_n_s_pyx_type;
2706 static PyObject *__pyx_n_s_pyx_unpickle_Enum;
2707 static PyObject *__pyx_n_s_pyx_vtable;
2708 static PyObject *__pyx_n_s_r;
2709 static PyObject *__pyx_n_s_range;
2710 static PyObject *__pyx_n_s_reduce;
2711 static PyObject *__pyx_n_s_reduce_cython;
2712 static PyObject *__pyx_n_s_reduce_ex;
2713 static PyObject *__pyx_n_s_residual;
2714 static PyObject *__pyx_n_s_s;
2715 static PyObject *__pyx_n_s_setstate;
2716 static PyObject *__pyx_n_s_setstate_cython;
2717 static PyObject *__pyx_n_s_shape;
2718 static PyObject *__pyx_n_s_sigma_sq_x;
2719 static PyObject *__pyx_n_s_sigmasq;
2720 static PyObject *__pyx_n_s_sigmasq_field;
2721 static PyObject *__pyx_n_s_signatures;
2722 static PyObject *__pyx_n_s_size;
2723 static PyObject *__pyx_n_s_solve_2d_symmetric_positive_defi;
2724 static PyObject *__pyx_n_s_solve_3d_symmetric_positive_defi;
2725 static PyObject *__pyx_n_s_split;
2726 static PyObject *__pyx_n_s_start;
2727 static PyObject *__pyx_n_s_step;
2728 static PyObject *__pyx_n_s_stop;
2729 static PyObject *__pyx_kp_s_strided_and_direct;
2730 static PyObject *__pyx_kp_s_strided_and_direct_or_indirect;
2731 static PyObject *__pyx_kp_s_strided_and_indirect;
2732 static PyObject *__pyx_kp_s_stringsource;
2733 static PyObject *__pyx_n_s_strip;
2734 static PyObject *__pyx_n_s_struct;
2735 static PyObject *__pyx_n_s_target;
2736 static PyObject *__pyx_n_s_tau;
2737 static PyObject *__pyx_n_s_test;
2738 static PyObject *__pyx_kp_s_unable_to_allocate_array_data;
2739 static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str;
2740 static PyObject *__pyx_n_s_unpack;
2741 static PyObject *__pyx_n_s_update;
2742 static PyObject *__pyx_n_s_y;
2743 static PyObject *__pyx_n_s_zeros;
2744 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_solve_2d_symmetric_positive_definite(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_A, PyObject *__pyx_v_y, double __pyx_v_det); /* proto */
2745 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_2solve_3d_symmetric_positive_definite(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_g, PyObject *__pyx_v_y, double __pyx_v_tau); /* proto */
2746 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_4iterate_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults); /* proto */
2747 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_20__pyx_fuse_0iterate_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_displacement_field); /* proto */
2748 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_22__pyx_fuse_1iterate_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_displacement_field); /* proto */
2749 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_6compute_energy_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults); /* proto */
2750 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_26__pyx_fuse_0compute_energy_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field); /* proto */
2751 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_28__pyx_fuse_1compute_energy_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field); /* proto */
2752 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_8iterate_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults); /* proto */
2753 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_32__pyx_fuse_0iterate_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_disp); /* proto */
2754 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_34__pyx_fuse_1iterate_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_disp); /* proto */
2755 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_10compute_energy_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults); /* proto */
2756 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_38__pyx_fuse_0compute_energy_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field); /* proto */
2757 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_40__pyx_fuse_1compute_energy_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field); /* proto */
2758 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_12compute_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults); /* proto */
2759 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_44compute_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_gradient_field, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_disp, __Pyx_memviewslice __pyx_v_residual); /* proto */
2760 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_46compute_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_gradient_field, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_disp, __Pyx_memviewslice __pyx_v_residual); /* proto */
2761 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_14compute_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults); /* proto */
2762 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_50__pyx_fuse_0compute_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_gradient_field, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_d, __Pyx_memviewslice __pyx_v_residual); /* proto */
2763 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_52__pyx_fuse_1compute_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_gradient_field, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_d, __Pyx_memviewslice __pyx_v_residual); /* proto */
2764 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_16compute_ssd_demons_step_2d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults); /* proto */
2765 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_56compute_ssd_demons_step_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_gradient_moving, double __pyx_v_sigma_sq_x, __Pyx_memviewslice __pyx_v_out); /* proto */
2766 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_58compute_ssd_demons_step_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_gradient_moving, double __pyx_v_sigma_sq_x, __Pyx_memviewslice __pyx_v_out); /* proto */
2767 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_18compute_ssd_demons_step_3d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults); /* proto */
2768 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_62compute_ssd_demons_step_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_gradient_moving, double __pyx_v_sigma_sq_x, __Pyx_memviewslice __pyx_v_out); /* proto */
2769 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_64compute_ssd_demons_step_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_gradient_moving, double __pyx_v_sigma_sq_x, __Pyx_memviewslice __pyx_v_out); /* proto */
2770 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 */
2771 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 */
2772 static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2773 static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2774 static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self); /* proto */
2775 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
2776 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
2777 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 */
2778 static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self); /* proto */
2779 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 */
2780 static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
2781 static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
2782 static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
2783 static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
2784 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 */
2785 static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2786 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
2787 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 */
2788 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 */
2789 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2790 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2791 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2792 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2793 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2794 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2795 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2796 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2797 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2798 static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2799 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2800 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2801 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2802 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2803 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2804 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2805 static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
2806 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 */
2807 static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2808 static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2809 static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
2810 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 */
2811 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 */
2812 static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2813 static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2814 static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2815 static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2816 static PyObject *__pyx_int_0;
2817 static PyObject *__pyx_int_1;
2818 static PyObject *__pyx_int_2;
2819 static PyObject *__pyx_int_3;
2820 static PyObject *__pyx_int_4;
2821 static PyObject *__pyx_int_6;
2822 static PyObject *__pyx_int_7;
2823 static PyObject *__pyx_int_184977713;
2824 static PyObject *__pyx_int_neg_1;
2825 static PyObject *__pyx_tuple_;
2826 static PyObject *__pyx_tuple__2;
2827 static PyObject *__pyx_tuple__5;
2828 static PyObject *__pyx_tuple__6;
2829 static PyObject *__pyx_tuple__8;
2830 static PyObject *__pyx_tuple__9;
2831 static PyObject *__pyx_slice__24;
2832 static PyObject *__pyx_tuple__10;
2833 static PyObject *__pyx_tuple__11;
2834 static PyObject *__pyx_tuple__12;
2835 static PyObject *__pyx_tuple__13;
2836 static PyObject *__pyx_tuple__14;
2837 static PyObject *__pyx_tuple__15;
2838 static PyObject *__pyx_tuple__16;
2839 static PyObject *__pyx_tuple__17;
2840 static PyObject *__pyx_tuple__18;
2841 static PyObject *__pyx_tuple__19;
2842 static PyObject *__pyx_tuple__20;
2843 static PyObject *__pyx_tuple__21;
2844 static PyObject *__pyx_tuple__22;
2845 static PyObject *__pyx_tuple__23;
2846 static PyObject *__pyx_tuple__25;
2847 static PyObject *__pyx_tuple__26;
2848 static PyObject *__pyx_tuple__27;
2849 static PyObject *__pyx_tuple__28;
2850 static PyObject *__pyx_tuple__30;
2851 static PyObject *__pyx_tuple__32;
2852 static PyObject *__pyx_tuple__34;
2853 static PyObject *__pyx_tuple__36;
2854 static PyObject *__pyx_tuple__38;
2855 static PyObject *__pyx_tuple__40;
2856 static PyObject *__pyx_tuple__42;
2857 static PyObject *__pyx_tuple__44;
2858 static PyObject *__pyx_tuple__46;
2859 static PyObject *__pyx_tuple__48;
2860 static PyObject *__pyx_tuple__49;
2861 static PyObject *__pyx_tuple__50;
2862 static PyObject *__pyx_tuple__51;
2863 static PyObject *__pyx_tuple__52;
2864 static PyObject *__pyx_tuple__53;
2865 static PyObject *__pyx_codeobj__29;
2866 static PyObject *__pyx_codeobj__31;
2867 static PyObject *__pyx_codeobj__33;
2868 static PyObject *__pyx_codeobj__35;
2869 static PyObject *__pyx_codeobj__37;
2870 static PyObject *__pyx_codeobj__39;
2871 static PyObject *__pyx_codeobj__41;
2872 static PyObject *__pyx_codeobj__43;
2873 static PyObject *__pyx_codeobj__45;
2874 static PyObject *__pyx_codeobj__47;
2875 static PyObject *__pyx_codeobj__54;
2876 /* Late includes */
2877 
2878 /* "dipy/align/sumsqdiff.pyx":15
2879  * @cython.wraparound(False)
2880  * @cython.cdivision(True)
2881  * cdef void _solve_2d_symmetric_positive_definite(double* A, double* y,             # <<<<<<<<<<<<<<
2882  *                                                 double det,
2883  *                                                 double* out) nogil:
2884  */
2885 
__pyx_f_4dipy_5align_9sumsqdiff__solve_2d_symmetric_positive_definite(double * __pyx_v_A,double * __pyx_v_y,double __pyx_v_det,double * __pyx_v_out)2886 static void __pyx_f_4dipy_5align_9sumsqdiff__solve_2d_symmetric_positive_definite(double *__pyx_v_A, double *__pyx_v_y, double __pyx_v_det, double *__pyx_v_out) {
2887 
2888   /* "dipy/align/sumsqdiff.pyx":37
2889  *         the array the output will be stored in
2890  *     """
2891  *     out[1] = (A[0] * y[1] - A[1] * y[0]) / det             # <<<<<<<<<<<<<<
2892  *     out[0] = (y[0] - A[1] * out[1]) / A[0]
2893  *
2894  */
2895   (__pyx_v_out[1]) = ((((__pyx_v_A[0]) * (__pyx_v_y[1])) - ((__pyx_v_A[1]) * (__pyx_v_y[0]))) / __pyx_v_det);
2896 
2897   /* "dipy/align/sumsqdiff.pyx":38
2898  *     """
2899  *     out[1] = (A[0] * y[1] - A[1] * y[0]) / det
2900  *     out[0] = (y[0] - A[1] * out[1]) / A[0]             # <<<<<<<<<<<<<<
2901  *
2902  *
2903  */
2904   (__pyx_v_out[0]) = (((__pyx_v_y[0]) - ((__pyx_v_A[1]) * (__pyx_v_out[1]))) / (__pyx_v_A[0]));
2905 
2906   /* "dipy/align/sumsqdiff.pyx":15
2907  * @cython.wraparound(False)
2908  * @cython.cdivision(True)
2909  * cdef void _solve_2d_symmetric_positive_definite(double* A, double* y,             # <<<<<<<<<<<<<<
2910  *                                                 double det,
2911  *                                                 double* out) nogil:
2912  */
2913 
2914   /* function exit code */
2915 }
2916 
2917 /* "dipy/align/sumsqdiff.pyx":41
2918  *
2919  *
2920  * def solve_2d_symmetric_positive_definite(A, y, double det):             # <<<<<<<<<<<<<<
2921  *     r"""Solves a 2-variable symmetric positive-definite linear system
2922  *
2923  */
2924 
2925 /* Python wrapper */
2926 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_1solve_2d_symmetric_positive_definite(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2927 static char __pyx_doc_4dipy_5align_9sumsqdiff_solve_2d_symmetric_positive_definite[] = "Solves a 2-variable symmetric positive-definite linear system\n\n    Solves the symmetric positive-definite linear system $Mx = y$ given by::\n\n        M = [[A[0], A[1]],\n             [A[1], A[2]]]\n\n    Parameters\n    ----------\n    A : array, shape (3,)\n        the array containing the entries of the symmetric 2x2 matrix\n    y : array, shape (2,)\n        right-hand side of the system to be solved\n\n    Returns\n    -------\n    out : array, shape (2,)\n        the array the output will be stored in\n    ";
2928 static PyMethodDef __pyx_mdef_4dipy_5align_9sumsqdiff_1solve_2d_symmetric_positive_definite = {"solve_2d_symmetric_positive_definite", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_1solve_2d_symmetric_positive_definite, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_solve_2d_symmetric_positive_definite};
__pyx_pw_4dipy_5align_9sumsqdiff_1solve_2d_symmetric_positive_definite(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)2929 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_1solve_2d_symmetric_positive_definite(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2930   PyObject *__pyx_v_A = 0;
2931   PyObject *__pyx_v_y = 0;
2932   double __pyx_v_det;
2933   int __pyx_lineno = 0;
2934   const char *__pyx_filename = NULL;
2935   int __pyx_clineno = 0;
2936   PyObject *__pyx_r = 0;
2937   __Pyx_RefNannyDeclarations
2938   __Pyx_RefNannySetupContext("solve_2d_symmetric_positive_definite (wrapper)", 0);
2939   {
2940     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_A,&__pyx_n_s_y,&__pyx_n_s_det,0};
2941     PyObject* values[3] = {0,0,0};
2942     if (unlikely(__pyx_kwds)) {
2943       Py_ssize_t kw_args;
2944       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2945       switch (pos_args) {
2946         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2947         CYTHON_FALLTHROUGH;
2948         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2949         CYTHON_FALLTHROUGH;
2950         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2951         CYTHON_FALLTHROUGH;
2952         case  0: break;
2953         default: goto __pyx_L5_argtuple_error;
2954       }
2955       kw_args = PyDict_Size(__pyx_kwds);
2956       switch (pos_args) {
2957         case  0:
2958         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--;
2959         else goto __pyx_L5_argtuple_error;
2960         CYTHON_FALLTHROUGH;
2961         case  1:
2962         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
2963         else {
2964           __Pyx_RaiseArgtupleInvalid("solve_2d_symmetric_positive_definite", 1, 3, 3, 1); __PYX_ERR(0, 41, __pyx_L3_error)
2965         }
2966         CYTHON_FALLTHROUGH;
2967         case  2:
2968         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_det)) != 0)) kw_args--;
2969         else {
2970           __Pyx_RaiseArgtupleInvalid("solve_2d_symmetric_positive_definite", 1, 3, 3, 2); __PYX_ERR(0, 41, __pyx_L3_error)
2971         }
2972       }
2973       if (unlikely(kw_args > 0)) {
2974         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "solve_2d_symmetric_positive_definite") < 0)) __PYX_ERR(0, 41, __pyx_L3_error)
2975       }
2976     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
2977       goto __pyx_L5_argtuple_error;
2978     } else {
2979       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2980       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2981       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2982     }
2983     __pyx_v_A = values[0];
2984     __pyx_v_y = values[1];
2985     __pyx_v_det = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_det == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 41, __pyx_L3_error)
2986   }
2987   goto __pyx_L4_argument_unpacking_done;
2988   __pyx_L5_argtuple_error:;
2989   __Pyx_RaiseArgtupleInvalid("solve_2d_symmetric_positive_definite", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 41, __pyx_L3_error)
2990   __pyx_L3_error:;
2991   __Pyx_AddTraceback("dipy.align.sumsqdiff.solve_2d_symmetric_positive_definite", __pyx_clineno, __pyx_lineno, __pyx_filename);
2992   __Pyx_RefNannyFinishContext();
2993   return NULL;
2994   __pyx_L4_argument_unpacking_done:;
2995   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_solve_2d_symmetric_positive_definite(__pyx_self, __pyx_v_A, __pyx_v_y, __pyx_v_det);
2996 
2997   /* function exit code */
2998   __Pyx_RefNannyFinishContext();
2999   return __pyx_r;
3000 }
3001 
__pyx_pf_4dipy_5align_9sumsqdiff_solve_2d_symmetric_positive_definite(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_A,PyObject * __pyx_v_y,double __pyx_v_det)3002 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_solve_2d_symmetric_positive_definite(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_A, PyObject *__pyx_v_y, double __pyx_v_det) {
3003   PyArrayObject *__pyx_v_out = 0;
3004   PyObject *__pyx_r = NULL;
3005   __Pyx_RefNannyDeclarations
3006   PyObject *__pyx_t_1 = NULL;
3007   PyObject *__pyx_t_2 = NULL;
3008   PyObject *__pyx_t_3 = NULL;
3009   int __pyx_t_4;
3010   PyObject *__pyx_t_5 = NULL;
3011   PyObject *__pyx_t_6 = NULL;
3012   int __pyx_lineno = 0;
3013   const char *__pyx_filename = NULL;
3014   int __pyx_clineno = 0;
3015   __Pyx_RefNannySetupContext("solve_2d_symmetric_positive_definite", 0);
3016 
3017   /* "dipy/align/sumsqdiff.pyx":62
3018  *     """
3019  *     cdef:
3020  *         cnp.ndarray out = np.zeros(2, dtype=float)             # <<<<<<<<<<<<<<
3021  *
3022  *     _solve_2d_symmetric_positive_definite(
3023  */
3024   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
3025   __Pyx_GOTREF(__pyx_t_1);
3026   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
3027   __Pyx_GOTREF(__pyx_t_2);
3028   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3029   __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
3030   __Pyx_GOTREF(__pyx_t_1);
3031   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 62, __pyx_L1_error)
3032   __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple_, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 62, __pyx_L1_error)
3033   __Pyx_GOTREF(__pyx_t_3);
3034   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3035   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3036   if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 62, __pyx_L1_error)
3037   __pyx_v_out = ((PyArrayObject *)__pyx_t_3);
3038   __pyx_t_3 = 0;
3039 
3040   /* "dipy/align/sumsqdiff.pyx":65
3041  *
3042  *     _solve_2d_symmetric_positive_definite(
3043  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(A, float)),             # <<<<<<<<<<<<<<
3044  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(y, float)),
3045  *         det,
3046  */
3047   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
3048   __Pyx_GOTREF(__pyx_t_1);
3049   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
3050   __Pyx_GOTREF(__pyx_t_2);
3051   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3052   __pyx_t_1 = NULL;
3053   __pyx_t_4 = 0;
3054   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
3055     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
3056     if (likely(__pyx_t_1)) {
3057       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3058       __Pyx_INCREF(__pyx_t_1);
3059       __Pyx_INCREF(function);
3060       __Pyx_DECREF_SET(__pyx_t_2, function);
3061       __pyx_t_4 = 1;
3062     }
3063   }
3064   #if CYTHON_FAST_PYCALL
3065   if (PyFunction_Check(__pyx_t_2)) {
3066     PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_A, ((PyObject *)(&PyFloat_Type))};
3067     __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error)
3068     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3069     __Pyx_GOTREF(__pyx_t_3);
3070   } else
3071   #endif
3072   #if CYTHON_FAST_PYCCALL
3073   if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
3074     PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_A, ((PyObject *)(&PyFloat_Type))};
3075     __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error)
3076     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3077     __Pyx_GOTREF(__pyx_t_3);
3078   } else
3079   #endif
3080   {
3081     __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 65, __pyx_L1_error)
3082     __Pyx_GOTREF(__pyx_t_5);
3083     if (__pyx_t_1) {
3084       __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
3085     }
3086     __Pyx_INCREF(__pyx_v_A);
3087     __Pyx_GIVEREF(__pyx_v_A);
3088     PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_A);
3089     __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
3090     __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
3091     PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, ((PyObject *)(&PyFloat_Type)));
3092     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error)
3093     __Pyx_GOTREF(__pyx_t_3);
3094     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3095   }
3096   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3097   if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 65, __pyx_L1_error)
3098 
3099   /* "dipy/align/sumsqdiff.pyx":66
3100  *     _solve_2d_symmetric_positive_definite(
3101  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(A, float)),
3102  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(y, float)),             # <<<<<<<<<<<<<<
3103  *         det,
3104  *         <double*> cnp.PyArray_DATA(out))
3105  */
3106   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 66, __pyx_L1_error)
3107   __Pyx_GOTREF(__pyx_t_5);
3108   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
3109   __Pyx_GOTREF(__pyx_t_1);
3110   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3111   __pyx_t_5 = NULL;
3112   __pyx_t_4 = 0;
3113   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
3114     __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
3115     if (likely(__pyx_t_5)) {
3116       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3117       __Pyx_INCREF(__pyx_t_5);
3118       __Pyx_INCREF(function);
3119       __Pyx_DECREF_SET(__pyx_t_1, function);
3120       __pyx_t_4 = 1;
3121     }
3122   }
3123   #if CYTHON_FAST_PYCALL
3124   if (PyFunction_Check(__pyx_t_1)) {
3125     PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_y, ((PyObject *)(&PyFloat_Type))};
3126     __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
3127     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3128     __Pyx_GOTREF(__pyx_t_2);
3129   } else
3130   #endif
3131   #if CYTHON_FAST_PYCCALL
3132   if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
3133     PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_y, ((PyObject *)(&PyFloat_Type))};
3134     __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
3135     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3136     __Pyx_GOTREF(__pyx_t_2);
3137   } else
3138   #endif
3139   {
3140     __pyx_t_6 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 66, __pyx_L1_error)
3141     __Pyx_GOTREF(__pyx_t_6);
3142     if (__pyx_t_5) {
3143       __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
3144     }
3145     __Pyx_INCREF(__pyx_v_y);
3146     __Pyx_GIVEREF(__pyx_v_y);
3147     PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_4, __pyx_v_y);
3148     __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
3149     __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
3150     PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_4, ((PyObject *)(&PyFloat_Type)));
3151     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
3152     __Pyx_GOTREF(__pyx_t_2);
3153     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3154   }
3155   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3156   if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 66, __pyx_L1_error)
3157 
3158   /* "dipy/align/sumsqdiff.pyx":64
3159  *         cnp.ndarray out = np.zeros(2, dtype=float)
3160  *
3161  *     _solve_2d_symmetric_positive_definite(             # <<<<<<<<<<<<<<
3162  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(A, float)),
3163  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(y, float)),
3164  */
3165   __pyx_f_4dipy_5align_9sumsqdiff__solve_2d_symmetric_positive_definite(((double *)PyArray_DATA(((PyArrayObject *)__pyx_t_3))), ((double *)PyArray_DATA(((PyArrayObject *)__pyx_t_2))), __pyx_v_det, ((double *)PyArray_DATA(__pyx_v_out)));
3166   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3167   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3168 
3169   /* "dipy/align/sumsqdiff.pyx":69
3170  *         det,
3171  *         <double*> cnp.PyArray_DATA(out))
3172  *     return np.asarray(out)             # <<<<<<<<<<<<<<
3173  *
3174  *
3175  */
3176   __Pyx_XDECREF(__pyx_r);
3177   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 69, __pyx_L1_error)
3178   __Pyx_GOTREF(__pyx_t_3);
3179   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
3180   __Pyx_GOTREF(__pyx_t_1);
3181   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3182   __pyx_t_3 = NULL;
3183   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
3184     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
3185     if (likely(__pyx_t_3)) {
3186       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3187       __Pyx_INCREF(__pyx_t_3);
3188       __Pyx_INCREF(function);
3189       __Pyx_DECREF_SET(__pyx_t_1, function);
3190     }
3191   }
3192   __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, ((PyObject *)__pyx_v_out)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_out));
3193   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3194   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
3195   __Pyx_GOTREF(__pyx_t_2);
3196   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3197   __pyx_r = __pyx_t_2;
3198   __pyx_t_2 = 0;
3199   goto __pyx_L0;
3200 
3201   /* "dipy/align/sumsqdiff.pyx":41
3202  *
3203  *
3204  * def solve_2d_symmetric_positive_definite(A, y, double det):             # <<<<<<<<<<<<<<
3205  *     r"""Solves a 2-variable symmetric positive-definite linear system
3206  *
3207  */
3208 
3209   /* function exit code */
3210   __pyx_L1_error:;
3211   __Pyx_XDECREF(__pyx_t_1);
3212   __Pyx_XDECREF(__pyx_t_2);
3213   __Pyx_XDECREF(__pyx_t_3);
3214   __Pyx_XDECREF(__pyx_t_5);
3215   __Pyx_XDECREF(__pyx_t_6);
3216   __Pyx_AddTraceback("dipy.align.sumsqdiff.solve_2d_symmetric_positive_definite", __pyx_clineno, __pyx_lineno, __pyx_filename);
3217   __pyx_r = NULL;
3218   __pyx_L0:;
3219   __Pyx_XDECREF((PyObject *)__pyx_v_out);
3220   __Pyx_XGIVEREF(__pyx_r);
3221   __Pyx_RefNannyFinishContext();
3222   return __pyx_r;
3223 }
3224 
3225 /* "dipy/align/sumsqdiff.pyx":75
3226  * @cython.wraparound(False)
3227  * @cython.cdivision(True)
3228  * cdef int _solve_3d_symmetric_positive_definite(double* g,             # <<<<<<<<<<<<<<
3229  *                                                double* y,
3230  *                                                double tau,
3231  */
3232 
__pyx_f_4dipy_5align_9sumsqdiff__solve_3d_symmetric_positive_definite(double * __pyx_v_g,double * __pyx_v_y,double __pyx_v_tau,double * __pyx_v_out)3233 static int __pyx_f_4dipy_5align_9sumsqdiff__solve_3d_symmetric_positive_definite(double *__pyx_v_g, double *__pyx_v_y, double __pyx_v_tau, double *__pyx_v_out) {
3234   double __pyx_v_a;
3235   double __pyx_v_b;
3236   double __pyx_v_c;
3237   double __pyx_v_d;
3238   double __pyx_v_e;
3239   double __pyx_v_f;
3240   double __pyx_v_y0;
3241   double __pyx_v_y1;
3242   double __pyx_v_y2;
3243   double __pyx_v_sub_det;
3244   int __pyx_r;
3245   int __pyx_t_1;
3246 
3247   /* "dipy/align/sumsqdiff.pyx":105
3248  *     cdef:
3249  *         double a,b,c,d,e,f, y0, y1, y2, sub_det
3250  *     a = g[0] ** 2 + tau             # <<<<<<<<<<<<<<
3251  *     if a < 1e-9:
3252  *         return 1
3253  */
3254   __pyx_v_a = (pow((__pyx_v_g[0]), 2.0) + __pyx_v_tau);
3255 
3256   /* "dipy/align/sumsqdiff.pyx":106
3257  *         double a,b,c,d,e,f, y0, y1, y2, sub_det
3258  *     a = g[0] ** 2 + tau
3259  *     if a < 1e-9:             # <<<<<<<<<<<<<<
3260  *         return 1
3261  *     b = g[0] * g[1]
3262  */
3263   __pyx_t_1 = ((__pyx_v_a < 1e-9) != 0);
3264   if (__pyx_t_1) {
3265 
3266     /* "dipy/align/sumsqdiff.pyx":107
3267  *     a = g[0] ** 2 + tau
3268  *     if a < 1e-9:
3269  *         return 1             # <<<<<<<<<<<<<<
3270  *     b = g[0] * g[1]
3271  *     sub_det = (a * (g[1] ** 2 + tau) - b * b)
3272  */
3273     __pyx_r = 1;
3274     goto __pyx_L0;
3275 
3276     /* "dipy/align/sumsqdiff.pyx":106
3277  *         double a,b,c,d,e,f, y0, y1, y2, sub_det
3278  *     a = g[0] ** 2 + tau
3279  *     if a < 1e-9:             # <<<<<<<<<<<<<<
3280  *         return 1
3281  *     b = g[0] * g[1]
3282  */
3283   }
3284 
3285   /* "dipy/align/sumsqdiff.pyx":108
3286  *     if a < 1e-9:
3287  *         return 1
3288  *     b = g[0] * g[1]             # <<<<<<<<<<<<<<
3289  *     sub_det = (a * (g[1] ** 2 + tau) - b * b)
3290  *     if sub_det < 1e-9:
3291  */
3292   __pyx_v_b = ((__pyx_v_g[0]) * (__pyx_v_g[1]));
3293 
3294   /* "dipy/align/sumsqdiff.pyx":109
3295  *         return 1
3296  *     b = g[0] * g[1]
3297  *     sub_det = (a * (g[1] ** 2 + tau) - b * b)             # <<<<<<<<<<<<<<
3298  *     if sub_det < 1e-9:
3299  *         return 1
3300  */
3301   __pyx_v_sub_det = ((__pyx_v_a * (pow((__pyx_v_g[1]), 2.0) + __pyx_v_tau)) - (__pyx_v_b * __pyx_v_b));
3302 
3303   /* "dipy/align/sumsqdiff.pyx":110
3304  *     b = g[0] * g[1]
3305  *     sub_det = (a * (g[1] ** 2 + tau) - b * b)
3306  *     if sub_det < 1e-9:             # <<<<<<<<<<<<<<
3307  *         return 1
3308  *     c = g[0] * g[2]
3309  */
3310   __pyx_t_1 = ((__pyx_v_sub_det < 1e-9) != 0);
3311   if (__pyx_t_1) {
3312 
3313     /* "dipy/align/sumsqdiff.pyx":111
3314  *     sub_det = (a * (g[1] ** 2 + tau) - b * b)
3315  *     if sub_det < 1e-9:
3316  *         return 1             # <<<<<<<<<<<<<<
3317  *     c = g[0] * g[2]
3318  *     d = (a * (g[1] ** 2 + tau) - b * b) / a
3319  */
3320     __pyx_r = 1;
3321     goto __pyx_L0;
3322 
3323     /* "dipy/align/sumsqdiff.pyx":110
3324  *     b = g[0] * g[1]
3325  *     sub_det = (a * (g[1] ** 2 + tau) - b * b)
3326  *     if sub_det < 1e-9:             # <<<<<<<<<<<<<<
3327  *         return 1
3328  *     c = g[0] * g[2]
3329  */
3330   }
3331 
3332   /* "dipy/align/sumsqdiff.pyx":112
3333  *     if sub_det < 1e-9:
3334  *         return 1
3335  *     c = g[0] * g[2]             # <<<<<<<<<<<<<<
3336  *     d = (a * (g[1] ** 2 + tau) - b * b) / a
3337  *     e = (a * (g[1] * g[2]) - b * c) / a
3338  */
3339   __pyx_v_c = ((__pyx_v_g[0]) * (__pyx_v_g[2]));
3340 
3341   /* "dipy/align/sumsqdiff.pyx":113
3342  *         return 1
3343  *     c = g[0] * g[2]
3344  *     d = (a * (g[1] ** 2 + tau) - b * b) / a             # <<<<<<<<<<<<<<
3345  *     e = (a * (g[1] * g[2]) - b * c) / a
3346  *     f = (a * (g[2] ** 2 + tau) - c * c) / a - (e * e * a) / sub_det
3347  */
3348   __pyx_v_d = (((__pyx_v_a * (pow((__pyx_v_g[1]), 2.0) + __pyx_v_tau)) - (__pyx_v_b * __pyx_v_b)) / __pyx_v_a);
3349 
3350   /* "dipy/align/sumsqdiff.pyx":114
3351  *     c = g[0] * g[2]
3352  *     d = (a * (g[1] ** 2 + tau) - b * b) / a
3353  *     e = (a * (g[1] * g[2]) - b * c) / a             # <<<<<<<<<<<<<<
3354  *     f = (a * (g[2] ** 2 + tau) - c * c) / a - (e * e * a) / sub_det
3355  *     if f < 1e-9:
3356  */
3357   __pyx_v_e = (((__pyx_v_a * ((__pyx_v_g[1]) * (__pyx_v_g[2]))) - (__pyx_v_b * __pyx_v_c)) / __pyx_v_a);
3358 
3359   /* "dipy/align/sumsqdiff.pyx":115
3360  *     d = (a * (g[1] ** 2 + tau) - b * b) / a
3361  *     e = (a * (g[1] * g[2]) - b * c) / a
3362  *     f = (a * (g[2] ** 2 + tau) - c * c) / a - (e * e * a) / sub_det             # <<<<<<<<<<<<<<
3363  *     if f < 1e-9:
3364  *         return 1
3365  */
3366   __pyx_v_f = ((((__pyx_v_a * (pow((__pyx_v_g[2]), 2.0) + __pyx_v_tau)) - (__pyx_v_c * __pyx_v_c)) / __pyx_v_a) - (((__pyx_v_e * __pyx_v_e) * __pyx_v_a) / __pyx_v_sub_det));
3367 
3368   /* "dipy/align/sumsqdiff.pyx":116
3369  *     e = (a * (g[1] * g[2]) - b * c) / a
3370  *     f = (a * (g[2] ** 2 + tau) - c * c) / a - (e * e * a) / sub_det
3371  *     if f < 1e-9:             # <<<<<<<<<<<<<<
3372  *         return 1
3373  *     y0 = y[0]
3374  */
3375   __pyx_t_1 = ((__pyx_v_f < 1e-9) != 0);
3376   if (__pyx_t_1) {
3377 
3378     /* "dipy/align/sumsqdiff.pyx":117
3379  *     f = (a * (g[2] ** 2 + tau) - c * c) / a - (e * e * a) / sub_det
3380  *     if f < 1e-9:
3381  *         return 1             # <<<<<<<<<<<<<<
3382  *     y0 = y[0]
3383  *     y1 = (y[1] * a - y0 * b) / a
3384  */
3385     __pyx_r = 1;
3386     goto __pyx_L0;
3387 
3388     /* "dipy/align/sumsqdiff.pyx":116
3389  *     e = (a * (g[1] * g[2]) - b * c) / a
3390  *     f = (a * (g[2] ** 2 + tau) - c * c) / a - (e * e * a) / sub_det
3391  *     if f < 1e-9:             # <<<<<<<<<<<<<<
3392  *         return 1
3393  *     y0 = y[0]
3394  */
3395   }
3396 
3397   /* "dipy/align/sumsqdiff.pyx":118
3398  *     if f < 1e-9:
3399  *         return 1
3400  *     y0 = y[0]             # <<<<<<<<<<<<<<
3401  *     y1 = (y[1] * a - y0 * b) / a
3402  *     y2 = (y[2] * a - c * y0) / a - (e * (y[1] * a - b * y0)) / sub_det
3403  */
3404   __pyx_v_y0 = (__pyx_v_y[0]);
3405 
3406   /* "dipy/align/sumsqdiff.pyx":119
3407  *         return 1
3408  *     y0 = y[0]
3409  *     y1 = (y[1] * a - y0 * b) / a             # <<<<<<<<<<<<<<
3410  *     y2 = (y[2] * a - c * y0) / a - (e * (y[1] * a - b * y0)) / sub_det
3411  *     out[2] = y2 / f
3412  */
3413   __pyx_v_y1 = ((((__pyx_v_y[1]) * __pyx_v_a) - (__pyx_v_y0 * __pyx_v_b)) / __pyx_v_a);
3414 
3415   /* "dipy/align/sumsqdiff.pyx":120
3416  *     y0 = y[0]
3417  *     y1 = (y[1] * a - y0 * b) / a
3418  *     y2 = (y[2] * a - c * y0) / a - (e * (y[1] * a - b * y0)) / sub_det             # <<<<<<<<<<<<<<
3419  *     out[2] = y2 / f
3420  *     out[1] = (y1 - e * out[2]) / d
3421  */
3422   __pyx_v_y2 = (((((__pyx_v_y[2]) * __pyx_v_a) - (__pyx_v_c * __pyx_v_y0)) / __pyx_v_a) - ((__pyx_v_e * (((__pyx_v_y[1]) * __pyx_v_a) - (__pyx_v_b * __pyx_v_y0))) / __pyx_v_sub_det));
3423 
3424   /* "dipy/align/sumsqdiff.pyx":121
3425  *     y1 = (y[1] * a - y0 * b) / a
3426  *     y2 = (y[2] * a - c * y0) / a - (e * (y[1] * a - b * y0)) / sub_det
3427  *     out[2] = y2 / f             # <<<<<<<<<<<<<<
3428  *     out[1] = (y1 - e * out[2]) / d
3429  *     out[0] = (y0 - b * out[1] - c * out[2]) / a
3430  */
3431   (__pyx_v_out[2]) = (__pyx_v_y2 / __pyx_v_f);
3432 
3433   /* "dipy/align/sumsqdiff.pyx":122
3434  *     y2 = (y[2] * a - c * y0) / a - (e * (y[1] * a - b * y0)) / sub_det
3435  *     out[2] = y2 / f
3436  *     out[1] = (y1 - e * out[2]) / d             # <<<<<<<<<<<<<<
3437  *     out[0] = (y0 - b * out[1] - c * out[2]) / a
3438  *     return 0
3439  */
3440   (__pyx_v_out[1]) = ((__pyx_v_y1 - (__pyx_v_e * (__pyx_v_out[2]))) / __pyx_v_d);
3441 
3442   /* "dipy/align/sumsqdiff.pyx":123
3443  *     out[2] = y2 / f
3444  *     out[1] = (y1 - e * out[2]) / d
3445  *     out[0] = (y0 - b * out[1] - c * out[2]) / a             # <<<<<<<<<<<<<<
3446  *     return 0
3447  *
3448  */
3449   (__pyx_v_out[0]) = (((__pyx_v_y0 - (__pyx_v_b * (__pyx_v_out[1]))) - (__pyx_v_c * (__pyx_v_out[2]))) / __pyx_v_a);
3450 
3451   /* "dipy/align/sumsqdiff.pyx":124
3452  *     out[1] = (y1 - e * out[2]) / d
3453  *     out[0] = (y0 - b * out[1] - c * out[2]) / a
3454  *     return 0             # <<<<<<<<<<<<<<
3455  *
3456  *
3457  */
3458   __pyx_r = 0;
3459   goto __pyx_L0;
3460 
3461   /* "dipy/align/sumsqdiff.pyx":75
3462  * @cython.wraparound(False)
3463  * @cython.cdivision(True)
3464  * cdef int _solve_3d_symmetric_positive_definite(double* g,             # <<<<<<<<<<<<<<
3465  *                                                double* y,
3466  *                                                double tau,
3467  */
3468 
3469   /* function exit code */
3470   __pyx_L0:;
3471   return __pyx_r;
3472 }
3473 
3474 /* "dipy/align/sumsqdiff.pyx":127
3475  *
3476  *
3477  * def solve_3d_symmetric_positive_definite(g, y, double tau):             # <<<<<<<<<<<<<<
3478  *     r"""Solves a 3-variable symmetric positive-definite linear system
3479  *
3480  */
3481 
3482 /* Python wrapper */
3483 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_3solve_3d_symmetric_positive_definite(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3484 static char __pyx_doc_4dipy_5align_9sumsqdiff_2solve_3d_symmetric_positive_definite[] = "Solves a 3-variable symmetric positive-definite linear system\n\n    Solves the symmetric semi-positive-definite linear system $Mx = y$ given by\n    $M = (g g^{T} + \\tau I)$.\n\n    Parameters\n    ----------\n    g : array, shape (3,)\n        the vector in the outer product above\n    y : array, shape (3,)\n        right-hand side of the system to be solved\n    tau : double\n        $\\tau$ in $M = (g g^{T} + \\tau I)$\n\n    Returns\n    -------\n    out : array, shape (3,)\n        the array the output will be stored in\n    is_singular : int\n        1 if M is singular, otherwise 0\n    ";
3485 static PyMethodDef __pyx_mdef_4dipy_5align_9sumsqdiff_3solve_3d_symmetric_positive_definite = {"solve_3d_symmetric_positive_definite", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_3solve_3d_symmetric_positive_definite, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_2solve_3d_symmetric_positive_definite};
__pyx_pw_4dipy_5align_9sumsqdiff_3solve_3d_symmetric_positive_definite(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3486 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_3solve_3d_symmetric_positive_definite(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3487   PyObject *__pyx_v_g = 0;
3488   PyObject *__pyx_v_y = 0;
3489   double __pyx_v_tau;
3490   int __pyx_lineno = 0;
3491   const char *__pyx_filename = NULL;
3492   int __pyx_clineno = 0;
3493   PyObject *__pyx_r = 0;
3494   __Pyx_RefNannyDeclarations
3495   __Pyx_RefNannySetupContext("solve_3d_symmetric_positive_definite (wrapper)", 0);
3496   {
3497     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_g,&__pyx_n_s_y,&__pyx_n_s_tau,0};
3498     PyObject* values[3] = {0,0,0};
3499     if (unlikely(__pyx_kwds)) {
3500       Py_ssize_t kw_args;
3501       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3502       switch (pos_args) {
3503         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3504         CYTHON_FALLTHROUGH;
3505         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3506         CYTHON_FALLTHROUGH;
3507         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3508         CYTHON_FALLTHROUGH;
3509         case  0: break;
3510         default: goto __pyx_L5_argtuple_error;
3511       }
3512       kw_args = PyDict_Size(__pyx_kwds);
3513       switch (pos_args) {
3514         case  0:
3515         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_g)) != 0)) kw_args--;
3516         else goto __pyx_L5_argtuple_error;
3517         CYTHON_FALLTHROUGH;
3518         case  1:
3519         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
3520         else {
3521           __Pyx_RaiseArgtupleInvalid("solve_3d_symmetric_positive_definite", 1, 3, 3, 1); __PYX_ERR(0, 127, __pyx_L3_error)
3522         }
3523         CYTHON_FALLTHROUGH;
3524         case  2:
3525         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tau)) != 0)) kw_args--;
3526         else {
3527           __Pyx_RaiseArgtupleInvalid("solve_3d_symmetric_positive_definite", 1, 3, 3, 2); __PYX_ERR(0, 127, __pyx_L3_error)
3528         }
3529       }
3530       if (unlikely(kw_args > 0)) {
3531         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "solve_3d_symmetric_positive_definite") < 0)) __PYX_ERR(0, 127, __pyx_L3_error)
3532       }
3533     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
3534       goto __pyx_L5_argtuple_error;
3535     } else {
3536       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3537       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3538       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3539     }
3540     __pyx_v_g = values[0];
3541     __pyx_v_y = values[1];
3542     __pyx_v_tau = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_tau == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L3_error)
3543   }
3544   goto __pyx_L4_argument_unpacking_done;
3545   __pyx_L5_argtuple_error:;
3546   __Pyx_RaiseArgtupleInvalid("solve_3d_symmetric_positive_definite", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 127, __pyx_L3_error)
3547   __pyx_L3_error:;
3548   __Pyx_AddTraceback("dipy.align.sumsqdiff.solve_3d_symmetric_positive_definite", __pyx_clineno, __pyx_lineno, __pyx_filename);
3549   __Pyx_RefNannyFinishContext();
3550   return NULL;
3551   __pyx_L4_argument_unpacking_done:;
3552   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_2solve_3d_symmetric_positive_definite(__pyx_self, __pyx_v_g, __pyx_v_y, __pyx_v_tau);
3553 
3554   /* function exit code */
3555   __Pyx_RefNannyFinishContext();
3556   return __pyx_r;
3557 }
3558 
__pyx_pf_4dipy_5align_9sumsqdiff_2solve_3d_symmetric_positive_definite(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_g,PyObject * __pyx_v_y,double __pyx_v_tau)3559 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_2solve_3d_symmetric_positive_definite(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_g, PyObject *__pyx_v_y, double __pyx_v_tau) {
3560   PyArrayObject *__pyx_v_out = 0;
3561   int __pyx_v_is_singular;
3562   PyObject *__pyx_r = NULL;
3563   __Pyx_RefNannyDeclarations
3564   PyObject *__pyx_t_1 = NULL;
3565   PyObject *__pyx_t_2 = NULL;
3566   PyObject *__pyx_t_3 = NULL;
3567   int __pyx_t_4;
3568   PyObject *__pyx_t_5 = NULL;
3569   PyObject *__pyx_t_6 = NULL;
3570   int __pyx_lineno = 0;
3571   const char *__pyx_filename = NULL;
3572   int __pyx_clineno = 0;
3573   __Pyx_RefNannySetupContext("solve_3d_symmetric_positive_definite", 0);
3574 
3575   /* "dipy/align/sumsqdiff.pyx":150
3576  *     """
3577  *     cdef:
3578  *         cnp.ndarray out = np.zeros(3, dtype=float)             # <<<<<<<<<<<<<<
3579  *         int is_singular
3580  *     is_singular = _solve_3d_symmetric_positive_definite(
3581  */
3582   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error)
3583   __Pyx_GOTREF(__pyx_t_1);
3584   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
3585   __Pyx_GOTREF(__pyx_t_2);
3586   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3587   __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error)
3588   __Pyx_GOTREF(__pyx_t_1);
3589   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 150, __pyx_L1_error)
3590   __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 150, __pyx_L1_error)
3591   __Pyx_GOTREF(__pyx_t_3);
3592   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3593   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3594   if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 150, __pyx_L1_error)
3595   __pyx_v_out = ((PyArrayObject *)__pyx_t_3);
3596   __pyx_t_3 = 0;
3597 
3598   /* "dipy/align/sumsqdiff.pyx":153
3599  *         int is_singular
3600  *     is_singular = _solve_3d_symmetric_positive_definite(
3601  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(g, float)),             # <<<<<<<<<<<<<<
3602  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(y, float)),
3603  *         tau,
3604  */
3605   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
3606   __Pyx_GOTREF(__pyx_t_1);
3607   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error)
3608   __Pyx_GOTREF(__pyx_t_2);
3609   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3610   __pyx_t_1 = NULL;
3611   __pyx_t_4 = 0;
3612   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
3613     __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
3614     if (likely(__pyx_t_1)) {
3615       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3616       __Pyx_INCREF(__pyx_t_1);
3617       __Pyx_INCREF(function);
3618       __Pyx_DECREF_SET(__pyx_t_2, function);
3619       __pyx_t_4 = 1;
3620     }
3621   }
3622   #if CYTHON_FAST_PYCALL
3623   if (PyFunction_Check(__pyx_t_2)) {
3624     PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_g, ((PyObject *)(&PyFloat_Type))};
3625     __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error)
3626     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3627     __Pyx_GOTREF(__pyx_t_3);
3628   } else
3629   #endif
3630   #if CYTHON_FAST_PYCCALL
3631   if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
3632     PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_g, ((PyObject *)(&PyFloat_Type))};
3633     __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error)
3634     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3635     __Pyx_GOTREF(__pyx_t_3);
3636   } else
3637   #endif
3638   {
3639     __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 153, __pyx_L1_error)
3640     __Pyx_GOTREF(__pyx_t_5);
3641     if (__pyx_t_1) {
3642       __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
3643     }
3644     __Pyx_INCREF(__pyx_v_g);
3645     __Pyx_GIVEREF(__pyx_v_g);
3646     PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_g);
3647     __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
3648     __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
3649     PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, ((PyObject *)(&PyFloat_Type)));
3650     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error)
3651     __Pyx_GOTREF(__pyx_t_3);
3652     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3653   }
3654   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3655   if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 153, __pyx_L1_error)
3656 
3657   /* "dipy/align/sumsqdiff.pyx":154
3658  *     is_singular = _solve_3d_symmetric_positive_definite(
3659  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(g, float)),
3660  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(y, float)),             # <<<<<<<<<<<<<<
3661  *         tau,
3662  *         <double*> cnp.PyArray_DATA(out))
3663  */
3664   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 154, __pyx_L1_error)
3665   __Pyx_GOTREF(__pyx_t_5);
3666   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error)
3667   __Pyx_GOTREF(__pyx_t_1);
3668   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3669   __pyx_t_5 = NULL;
3670   __pyx_t_4 = 0;
3671   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
3672     __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
3673     if (likely(__pyx_t_5)) {
3674       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3675       __Pyx_INCREF(__pyx_t_5);
3676       __Pyx_INCREF(function);
3677       __Pyx_DECREF_SET(__pyx_t_1, function);
3678       __pyx_t_4 = 1;
3679     }
3680   }
3681   #if CYTHON_FAST_PYCALL
3682   if (PyFunction_Check(__pyx_t_1)) {
3683     PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_y, ((PyObject *)(&PyFloat_Type))};
3684     __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 154, __pyx_L1_error)
3685     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3686     __Pyx_GOTREF(__pyx_t_2);
3687   } else
3688   #endif
3689   #if CYTHON_FAST_PYCCALL
3690   if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
3691     PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_y, ((PyObject *)(&PyFloat_Type))};
3692     __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 154, __pyx_L1_error)
3693     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3694     __Pyx_GOTREF(__pyx_t_2);
3695   } else
3696   #endif
3697   {
3698     __pyx_t_6 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 154, __pyx_L1_error)
3699     __Pyx_GOTREF(__pyx_t_6);
3700     if (__pyx_t_5) {
3701       __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
3702     }
3703     __Pyx_INCREF(__pyx_v_y);
3704     __Pyx_GIVEREF(__pyx_v_y);
3705     PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_4, __pyx_v_y);
3706     __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
3707     __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
3708     PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_4, ((PyObject *)(&PyFloat_Type)));
3709     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 154, __pyx_L1_error)
3710     __Pyx_GOTREF(__pyx_t_2);
3711     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3712   }
3713   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3714   if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 154, __pyx_L1_error)
3715 
3716   /* "dipy/align/sumsqdiff.pyx":152
3717  *         cnp.ndarray out = np.zeros(3, dtype=float)
3718  *         int is_singular
3719  *     is_singular = _solve_3d_symmetric_positive_definite(             # <<<<<<<<<<<<<<
3720  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(g, float)),
3721  *         <double*> cnp.PyArray_DATA(np.ascontiguousarray(y, float)),
3722  */
3723   __pyx_v_is_singular = __pyx_f_4dipy_5align_9sumsqdiff__solve_3d_symmetric_positive_definite(((double *)PyArray_DATA(((PyArrayObject *)__pyx_t_3))), ((double *)PyArray_DATA(((PyArrayObject *)__pyx_t_2))), __pyx_v_tau, ((double *)PyArray_DATA(__pyx_v_out)));
3724   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3725   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3726 
3727   /* "dipy/align/sumsqdiff.pyx":157
3728  *         tau,
3729  *         <double*> cnp.PyArray_DATA(out))
3730  *     return np.asarray(out), is_singular             # <<<<<<<<<<<<<<
3731  *
3732  *
3733  */
3734   __Pyx_XDECREF(__pyx_r);
3735   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error)
3736   __Pyx_GOTREF(__pyx_t_3);
3737   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
3738   __Pyx_GOTREF(__pyx_t_1);
3739   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3740   __pyx_t_3 = NULL;
3741   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
3742     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
3743     if (likely(__pyx_t_3)) {
3744       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3745       __Pyx_INCREF(__pyx_t_3);
3746       __Pyx_INCREF(function);
3747       __Pyx_DECREF_SET(__pyx_t_1, function);
3748     }
3749   }
3750   __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, ((PyObject *)__pyx_v_out)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_out));
3751   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3752   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error)
3753   __Pyx_GOTREF(__pyx_t_2);
3754   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3755   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_is_singular); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
3756   __Pyx_GOTREF(__pyx_t_1);
3757   __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 157, __pyx_L1_error)
3758   __Pyx_GOTREF(__pyx_t_3);
3759   __Pyx_GIVEREF(__pyx_t_2);
3760   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
3761   __Pyx_GIVEREF(__pyx_t_1);
3762   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
3763   __pyx_t_2 = 0;
3764   __pyx_t_1 = 0;
3765   __pyx_r = __pyx_t_3;
3766   __pyx_t_3 = 0;
3767   goto __pyx_L0;
3768 
3769   /* "dipy/align/sumsqdiff.pyx":127
3770  *
3771  *
3772  * def solve_3d_symmetric_positive_definite(g, y, double tau):             # <<<<<<<<<<<<<<
3773  *     r"""Solves a 3-variable symmetric positive-definite linear system
3774  *
3775  */
3776 
3777   /* function exit code */
3778   __pyx_L1_error:;
3779   __Pyx_XDECREF(__pyx_t_1);
3780   __Pyx_XDECREF(__pyx_t_2);
3781   __Pyx_XDECREF(__pyx_t_3);
3782   __Pyx_XDECREF(__pyx_t_5);
3783   __Pyx_XDECREF(__pyx_t_6);
3784   __Pyx_AddTraceback("dipy.align.sumsqdiff.solve_3d_symmetric_positive_definite", __pyx_clineno, __pyx_lineno, __pyx_filename);
3785   __pyx_r = NULL;
3786   __pyx_L0:;
3787   __Pyx_XDECREF((PyObject *)__pyx_v_out);
3788   __Pyx_XGIVEREF(__pyx_r);
3789   __Pyx_RefNannyFinishContext();
3790   return __pyx_r;
3791 }
3792 
3793 /* "dipy/align/sumsqdiff.pyx":163
3794  * @cython.wraparound(False)
3795  * @cython.cdivision(True)
3796  * cpdef double iterate_residual_displacement_field_ssd_2d(             # <<<<<<<<<<<<<<
3797  *                 floating[:, :] delta_field, floating[:, :] sigmasq_field,
3798  *                 floating[:, :, :] grad, floating[:, :, :] target,
3799  */
3800 
3801 /* Python wrapper */
3802 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_5iterate_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3803 static char __pyx_doc_4dipy_5align_9sumsqdiff_4iterate_residual_displacement_field_ssd_2d[] = "One iteration of a large linear system solver for 2D SSD registration\n\n    Performs one iteration at one level of the Multi-resolution Gauss-Seidel\n    solver proposed by Bruhn and Weickert [Bruhn05].\n\n    Parameters\n    ----------\n    delta_field : array, shape (R, C)\n        the difference between the static and moving image (the 'derivative\n        w.r.t. time' in the optical flow model)\n    sigmasq_field : array, shape (R, C)\n        the variance of the gray level value at each voxel, according to the\n        EM model (for SSD, it is 1 for all voxels). Inf and 0 values\n        are processed specially to support infinite and zero variance.\n    grad : array, shape (R, C, 2)\n        the gradient of the moving image\n    target : array, shape (R, C, 2)\n        right-hand side of the linear system to be solved in the Weickert's\n        multi-resolution algorithm\n    lambda_param : float\n        smoothness parameter of the objective function\n    displacement_field : array, shape (R, C, 2)\n        current displacement field to start the iteration from\n\n    Returns\n    -------\n    max_displacement : float\n        the norm of the maximum change in the displacement field after the\n        iteration\n\n    References\n    ----------\n    [Bruhn05] Andres Bruhn and Joachim Weickert, \"Towards ultimate motion\n              estimation: combining highest accuracy with real-time\n              performance\", 10th IEEE International Conference on Computer\n              Vision, 2005. ICCV 2005.\n    ";
3804 static PyMethodDef __pyx_mdef_4dipy_5align_9sumsqdiff_5iterate_residual_displacement_field_ssd_2d = {"iterate_residual_displacement_field_ssd_2d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_5iterate_residual_displacement_field_ssd_2d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_4iterate_residual_displacement_field_ssd_2d};
__pyx_pw_4dipy_5align_9sumsqdiff_5iterate_residual_displacement_field_ssd_2d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3805 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_5iterate_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3806   PyObject *__pyx_v_signatures = 0;
3807   PyObject *__pyx_v_args = 0;
3808   PyObject *__pyx_v_kwargs = 0;
3809   CYTHON_UNUSED PyObject *__pyx_v_defaults = 0;
3810   int __pyx_lineno = 0;
3811   const char *__pyx_filename = NULL;
3812   int __pyx_clineno = 0;
3813   PyObject *__pyx_r = 0;
3814   __Pyx_RefNannyDeclarations
3815   __Pyx_RefNannySetupContext("__pyx_fused_cpdef (wrapper)", 0);
3816   {
3817     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signatures,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_defaults,0};
3818     PyObject* values[4] = {0,0,0,0};
3819     if (unlikely(__pyx_kwds)) {
3820       Py_ssize_t kw_args;
3821       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3822       switch (pos_args) {
3823         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3824         CYTHON_FALLTHROUGH;
3825         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3826         CYTHON_FALLTHROUGH;
3827         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3828         CYTHON_FALLTHROUGH;
3829         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3830         CYTHON_FALLTHROUGH;
3831         case  0: break;
3832         default: goto __pyx_L5_argtuple_error;
3833       }
3834       kw_args = PyDict_Size(__pyx_kwds);
3835       switch (pos_args) {
3836         case  0:
3837         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signatures)) != 0)) kw_args--;
3838         else goto __pyx_L5_argtuple_error;
3839         CYTHON_FALLTHROUGH;
3840         case  1:
3841         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
3842         else {
3843           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 1); __PYX_ERR(0, 163, __pyx_L3_error)
3844         }
3845         CYTHON_FALLTHROUGH;
3846         case  2:
3847         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
3848         else {
3849           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); __PYX_ERR(0, 163, __pyx_L3_error)
3850         }
3851         CYTHON_FALLTHROUGH;
3852         case  3:
3853         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--;
3854         else {
3855           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); __PYX_ERR(0, 163, __pyx_L3_error)
3856         }
3857       }
3858       if (unlikely(kw_args > 0)) {
3859         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) __PYX_ERR(0, 163, __pyx_L3_error)
3860       }
3861     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
3862       goto __pyx_L5_argtuple_error;
3863     } else {
3864       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3865       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3866       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3867       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3868     }
3869     __pyx_v_signatures = values[0];
3870     __pyx_v_args = values[1];
3871     __pyx_v_kwargs = values[2];
3872     __pyx_v_defaults = values[3];
3873   }
3874   goto __pyx_L4_argument_unpacking_done;
3875   __pyx_L5_argtuple_error:;
3876   __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 163, __pyx_L3_error)
3877   __pyx_L3_error:;
3878   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
3879   __Pyx_RefNannyFinishContext();
3880   return NULL;
3881   __pyx_L4_argument_unpacking_done:;
3882   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_4iterate_residual_displacement_field_ssd_2d(__pyx_self, __pyx_v_signatures, __pyx_v_args, __pyx_v_kwargs, __pyx_v_defaults);
3883 
3884   /* function exit code */
3885   __Pyx_RefNannyFinishContext();
3886   return __pyx_r;
3887 }
3888 
__pyx_pf_4dipy_5align_9sumsqdiff_4iterate_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_signatures,PyObject * __pyx_v_args,PyObject * __pyx_v_kwargs,CYTHON_UNUSED PyObject * __pyx_v_defaults)3889 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_4iterate_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults) {
3890   PyObject *__pyx_v_dest_sig = NULL;
3891   Py_ssize_t __pyx_v_i;
3892   PyTypeObject *__pyx_v_ndarray = 0;
3893   __Pyx_memviewslice __pyx_v_memslice;
3894   Py_ssize_t __pyx_v_itemsize;
3895   CYTHON_UNUSED int __pyx_v_dtype_signed;
3896   char __pyx_v_kind;
3897   PyObject *__pyx_v_arg = NULL;
3898   PyObject *__pyx_v_dtype = NULL;
3899   PyObject *__pyx_v_arg_base = NULL;
3900   PyObject *__pyx_v_candidates = NULL;
3901   PyObject *__pyx_v_sig = NULL;
3902   int __pyx_v_match_found;
3903   PyObject *__pyx_v_src_sig = NULL;
3904   PyObject *__pyx_v_dst_type = NULL;
3905   PyObject *__pyx_r = NULL;
3906   __Pyx_RefNannyDeclarations
3907   PyObject *__pyx_t_1 = NULL;
3908   int __pyx_t_2;
3909   int __pyx_t_3;
3910   int __pyx_t_4;
3911   Py_ssize_t __pyx_t_5;
3912   PyObject *__pyx_t_6 = NULL;
3913   long __pyx_t_7;
3914   __Pyx_memviewslice __pyx_t_8;
3915   Py_ssize_t __pyx_t_9;
3916   int __pyx_t_10;
3917   int __pyx_t_11;
3918   PyObject *__pyx_t_12 = NULL;
3919   PyObject *__pyx_t_13 = NULL;
3920   PyObject *__pyx_t_14 = NULL;
3921   Py_ssize_t __pyx_t_15;
3922   Py_ssize_t __pyx_t_16;
3923   Py_ssize_t __pyx_t_17;
3924   int __pyx_t_18;
3925   int __pyx_lineno = 0;
3926   const char *__pyx_filename = NULL;
3927   int __pyx_clineno = 0;
3928   __Pyx_RefNannySetupContext("iterate_residual_displacement_field_ssd_2d", 0);
3929   __Pyx_INCREF(__pyx_v_kwargs);
3930   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
3931   __Pyx_GOTREF(__pyx_t_1);
3932   __Pyx_INCREF(Py_None);
3933   __Pyx_GIVEREF(Py_None);
3934   PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
3935   __pyx_v_dest_sig = ((PyObject*)__pyx_t_1);
3936   __pyx_t_1 = 0;
3937   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
3938   __pyx_t_4 = (__pyx_t_3 != 0);
3939   if (__pyx_t_4) {
3940   } else {
3941     __pyx_t_2 = __pyx_t_4;
3942     goto __pyx_L4_bool_binop_done;
3943   }
3944   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 163, __pyx_L1_error)
3945   __pyx_t_3 = ((!__pyx_t_4) != 0);
3946   __pyx_t_2 = __pyx_t_3;
3947   __pyx_L4_bool_binop_done:;
3948   if (__pyx_t_2) {
3949     __Pyx_INCREF(Py_None);
3950     __Pyx_DECREF_SET(__pyx_v_kwargs, Py_None);
3951   }
3952   __pyx_t_1 = ((PyObject *)__Pyx_ImportNumPyArrayTypeIfAvailable()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
3953   __Pyx_GOTREF(__pyx_t_1);
3954   __pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1);
3955   __pyx_t_1 = 0;
3956   __pyx_v_itemsize = -1L;
3957   if (unlikely(__pyx_v_args == Py_None)) {
3958     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
3959     __PYX_ERR(0, 163, __pyx_L1_error)
3960   }
3961   __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 163, __pyx_L1_error)
3962   __pyx_t_2 = ((0 < __pyx_t_5) != 0);
3963   if (__pyx_t_2) {
3964     if (unlikely(__pyx_v_args == Py_None)) {
3965       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
3966       __PYX_ERR(0, 163, __pyx_L1_error)
3967     }
3968     __pyx_t_1 = PyTuple_GET_ITEM(((PyObject*)__pyx_v_args), 0);
3969     __Pyx_INCREF(__pyx_t_1);
3970     __pyx_v_arg = __pyx_t_1;
3971     __pyx_t_1 = 0;
3972     goto __pyx_L6;
3973   }
3974   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
3975   __pyx_t_4 = (__pyx_t_3 != 0);
3976   if (__pyx_t_4) {
3977   } else {
3978     __pyx_t_2 = __pyx_t_4;
3979     goto __pyx_L7_bool_binop_done;
3980   }
3981   if (unlikely(__pyx_v_kwargs == Py_None)) {
3982     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
3983     __PYX_ERR(0, 163, __pyx_L1_error)
3984   }
3985   __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_delta_field, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 163, __pyx_L1_error)
3986   __pyx_t_3 = (__pyx_t_4 != 0);
3987   __pyx_t_2 = __pyx_t_3;
3988   __pyx_L7_bool_binop_done:;
3989   if (__pyx_t_2) {
3990     if (unlikely(__pyx_v_kwargs == Py_None)) {
3991       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
3992       __PYX_ERR(0, 163, __pyx_L1_error)
3993     }
3994     __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_delta_field); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
3995     __Pyx_GOTREF(__pyx_t_1);
3996     __pyx_v_arg = __pyx_t_1;
3997     __pyx_t_1 = 0;
3998     goto __pyx_L6;
3999   }
4000   /*else*/ {
4001     if (unlikely(__pyx_v_args == Py_None)) {
4002       PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
4003       __PYX_ERR(0, 163, __pyx_L1_error)
4004     }
4005     __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 163, __pyx_L1_error)
4006     __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
4007     __Pyx_GOTREF(__pyx_t_1);
4008     __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4009     __Pyx_GOTREF(__pyx_t_6);
4010     __Pyx_INCREF(__pyx_int_6);
4011     __Pyx_GIVEREF(__pyx_int_6);
4012     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_6);
4013     __Pyx_INCREF(__pyx_n_s_s);
4014     __Pyx_GIVEREF(__pyx_n_s_s);
4015     PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_s);
4016     __Pyx_GIVEREF(__pyx_t_1);
4017     PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
4018     __pyx_t_1 = 0;
4019     __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
4020     __Pyx_GOTREF(__pyx_t_1);
4021     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4022     __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4023     __Pyx_GOTREF(__pyx_t_6);
4024     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4025     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
4026     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4027     __PYX_ERR(0, 163, __pyx_L1_error)
4028   }
4029   __pyx_L6:;
4030   while (1) {
4031     __pyx_t_2 = (__pyx_v_ndarray != ((PyTypeObject*)Py_None));
4032     __pyx_t_3 = (__pyx_t_2 != 0);
4033     if (__pyx_t_3) {
4034       __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray);
4035       __pyx_t_2 = (__pyx_t_3 != 0);
4036       if (__pyx_t_2) {
4037         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4038         __Pyx_GOTREF(__pyx_t_6);
4039         __pyx_v_dtype = __pyx_t_6;
4040         __pyx_t_6 = 0;
4041         goto __pyx_L12;
4042       }
4043       __pyx_t_2 = __pyx_memoryview_check(__pyx_v_arg);
4044       __pyx_t_3 = (__pyx_t_2 != 0);
4045       if (__pyx_t_3) {
4046         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4047         __Pyx_GOTREF(__pyx_t_6);
4048         __pyx_v_arg_base = __pyx_t_6;
4049         __pyx_t_6 = 0;
4050         __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray);
4051         __pyx_t_2 = (__pyx_t_3 != 0);
4052         if (__pyx_t_2) {
4053           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4054           __Pyx_GOTREF(__pyx_t_6);
4055           __pyx_v_dtype = __pyx_t_6;
4056           __pyx_t_6 = 0;
4057           goto __pyx_L13;
4058         }
4059         /*else*/ {
4060           __Pyx_INCREF(Py_None);
4061           __pyx_v_dtype = Py_None;
4062         }
4063         __pyx_L13:;
4064         goto __pyx_L12;
4065       }
4066       /*else*/ {
4067         __Pyx_INCREF(Py_None);
4068         __pyx_v_dtype = Py_None;
4069       }
4070       __pyx_L12:;
4071       __pyx_v_itemsize = -1L;
4072       __pyx_t_2 = (__pyx_v_dtype != Py_None);
4073       __pyx_t_3 = (__pyx_t_2 != 0);
4074       if (__pyx_t_3) {
4075         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4076         __Pyx_GOTREF(__pyx_t_6);
4077         __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L1_error)
4078         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4079         __pyx_v_itemsize = __pyx_t_5;
4080         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4081         __Pyx_GOTREF(__pyx_t_6);
4082         __pyx_t_7 = __Pyx_PyObject_Ord(__pyx_t_6); if (unlikely(__pyx_t_7 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 163, __pyx_L1_error)
4083         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4084         __pyx_v_kind = __pyx_t_7;
4085         __pyx_v_dtype_signed = (__pyx_v_kind == 'i');
4086         switch (__pyx_v_kind) {
4087           case 'i':
4088           case 'u':
4089           break;
4090           case 'f':
4091           __pyx_t_2 = (((sizeof(float)) == __pyx_v_itemsize) != 0);
4092           if (__pyx_t_2) {
4093           } else {
4094             __pyx_t_3 = __pyx_t_2;
4095             goto __pyx_L16_bool_binop_done;
4096           }
4097           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4098           __Pyx_GOTREF(__pyx_t_6);
4099           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L1_error)
4100           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4101           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 2) != 0);
4102           __pyx_t_3 = __pyx_t_2;
4103           __pyx_L16_bool_binop_done:;
4104           if (__pyx_t_3) {
4105             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 163, __pyx_L1_error)
4106             goto __pyx_L10_break;
4107           }
4108           __pyx_t_2 = (((sizeof(double)) == __pyx_v_itemsize) != 0);
4109           if (__pyx_t_2) {
4110           } else {
4111             __pyx_t_3 = __pyx_t_2;
4112             goto __pyx_L19_bool_binop_done;
4113           }
4114           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4115           __Pyx_GOTREF(__pyx_t_6);
4116           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L1_error)
4117           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4118           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 2) != 0);
4119           __pyx_t_3 = __pyx_t_2;
4120           __pyx_L19_bool_binop_done:;
4121           if (__pyx_t_3) {
4122             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 163, __pyx_L1_error)
4123             goto __pyx_L10_break;
4124           }
4125           break;
4126           case 'c':
4127           break;
4128           case 'O':
4129           break;
4130           default: break;
4131         }
4132       }
4133     }
4134     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
4135     if (!__pyx_t_2) {
4136     } else {
4137       __pyx_t_3 = __pyx_t_2;
4138       goto __pyx_L22_bool_binop_done;
4139     }
4140     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(float))) != 0);
4141     __pyx_t_3 = __pyx_t_2;
4142     __pyx_L22_bool_binop_done:;
4143     if (__pyx_t_3) {
4144       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_v_arg, 0);
4145       __pyx_v_memslice = __pyx_t_8;
4146       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
4147       if (__pyx_t_3) {
4148         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
4149         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 163, __pyx_L1_error)
4150         goto __pyx_L10_break;
4151       }
4152       /*else*/ {
4153         PyErr_Clear();
4154       }
4155     }
4156     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
4157     if (!__pyx_t_2) {
4158     } else {
4159       __pyx_t_3 = __pyx_t_2;
4160       goto __pyx_L26_bool_binop_done;
4161     }
4162     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(double))) != 0);
4163     __pyx_t_3 = __pyx_t_2;
4164     __pyx_L26_bool_binop_done:;
4165     if (__pyx_t_3) {
4166       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_v_arg, 0);
4167       __pyx_v_memslice = __pyx_t_8;
4168       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
4169       if (__pyx_t_3) {
4170         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
4171         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 163, __pyx_L1_error)
4172         goto __pyx_L10_break;
4173       }
4174       /*else*/ {
4175         PyErr_Clear();
4176       }
4177     }
4178     if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 163, __pyx_L1_error)
4179     goto __pyx_L10_break;
4180   }
4181   __pyx_L10_break:;
4182   __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4183   __Pyx_GOTREF(__pyx_t_6);
4184   __pyx_v_candidates = ((PyObject*)__pyx_t_6);
4185   __pyx_t_6 = 0;
4186   __pyx_t_5 = 0;
4187   if (unlikely(__pyx_v_signatures == Py_None)) {
4188     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
4189     __PYX_ERR(0, 163, __pyx_L1_error)
4190   }
4191   __pyx_t_1 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
4192   __Pyx_GOTREF(__pyx_t_1);
4193   __Pyx_XDECREF(__pyx_t_6);
4194   __pyx_t_6 = __pyx_t_1;
4195   __pyx_t_1 = 0;
4196   while (1) {
4197     __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_5, &__pyx_t_1, NULL, NULL, __pyx_t_10);
4198     if (unlikely(__pyx_t_11 == 0)) break;
4199     if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 163, __pyx_L1_error)
4200     __Pyx_GOTREF(__pyx_t_1);
4201     __Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_1);
4202     __pyx_t_1 = 0;
4203     __pyx_v_match_found = 0;
4204     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 163, __pyx_L1_error)
4205     __Pyx_GOTREF(__pyx_t_13);
4206     __pyx_t_14 = NULL;
4207     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
4208       __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
4209       if (likely(__pyx_t_14)) {
4210         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
4211         __Pyx_INCREF(__pyx_t_14);
4212         __Pyx_INCREF(function);
4213         __Pyx_DECREF_SET(__pyx_t_13, function);
4214       }
4215     }
4216     __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_kp_s__3) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__3);
4217     __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
4218     if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 163, __pyx_L1_error)
4219     __Pyx_GOTREF(__pyx_t_12);
4220     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
4221     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_split); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 163, __pyx_L1_error)
4222     __Pyx_GOTREF(__pyx_t_13);
4223     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
4224     __pyx_t_12 = NULL;
4225     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
4226       __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
4227       if (likely(__pyx_t_12)) {
4228         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
4229         __Pyx_INCREF(__pyx_t_12);
4230         __Pyx_INCREF(function);
4231         __Pyx_DECREF_SET(__pyx_t_13, function);
4232       }
4233     }
4234     __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_kp_s__4) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__4);
4235     __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
4236     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
4237     __Pyx_GOTREF(__pyx_t_1);
4238     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
4239     __Pyx_XDECREF_SET(__pyx_v_src_sig, __pyx_t_1);
4240     __pyx_t_1 = 0;
4241     __pyx_t_15 = PyList_GET_SIZE(__pyx_v_dest_sig); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 163, __pyx_L1_error)
4242     __pyx_t_16 = __pyx_t_15;
4243     for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
4244       __pyx_v_i = __pyx_t_17;
4245       __pyx_t_1 = PyList_GET_ITEM(__pyx_v_dest_sig, __pyx_v_i);
4246       __Pyx_INCREF(__pyx_t_1);
4247       __Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_1);
4248       __pyx_t_1 = 0;
4249       __pyx_t_3 = (__pyx_v_dst_type != Py_None);
4250       __pyx_t_2 = (__pyx_t_3 != 0);
4251       if (__pyx_t_2) {
4252         __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
4253         __Pyx_GOTREF(__pyx_t_1);
4254         __pyx_t_13 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 163, __pyx_L1_error)
4255         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4256         __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 163, __pyx_L1_error)
4257         __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
4258         if (__pyx_t_2) {
4259           __pyx_v_match_found = 1;
4260           goto __pyx_L34;
4261         }
4262         /*else*/ {
4263           __pyx_v_match_found = 0;
4264           goto __pyx_L32_break;
4265         }
4266         __pyx_L34:;
4267       }
4268     }
4269     __pyx_L32_break:;
4270     __pyx_t_2 = (__pyx_v_match_found != 0);
4271     if (__pyx_t_2) {
4272       __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 163, __pyx_L1_error)
4273     }
4274   }
4275   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4276   __pyx_t_2 = (PyList_GET_SIZE(__pyx_v_candidates) != 0);
4277   __pyx_t_3 = ((!__pyx_t_2) != 0);
4278   if (__pyx_t_3) {
4279     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4280     __Pyx_GOTREF(__pyx_t_6);
4281     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
4282     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4283     __PYX_ERR(0, 163, __pyx_L1_error)
4284   }
4285   __pyx_t_9 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 163, __pyx_L1_error)
4286   __pyx_t_3 = ((__pyx_t_9 > 1) != 0);
4287   if (__pyx_t_3) {
4288     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4289     __Pyx_GOTREF(__pyx_t_6);
4290     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
4291     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4292     __PYX_ERR(0, 163, __pyx_L1_error)
4293   }
4294   /*else*/ {
4295     __Pyx_XDECREF(__pyx_r);
4296     if (unlikely(__pyx_v_signatures == Py_None)) {
4297       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
4298       __PYX_ERR(0, 163, __pyx_L1_error)
4299     }
4300     __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), PyList_GET_ITEM(__pyx_v_candidates, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4301     __Pyx_GOTREF(__pyx_t_6);
4302     __pyx_r = __pyx_t_6;
4303     __pyx_t_6 = 0;
4304     goto __pyx_L0;
4305   }
4306 
4307   /* function exit code */
4308   __pyx_L1_error:;
4309   __Pyx_XDECREF(__pyx_t_1);
4310   __Pyx_XDECREF(__pyx_t_6);
4311   __Pyx_XDECREF(__pyx_t_12);
4312   __Pyx_XDECREF(__pyx_t_13);
4313   __Pyx_XDECREF(__pyx_t_14);
4314   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
4315   __pyx_r = NULL;
4316   __pyx_L0:;
4317   __Pyx_XDECREF(__pyx_v_dest_sig);
4318   __Pyx_XDECREF(__pyx_v_ndarray);
4319   __Pyx_XDECREF(__pyx_v_arg);
4320   __Pyx_XDECREF(__pyx_v_dtype);
4321   __Pyx_XDECREF(__pyx_v_arg_base);
4322   __Pyx_XDECREF(__pyx_v_candidates);
4323   __Pyx_XDECREF(__pyx_v_sig);
4324   __Pyx_XDECREF(__pyx_v_src_sig);
4325   __Pyx_XDECREF(__pyx_v_dst_type);
4326   __Pyx_XDECREF(__pyx_v_kwargs);
4327   __Pyx_XGIVEREF(__pyx_r);
4328   __Pyx_RefNannyFinishContext();
4329   return __pyx_r;
4330 }
4331 
4332 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_21__pyx_fuse_0iterate_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4333 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_5iterate_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_grad,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_displacement_field,CYTHON_UNUSED int __pyx_skip_dispatch)4334 static double __pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_displacement_field, CYTHON_UNUSED int __pyx_skip_dispatch) {
4335   CYTHON_UNUSED PyObject *__pyx_v_ftype = NULL;
4336   int __pyx_v_NUM_NEIGHBORS;
4337   int *__pyx_v_dRow;
4338   int *__pyx_v_dCol;
4339   npy_intp __pyx_v_nrows;
4340   npy_intp __pyx_v_ncols;
4341   npy_intp __pyx_v_r;
4342   npy_intp __pyx_v_c;
4343   npy_intp __pyx_v_dr;
4344   npy_intp __pyx_v_dc;
4345   npy_intp __pyx_v_nn;
4346   npy_intp __pyx_v_k;
4347   double *__pyx_v_b;
4348   double *__pyx_v_d;
4349   double *__pyx_v_y;
4350   double *__pyx_v_A;
4351   double __pyx_v_xx;
4352   double __pyx_v_yy;
4353   double __pyx_v_opt;
4354   double __pyx_v_nrm2;
4355   CYTHON_UNUSED double __pyx_v_delta;
4356   double __pyx_v_sigmasq;
4357   double __pyx_v_max_displacement;
4358   double __pyx_v_det;
4359   double __pyx_r;
4360   __Pyx_RefNannyDeclarations
4361   PyObject *__pyx_t_1 = NULL;
4362   PyObject *__pyx_t_2 = NULL;
4363   PyObject *__pyx_t_3 = NULL;
4364   PyObject *__pyx_t_4 = NULL;
4365   int __pyx_t_5[4];
4366   int __pyx_t_6[4];
4367   double __pyx_t_7[2];
4368   double __pyx_t_8[2];
4369   double __pyx_t_9[2];
4370   double __pyx_t_10[3];
4371   npy_intp __pyx_t_11;
4372   npy_intp __pyx_t_12;
4373   npy_intp __pyx_t_13;
4374   npy_intp __pyx_t_14;
4375   npy_intp __pyx_t_15;
4376   npy_intp __pyx_t_16;
4377   Py_ssize_t __pyx_t_17;
4378   Py_ssize_t __pyx_t_18;
4379   double __pyx_t_19;
4380   int __pyx_t_20;
4381   Py_ssize_t __pyx_t_21;
4382   Py_ssize_t __pyx_t_22;
4383   Py_ssize_t __pyx_t_23;
4384   int __pyx_t_24;
4385   int __pyx_t_25;
4386   npy_intp __pyx_t_26;
4387   int __pyx_t_27;
4388   long __pyx_t_28;
4389   Py_ssize_t __pyx_t_29;
4390   int __pyx_lineno = 0;
4391   const char *__pyx_filename = NULL;
4392   int __pyx_clineno = 0;
4393   __Pyx_RefNannySetupContext("__pyx_fuse_0iterate_residual_displacement_field_ssd_2d", 0);
4394 
4395   /* "dipy/align/sumsqdiff.pyx":204
4396  *               Vision, 2005. ICCV 2005.
4397  *     """
4398  *     ftype = np.asarray(delta_field).dtype             # <<<<<<<<<<<<<<
4399  *     cdef:
4400  *         int NUM_NEIGHBORS = 4
4401  */
4402   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
4403   __Pyx_GOTREF(__pyx_t_2);
4404   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
4405   __Pyx_GOTREF(__pyx_t_3);
4406   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4407   __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
4408   __Pyx_GOTREF(__pyx_t_2);
4409   __pyx_t_4 = NULL;
4410   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
4411     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
4412     if (likely(__pyx_t_4)) {
4413       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
4414       __Pyx_INCREF(__pyx_t_4);
4415       __Pyx_INCREF(function);
4416       __Pyx_DECREF_SET(__pyx_t_3, function);
4417     }
4418   }
4419   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
4420   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
4421   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4422   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
4423   __Pyx_GOTREF(__pyx_t_1);
4424   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4425   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
4426   __Pyx_GOTREF(__pyx_t_3);
4427   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4428   __pyx_v_ftype = __pyx_t_3;
4429   __pyx_t_3 = 0;
4430 
4431   /* "dipy/align/sumsqdiff.pyx":206
4432  *     ftype = np.asarray(delta_field).dtype
4433  *     cdef:
4434  *         int NUM_NEIGHBORS = 4             # <<<<<<<<<<<<<<
4435  *         int* dRow = [-1, 0, 1,  0]
4436  *         int* dCol = [0, 1, 0, -1]
4437  */
4438   __pyx_v_NUM_NEIGHBORS = 4;
4439 
4440   /* "dipy/align/sumsqdiff.pyx":207
4441  *     cdef:
4442  *         int NUM_NEIGHBORS = 4
4443  *         int* dRow = [-1, 0, 1,  0]             # <<<<<<<<<<<<<<
4444  *         int* dCol = [0, 1, 0, -1]
4445  *         cnp.npy_intp nrows = delta_field.shape[0]
4446  */
4447   __pyx_t_5[0] = -1;
4448   __pyx_t_5[1] = 0;
4449   __pyx_t_5[2] = 1;
4450   __pyx_t_5[3] = 0;
4451   __pyx_v_dRow = __pyx_t_5;
4452 
4453   /* "dipy/align/sumsqdiff.pyx":208
4454  *         int NUM_NEIGHBORS = 4
4455  *         int* dRow = [-1, 0, 1,  0]
4456  *         int* dCol = [0, 1, 0, -1]             # <<<<<<<<<<<<<<
4457  *         cnp.npy_intp nrows = delta_field.shape[0]
4458  *         cnp.npy_intp ncols = delta_field.shape[1]
4459  */
4460   __pyx_t_6[0] = 0;
4461   __pyx_t_6[1] = 1;
4462   __pyx_t_6[2] = 0;
4463   __pyx_t_6[3] = -1;
4464   __pyx_v_dCol = __pyx_t_6;
4465 
4466   /* "dipy/align/sumsqdiff.pyx":209
4467  *         int* dRow = [-1, 0, 1,  0]
4468  *         int* dCol = [0, 1, 0, -1]
4469  *         cnp.npy_intp nrows = delta_field.shape[0]             # <<<<<<<<<<<<<<
4470  *         cnp.npy_intp ncols = delta_field.shape[1]
4471  *         cnp.npy_intp r, c, dr, dc, nn, k
4472  */
4473   __pyx_v_nrows = (__pyx_v_delta_field.shape[0]);
4474 
4475   /* "dipy/align/sumsqdiff.pyx":210
4476  *         int* dCol = [0, 1, 0, -1]
4477  *         cnp.npy_intp nrows = delta_field.shape[0]
4478  *         cnp.npy_intp ncols = delta_field.shape[1]             # <<<<<<<<<<<<<<
4479  *         cnp.npy_intp r, c, dr, dc, nn, k
4480  *
4481  */
4482   __pyx_v_ncols = (__pyx_v_delta_field.shape[1]);
4483 
4484   /* "dipy/align/sumsqdiff.pyx":213
4485  *         cnp.npy_intp r, c, dr, dc, nn, k
4486  *
4487  *         double* b = [0, 0]             # <<<<<<<<<<<<<<
4488  *         double* d = [0, 0]
4489  *         double* y = [0, 0]
4490  */
4491   __pyx_t_7[0] = 0.0;
4492   __pyx_t_7[1] = 0.0;
4493   __pyx_v_b = __pyx_t_7;
4494 
4495   /* "dipy/align/sumsqdiff.pyx":214
4496  *
4497  *         double* b = [0, 0]
4498  *         double* d = [0, 0]             # <<<<<<<<<<<<<<
4499  *         double* y = [0, 0]
4500  *         double* A = [0, 0, 0]
4501  */
4502   __pyx_t_8[0] = 0.0;
4503   __pyx_t_8[1] = 0.0;
4504   __pyx_v_d = __pyx_t_8;
4505 
4506   /* "dipy/align/sumsqdiff.pyx":215
4507  *         double* b = [0, 0]
4508  *         double* d = [0, 0]
4509  *         double* y = [0, 0]             # <<<<<<<<<<<<<<
4510  *         double* A = [0, 0, 0]
4511  *
4512  */
4513   __pyx_t_9[0] = 0.0;
4514   __pyx_t_9[1] = 0.0;
4515   __pyx_v_y = __pyx_t_9;
4516 
4517   /* "dipy/align/sumsqdiff.pyx":216
4518  *         double* d = [0, 0]
4519  *         double* y = [0, 0]
4520  *         double* A = [0, 0, 0]             # <<<<<<<<<<<<<<
4521  *
4522  *         double xx, yy, opt, nrm2, delta, sigmasq, max_displacement, det
4523  */
4524   __pyx_t_10[0] = 0.0;
4525   __pyx_t_10[1] = 0.0;
4526   __pyx_t_10[2] = 0.0;
4527   __pyx_v_A = __pyx_t_10;
4528 
4529   /* "dipy/align/sumsqdiff.pyx":220
4530  *         double xx, yy, opt, nrm2, delta, sigmasq, max_displacement, det
4531  *
4532  *     max_displacement = 0             # <<<<<<<<<<<<<<
4533  *
4534  *     with nogil:
4535  */
4536   __pyx_v_max_displacement = 0.0;
4537 
4538   /* "dipy/align/sumsqdiff.pyx":222
4539  *     max_displacement = 0
4540  *
4541  *     with nogil:             # <<<<<<<<<<<<<<
4542  *
4543  *         for r in range(nrows):
4544  */
4545   {
4546       #ifdef WITH_THREAD
4547       PyThreadState *_save;
4548       Py_UNBLOCK_THREADS
4549       __Pyx_FastGIL_Remember();
4550       #endif
4551       /*try:*/ {
4552 
4553         /* "dipy/align/sumsqdiff.pyx":224
4554  *     with nogil:
4555  *
4556  *         for r in range(nrows):             # <<<<<<<<<<<<<<
4557  *             for c in range(ncols):
4558  *                 delta = delta_field[r, c]
4559  */
4560         __pyx_t_11 = __pyx_v_nrows;
4561         __pyx_t_12 = __pyx_t_11;
4562         for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
4563           __pyx_v_r = __pyx_t_13;
4564 
4565           /* "dipy/align/sumsqdiff.pyx":225
4566  *
4567  *         for r in range(nrows):
4568  *             for c in range(ncols):             # <<<<<<<<<<<<<<
4569  *                 delta = delta_field[r, c]
4570  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
4571  */
4572           __pyx_t_14 = __pyx_v_ncols;
4573           __pyx_t_15 = __pyx_t_14;
4574           for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
4575             __pyx_v_c = __pyx_t_16;
4576 
4577             /* "dipy/align/sumsqdiff.pyx":226
4578  *         for r in range(nrows):
4579  *             for c in range(ncols):
4580  *                 delta = delta_field[r, c]             # <<<<<<<<<<<<<<
4581  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
4582  *                 if(target is None):
4583  */
4584             __pyx_t_17 = __pyx_v_r;
4585             __pyx_t_18 = __pyx_v_c;
4586             __pyx_v_delta = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_17 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_18 * __pyx_v_delta_field.strides[1]) )));
4587 
4588             /* "dipy/align/sumsqdiff.pyx":227
4589  *             for c in range(ncols):
4590  *                 delta = delta_field[r, c]
4591  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1             # <<<<<<<<<<<<<<
4592  *                 if(target is None):
4593  *                     b[0] = delta_field[r, c] * grad[r, c, 0]
4594  */
4595             if (((((PyObject *) __pyx_v_sigmasq_field.memview) != Py_None) != 0)) {
4596               __pyx_t_18 = __pyx_v_r;
4597               __pyx_t_17 = __pyx_v_c;
4598               __pyx_t_19 = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_sigmasq_field.data + __pyx_t_18 * __pyx_v_sigmasq_field.strides[0]) ) + __pyx_t_17 * __pyx_v_sigmasq_field.strides[1]) )));
4599             } else {
4600               __pyx_t_19 = 1.0;
4601             }
4602             __pyx_v_sigmasq = __pyx_t_19;
4603 
4604             /* "dipy/align/sumsqdiff.pyx":228
4605  *                 delta = delta_field[r, c]
4606  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
4607  *                 if(target is None):             # <<<<<<<<<<<<<<
4608  *                     b[0] = delta_field[r, c] * grad[r, c, 0]
4609  *                     b[1] = delta_field[r, c] * grad[r, c, 1]
4610  */
4611             __pyx_t_20 = ((((PyObject *) __pyx_v_target.memview) == Py_None) != 0);
4612             if (__pyx_t_20) {
4613 
4614               /* "dipy/align/sumsqdiff.pyx":229
4615  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
4616  *                 if(target is None):
4617  *                     b[0] = delta_field[r, c] * grad[r, c, 0]             # <<<<<<<<<<<<<<
4618  *                     b[1] = delta_field[r, c] * grad[r, c, 1]
4619  *                 else:
4620  */
4621               __pyx_t_17 = __pyx_v_r;
4622               __pyx_t_18 = __pyx_v_c;
4623               __pyx_t_21 = __pyx_v_r;
4624               __pyx_t_22 = __pyx_v_c;
4625               __pyx_t_23 = 0;
4626               (__pyx_v_b[0]) = ((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_17 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_18 * __pyx_v_delta_field.strides[1]) ))) * (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_21 * __pyx_v_grad.strides[0]) ) + __pyx_t_22 * __pyx_v_grad.strides[1]) ) + __pyx_t_23 * __pyx_v_grad.strides[2]) ))));
4627 
4628               /* "dipy/align/sumsqdiff.pyx":230
4629  *                 if(target is None):
4630  *                     b[0] = delta_field[r, c] * grad[r, c, 0]
4631  *                     b[1] = delta_field[r, c] * grad[r, c, 1]             # <<<<<<<<<<<<<<
4632  *                 else:
4633  *                     b[0] = target[r, c, 0]
4634  */
4635               __pyx_t_23 = __pyx_v_r;
4636               __pyx_t_22 = __pyx_v_c;
4637               __pyx_t_21 = __pyx_v_r;
4638               __pyx_t_18 = __pyx_v_c;
4639               __pyx_t_17 = 1;
4640               (__pyx_v_b[1]) = ((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_23 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_22 * __pyx_v_delta_field.strides[1]) ))) * (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_21 * __pyx_v_grad.strides[0]) ) + __pyx_t_18 * __pyx_v_grad.strides[1]) ) + __pyx_t_17 * __pyx_v_grad.strides[2]) ))));
4641 
4642               /* "dipy/align/sumsqdiff.pyx":228
4643  *                 delta = delta_field[r, c]
4644  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
4645  *                 if(target is None):             # <<<<<<<<<<<<<<
4646  *                     b[0] = delta_field[r, c] * grad[r, c, 0]
4647  *                     b[1] = delta_field[r, c] * grad[r, c, 1]
4648  */
4649               goto __pyx_L10;
4650             }
4651 
4652             /* "dipy/align/sumsqdiff.pyx":232
4653  *                     b[1] = delta_field[r, c] * grad[r, c, 1]
4654  *                 else:
4655  *                     b[0] = target[r, c, 0]             # <<<<<<<<<<<<<<
4656  *                     b[1] = target[r, c, 1]
4657  *                 nn = 0
4658  */
4659             /*else*/ {
4660               __pyx_t_17 = __pyx_v_r;
4661               __pyx_t_18 = __pyx_v_c;
4662               __pyx_t_21 = 0;
4663               (__pyx_v_b[0]) = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_17 * __pyx_v_target.strides[0]) ) + __pyx_t_18 * __pyx_v_target.strides[1]) ) + __pyx_t_21 * __pyx_v_target.strides[2]) )));
4664 
4665               /* "dipy/align/sumsqdiff.pyx":233
4666  *                 else:
4667  *                     b[0] = target[r, c, 0]
4668  *                     b[1] = target[r, c, 1]             # <<<<<<<<<<<<<<
4669  *                 nn = 0
4670  *                 y[0] = 0
4671  */
4672               __pyx_t_21 = __pyx_v_r;
4673               __pyx_t_18 = __pyx_v_c;
4674               __pyx_t_17 = 1;
4675               (__pyx_v_b[1]) = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_21 * __pyx_v_target.strides[0]) ) + __pyx_t_18 * __pyx_v_target.strides[1]) ) + __pyx_t_17 * __pyx_v_target.strides[2]) )));
4676             }
4677             __pyx_L10:;
4678 
4679             /* "dipy/align/sumsqdiff.pyx":234
4680  *                     b[0] = target[r, c, 0]
4681  *                     b[1] = target[r, c, 1]
4682  *                 nn = 0             # <<<<<<<<<<<<<<
4683  *                 y[0] = 0
4684  *                 y[1] = 0
4685  */
4686             __pyx_v_nn = 0;
4687 
4688             /* "dipy/align/sumsqdiff.pyx":235
4689  *                     b[1] = target[r, c, 1]
4690  *                 nn = 0
4691  *                 y[0] = 0             # <<<<<<<<<<<<<<
4692  *                 y[1] = 0
4693  *                 for k in range(NUM_NEIGHBORS):
4694  */
4695             (__pyx_v_y[0]) = 0.0;
4696 
4697             /* "dipy/align/sumsqdiff.pyx":236
4698  *                 nn = 0
4699  *                 y[0] = 0
4700  *                 y[1] = 0             # <<<<<<<<<<<<<<
4701  *                 for k in range(NUM_NEIGHBORS):
4702  *                     dr = r + dRow[k]
4703  */
4704             (__pyx_v_y[1]) = 0.0;
4705 
4706             /* "dipy/align/sumsqdiff.pyx":237
4707  *                 y[0] = 0
4708  *                 y[1] = 0
4709  *                 for k in range(NUM_NEIGHBORS):             # <<<<<<<<<<<<<<
4710  *                     dr = r + dRow[k]
4711  *                     if((dr < 0) or (dr >= nrows)):
4712  */
4713             __pyx_t_24 = __pyx_v_NUM_NEIGHBORS;
4714             __pyx_t_25 = __pyx_t_24;
4715             for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_25; __pyx_t_26+=1) {
4716               __pyx_v_k = __pyx_t_26;
4717 
4718               /* "dipy/align/sumsqdiff.pyx":238
4719  *                 y[1] = 0
4720  *                 for k in range(NUM_NEIGHBORS):
4721  *                     dr = r + dRow[k]             # <<<<<<<<<<<<<<
4722  *                     if((dr < 0) or (dr >= nrows)):
4723  *                         continue
4724  */
4725               __pyx_v_dr = (__pyx_v_r + (__pyx_v_dRow[__pyx_v_k]));
4726 
4727               /* "dipy/align/sumsqdiff.pyx":239
4728  *                 for k in range(NUM_NEIGHBORS):
4729  *                     dr = r + dRow[k]
4730  *                     if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
4731  *                         continue
4732  *                     dc = c + dCol[k]
4733  */
4734               __pyx_t_27 = ((__pyx_v_dr < 0) != 0);
4735               if (!__pyx_t_27) {
4736               } else {
4737                 __pyx_t_20 = __pyx_t_27;
4738                 goto __pyx_L14_bool_binop_done;
4739               }
4740               __pyx_t_27 = ((__pyx_v_dr >= __pyx_v_nrows) != 0);
4741               __pyx_t_20 = __pyx_t_27;
4742               __pyx_L14_bool_binop_done:;
4743               if (__pyx_t_20) {
4744 
4745                 /* "dipy/align/sumsqdiff.pyx":240
4746  *                     dr = r + dRow[k]
4747  *                     if((dr < 0) or (dr >= nrows)):
4748  *                         continue             # <<<<<<<<<<<<<<
4749  *                     dc = c + dCol[k]
4750  *                     if((dc < 0) or (dc >= ncols)):
4751  */
4752                 goto __pyx_L11_continue;
4753 
4754                 /* "dipy/align/sumsqdiff.pyx":239
4755  *                 for k in range(NUM_NEIGHBORS):
4756  *                     dr = r + dRow[k]
4757  *                     if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
4758  *                         continue
4759  *                     dc = c + dCol[k]
4760  */
4761               }
4762 
4763               /* "dipy/align/sumsqdiff.pyx":241
4764  *                     if((dr < 0) or (dr >= nrows)):
4765  *                         continue
4766  *                     dc = c + dCol[k]             # <<<<<<<<<<<<<<
4767  *                     if((dc < 0) or (dc >= ncols)):
4768  *                         continue
4769  */
4770               __pyx_v_dc = (__pyx_v_c + (__pyx_v_dCol[__pyx_v_k]));
4771 
4772               /* "dipy/align/sumsqdiff.pyx":242
4773  *                         continue
4774  *                     dc = c + dCol[k]
4775  *                     if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
4776  *                         continue
4777  *                     nn += 1
4778  */
4779               __pyx_t_27 = ((__pyx_v_dc < 0) != 0);
4780               if (!__pyx_t_27) {
4781               } else {
4782                 __pyx_t_20 = __pyx_t_27;
4783                 goto __pyx_L17_bool_binop_done;
4784               }
4785               __pyx_t_27 = ((__pyx_v_dc >= __pyx_v_ncols) != 0);
4786               __pyx_t_20 = __pyx_t_27;
4787               __pyx_L17_bool_binop_done:;
4788               if (__pyx_t_20) {
4789 
4790                 /* "dipy/align/sumsqdiff.pyx":243
4791  *                     dc = c + dCol[k]
4792  *                     if((dc < 0) or (dc >= ncols)):
4793  *                         continue             # <<<<<<<<<<<<<<
4794  *                     nn += 1
4795  *                     y[0] += displacement_field[dr, dc, 0]
4796  */
4797                 goto __pyx_L11_continue;
4798 
4799                 /* "dipy/align/sumsqdiff.pyx":242
4800  *                         continue
4801  *                     dc = c + dCol[k]
4802  *                     if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
4803  *                         continue
4804  *                     nn += 1
4805  */
4806               }
4807 
4808               /* "dipy/align/sumsqdiff.pyx":244
4809  *                     if((dc < 0) or (dc >= ncols)):
4810  *                         continue
4811  *                     nn += 1             # <<<<<<<<<<<<<<
4812  *                     y[0] += displacement_field[dr, dc, 0]
4813  *                     y[1] += displacement_field[dr, dc, 1]
4814  */
4815               __pyx_v_nn = (__pyx_v_nn + 1);
4816 
4817               /* "dipy/align/sumsqdiff.pyx":245
4818  *                         continue
4819  *                     nn += 1
4820  *                     y[0] += displacement_field[dr, dc, 0]             # <<<<<<<<<<<<<<
4821  *                     y[1] += displacement_field[dr, dc, 1]
4822  *                 if dpy_isinf(sigmasq) != 0:
4823  */
4824               __pyx_t_28 = 0;
4825               __pyx_t_17 = __pyx_v_dr;
4826               __pyx_t_18 = __pyx_v_dc;
4827               __pyx_t_21 = 0;
4828               (__pyx_v_y[__pyx_t_28]) = ((__pyx_v_y[__pyx_t_28]) + (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) ))));
4829 
4830               /* "dipy/align/sumsqdiff.pyx":246
4831  *                     nn += 1
4832  *                     y[0] += displacement_field[dr, dc, 0]
4833  *                     y[1] += displacement_field[dr, dc, 1]             # <<<<<<<<<<<<<<
4834  *                 if dpy_isinf(sigmasq) != 0:
4835  *                     xx = displacement_field[r, c, 0]
4836  */
4837               __pyx_t_28 = 1;
4838               __pyx_t_21 = __pyx_v_dr;
4839               __pyx_t_18 = __pyx_v_dc;
4840               __pyx_t_17 = 1;
4841               (__pyx_v_y[__pyx_t_28]) = ((__pyx_v_y[__pyx_t_28]) + (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) ))));
4842               __pyx_L11_continue:;
4843             }
4844 
4845             /* "dipy/align/sumsqdiff.pyx":247
4846  *                     y[0] += displacement_field[dr, dc, 0]
4847  *                     y[1] += displacement_field[dr, dc, 1]
4848  *                 if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
4849  *                     xx = displacement_field[r, c, 0]
4850  *                     yy = displacement_field[r, c, 1]
4851  */
4852             __pyx_t_20 = ((dpy_isinf(__pyx_v_sigmasq) != 0) != 0);
4853             if (__pyx_t_20) {
4854 
4855               /* "dipy/align/sumsqdiff.pyx":248
4856  *                     y[1] += displacement_field[dr, dc, 1]
4857  *                 if dpy_isinf(sigmasq) != 0:
4858  *                     xx = displacement_field[r, c, 0]             # <<<<<<<<<<<<<<
4859  *                     yy = displacement_field[r, c, 1]
4860  *                     displacement_field[r, c, 0] = y[0] / nn
4861  */
4862               __pyx_t_17 = __pyx_v_r;
4863               __pyx_t_18 = __pyx_v_c;
4864               __pyx_t_21 = 0;
4865               __pyx_v_xx = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) )));
4866 
4867               /* "dipy/align/sumsqdiff.pyx":249
4868  *                 if dpy_isinf(sigmasq) != 0:
4869  *                     xx = displacement_field[r, c, 0]
4870  *                     yy = displacement_field[r, c, 1]             # <<<<<<<<<<<<<<
4871  *                     displacement_field[r, c, 0] = y[0] / nn
4872  *                     displacement_field[r, c, 1] = y[1] / nn
4873  */
4874               __pyx_t_21 = __pyx_v_r;
4875               __pyx_t_18 = __pyx_v_c;
4876               __pyx_t_17 = 1;
4877               __pyx_v_yy = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) )));
4878 
4879               /* "dipy/align/sumsqdiff.pyx":250
4880  *                     xx = displacement_field[r, c, 0]
4881  *                     yy = displacement_field[r, c, 1]
4882  *                     displacement_field[r, c, 0] = y[0] / nn             # <<<<<<<<<<<<<<
4883  *                     displacement_field[r, c, 1] = y[1] / nn
4884  *                     xx -= displacement_field[r, c, 0]
4885  */
4886               __pyx_t_17 = __pyx_v_r;
4887               __pyx_t_18 = __pyx_v_c;
4888               __pyx_t_21 = 0;
4889               *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) )) = ((__pyx_v_y[0]) / ((double)__pyx_v_nn));
4890 
4891               /* "dipy/align/sumsqdiff.pyx":251
4892  *                     yy = displacement_field[r, c, 1]
4893  *                     displacement_field[r, c, 0] = y[0] / nn
4894  *                     displacement_field[r, c, 1] = y[1] / nn             # <<<<<<<<<<<<<<
4895  *                     xx -= displacement_field[r, c, 0]
4896  *                     yy -= displacement_field[r, c, 1]
4897  */
4898               __pyx_t_21 = __pyx_v_r;
4899               __pyx_t_18 = __pyx_v_c;
4900               __pyx_t_17 = 1;
4901               *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) )) = ((__pyx_v_y[1]) / ((double)__pyx_v_nn));
4902 
4903               /* "dipy/align/sumsqdiff.pyx":252
4904  *                     displacement_field[r, c, 0] = y[0] / nn
4905  *                     displacement_field[r, c, 1] = y[1] / nn
4906  *                     xx -= displacement_field[r, c, 0]             # <<<<<<<<<<<<<<
4907  *                     yy -= displacement_field[r, c, 1]
4908  *                     opt = xx * xx + yy * yy
4909  */
4910               __pyx_t_17 = __pyx_v_r;
4911               __pyx_t_18 = __pyx_v_c;
4912               __pyx_t_21 = 0;
4913               __pyx_v_xx = (__pyx_v_xx - (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) ))));
4914 
4915               /* "dipy/align/sumsqdiff.pyx":253
4916  *                     displacement_field[r, c, 1] = y[1] / nn
4917  *                     xx -= displacement_field[r, c, 0]
4918  *                     yy -= displacement_field[r, c, 1]             # <<<<<<<<<<<<<<
4919  *                     opt = xx * xx + yy * yy
4920  *                     if(max_displacement < opt):
4921  */
4922               __pyx_t_21 = __pyx_v_r;
4923               __pyx_t_18 = __pyx_v_c;
4924               __pyx_t_17 = 1;
4925               __pyx_v_yy = (__pyx_v_yy - (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) ))));
4926 
4927               /* "dipy/align/sumsqdiff.pyx":254
4928  *                     xx -= displacement_field[r, c, 0]
4929  *                     yy -= displacement_field[r, c, 1]
4930  *                     opt = xx * xx + yy * yy             # <<<<<<<<<<<<<<
4931  *                     if(max_displacement < opt):
4932  *                         max_displacement = opt
4933  */
4934               __pyx_v_opt = ((__pyx_v_xx * __pyx_v_xx) + (__pyx_v_yy * __pyx_v_yy));
4935 
4936               /* "dipy/align/sumsqdiff.pyx":255
4937  *                     yy -= displacement_field[r, c, 1]
4938  *                     opt = xx * xx + yy * yy
4939  *                     if(max_displacement < opt):             # <<<<<<<<<<<<<<
4940  *                         max_displacement = opt
4941  *                 else:
4942  */
4943               __pyx_t_20 = ((__pyx_v_max_displacement < __pyx_v_opt) != 0);
4944               if (__pyx_t_20) {
4945 
4946                 /* "dipy/align/sumsqdiff.pyx":256
4947  *                     opt = xx * xx + yy * yy
4948  *                     if(max_displacement < opt):
4949  *                         max_displacement = opt             # <<<<<<<<<<<<<<
4950  *                 else:
4951  *                     A[0] = grad[r, c, 0] ** 2 + sigmasq * lambda_param * nn
4952  */
4953                 __pyx_v_max_displacement = __pyx_v_opt;
4954 
4955                 /* "dipy/align/sumsqdiff.pyx":255
4956  *                     yy -= displacement_field[r, c, 1]
4957  *                     opt = xx * xx + yy * yy
4958  *                     if(max_displacement < opt):             # <<<<<<<<<<<<<<
4959  *                         max_displacement = opt
4960  *                 else:
4961  */
4962               }
4963 
4964               /* "dipy/align/sumsqdiff.pyx":247
4965  *                     y[0] += displacement_field[dr, dc, 0]
4966  *                     y[1] += displacement_field[dr, dc, 1]
4967  *                 if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
4968  *                     xx = displacement_field[r, c, 0]
4969  *                     yy = displacement_field[r, c, 1]
4970  */
4971               goto __pyx_L19;
4972             }
4973 
4974             /* "dipy/align/sumsqdiff.pyx":258
4975  *                         max_displacement = opt
4976  *                 else:
4977  *                     A[0] = grad[r, c, 0] ** 2 + sigmasq * lambda_param * nn             # <<<<<<<<<<<<<<
4978  *                     A[1] = grad[r, c, 0] * grad[r, c, 1]
4979  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn
4980  */
4981             /*else*/ {
4982               __pyx_t_17 = __pyx_v_r;
4983               __pyx_t_18 = __pyx_v_c;
4984               __pyx_t_21 = 0;
4985               (__pyx_v_A[0]) = (powf((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_17 * __pyx_v_grad.strides[0]) ) + __pyx_t_18 * __pyx_v_grad.strides[1]) ) + __pyx_t_21 * __pyx_v_grad.strides[2]) ))), 2.0) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * __pyx_v_nn));
4986 
4987               /* "dipy/align/sumsqdiff.pyx":259
4988  *                 else:
4989  *                     A[0] = grad[r, c, 0] ** 2 + sigmasq * lambda_param * nn
4990  *                     A[1] = grad[r, c, 0] * grad[r, c, 1]             # <<<<<<<<<<<<<<
4991  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn
4992  *                     det = A[0] * A[2] - A[1] * A[1]
4993  */
4994               __pyx_t_21 = __pyx_v_r;
4995               __pyx_t_18 = __pyx_v_c;
4996               __pyx_t_17 = 0;
4997               __pyx_t_22 = __pyx_v_r;
4998               __pyx_t_23 = __pyx_v_c;
4999               __pyx_t_29 = 1;
5000               (__pyx_v_A[1]) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_21 * __pyx_v_grad.strides[0]) ) + __pyx_t_18 * __pyx_v_grad.strides[1]) ) + __pyx_t_17 * __pyx_v_grad.strides[2]) ))) * (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_22 * __pyx_v_grad.strides[0]) ) + __pyx_t_23 * __pyx_v_grad.strides[1]) ) + __pyx_t_29 * __pyx_v_grad.strides[2]) ))));
5001 
5002               /* "dipy/align/sumsqdiff.pyx":260
5003  *                     A[0] = grad[r, c, 0] ** 2 + sigmasq * lambda_param * nn
5004  *                     A[1] = grad[r, c, 0] * grad[r, c, 1]
5005  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn             # <<<<<<<<<<<<<<
5006  *                     det = A[0] * A[2] - A[1] * A[1]
5007  *                     if(det < 1e-9):
5008  */
5009               __pyx_t_29 = __pyx_v_r;
5010               __pyx_t_23 = __pyx_v_c;
5011               __pyx_t_22 = 1;
5012               (__pyx_v_A[2]) = (powf((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_29 * __pyx_v_grad.strides[0]) ) + __pyx_t_23 * __pyx_v_grad.strides[1]) ) + __pyx_t_22 * __pyx_v_grad.strides[2]) ))), 2.0) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * __pyx_v_nn));
5013 
5014               /* "dipy/align/sumsqdiff.pyx":261
5015  *                     A[1] = grad[r, c, 0] * grad[r, c, 1]
5016  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn
5017  *                     det = A[0] * A[2] - A[1] * A[1]             # <<<<<<<<<<<<<<
5018  *                     if(det < 1e-9):
5019  *                         nrm2 = (grad[r, c, 0] ** 2 +
5020  */
5021               __pyx_v_det = (((__pyx_v_A[0]) * (__pyx_v_A[2])) - ((__pyx_v_A[1]) * (__pyx_v_A[1])));
5022 
5023               /* "dipy/align/sumsqdiff.pyx":262
5024  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn
5025  *                     det = A[0] * A[2] - A[1] * A[1]
5026  *                     if(det < 1e-9):             # <<<<<<<<<<<<<<
5027  *                         nrm2 = (grad[r, c, 0] ** 2 +
5028  *                                 grad[r, c, 1] ** 2)
5029  */
5030               __pyx_t_20 = ((__pyx_v_det < 1e-9) != 0);
5031               if (__pyx_t_20) {
5032 
5033                 /* "dipy/align/sumsqdiff.pyx":263
5034  *                     det = A[0] * A[2] - A[1] * A[1]
5035  *                     if(det < 1e-9):
5036  *                         nrm2 = (grad[r, c, 0] ** 2 +             # <<<<<<<<<<<<<<
5037  *                                 grad[r, c, 1] ** 2)
5038  *                         if(nrm2 < 1e-9):
5039  */
5040                 __pyx_t_22 = __pyx_v_r;
5041                 __pyx_t_23 = __pyx_v_c;
5042                 __pyx_t_29 = 0;
5043 
5044                 /* "dipy/align/sumsqdiff.pyx":264
5045  *                     if(det < 1e-9):
5046  *                         nrm2 = (grad[r, c, 0] ** 2 +
5047  *                                 grad[r, c, 1] ** 2)             # <<<<<<<<<<<<<<
5048  *                         if(nrm2 < 1e-9):
5049  *                             displacement_field[r, c, 0] = 0
5050  */
5051                 __pyx_t_17 = __pyx_v_r;
5052                 __pyx_t_18 = __pyx_v_c;
5053                 __pyx_t_21 = 1;
5054 
5055                 /* "dipy/align/sumsqdiff.pyx":263
5056  *                     det = A[0] * A[2] - A[1] * A[1]
5057  *                     if(det < 1e-9):
5058  *                         nrm2 = (grad[r, c, 0] ** 2 +             # <<<<<<<<<<<<<<
5059  *                                 grad[r, c, 1] ** 2)
5060  *                         if(nrm2 < 1e-9):
5061  */
5062                 __pyx_v_nrm2 = (powf((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_22 * __pyx_v_grad.strides[0]) ) + __pyx_t_23 * __pyx_v_grad.strides[1]) ) + __pyx_t_29 * __pyx_v_grad.strides[2]) ))), 2.0) + powf((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_17 * __pyx_v_grad.strides[0]) ) + __pyx_t_18 * __pyx_v_grad.strides[1]) ) + __pyx_t_21 * __pyx_v_grad.strides[2]) ))), 2.0));
5063 
5064                 /* "dipy/align/sumsqdiff.pyx":265
5065  *                         nrm2 = (grad[r, c, 0] ** 2 +
5066  *                                 grad[r, c, 1] ** 2)
5067  *                         if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
5068  *                             displacement_field[r, c, 0] = 0
5069  *                             displacement_field[r, c, 1] = 0
5070  */
5071                 __pyx_t_20 = ((__pyx_v_nrm2 < 1e-9) != 0);
5072                 if (__pyx_t_20) {
5073 
5074                   /* "dipy/align/sumsqdiff.pyx":266
5075  *                                 grad[r, c, 1] ** 2)
5076  *                         if(nrm2 < 1e-9):
5077  *                             displacement_field[r, c, 0] = 0             # <<<<<<<<<<<<<<
5078  *                             displacement_field[r, c, 1] = 0
5079  *                         else:
5080  */
5081                   __pyx_t_21 = __pyx_v_r;
5082                   __pyx_t_18 = __pyx_v_c;
5083                   __pyx_t_17 = 0;
5084                   *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) )) = 0.0;
5085 
5086                   /* "dipy/align/sumsqdiff.pyx":267
5087  *                         if(nrm2 < 1e-9):
5088  *                             displacement_field[r, c, 0] = 0
5089  *                             displacement_field[r, c, 1] = 0             # <<<<<<<<<<<<<<
5090  *                         else:
5091  *                             displacement_field[r, c, 0] = (b[0]) / nrm2
5092  */
5093                   __pyx_t_17 = __pyx_v_r;
5094                   __pyx_t_18 = __pyx_v_c;
5095                   __pyx_t_21 = 1;
5096                   *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) )) = 0.0;
5097 
5098                   /* "dipy/align/sumsqdiff.pyx":265
5099  *                         nrm2 = (grad[r, c, 0] ** 2 +
5100  *                                 grad[r, c, 1] ** 2)
5101  *                         if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
5102  *                             displacement_field[r, c, 0] = 0
5103  *                             displacement_field[r, c, 1] = 0
5104  */
5105                   goto __pyx_L22;
5106                 }
5107 
5108                 /* "dipy/align/sumsqdiff.pyx":269
5109  *                             displacement_field[r, c, 1] = 0
5110  *                         else:
5111  *                             displacement_field[r, c, 0] = (b[0]) / nrm2             # <<<<<<<<<<<<<<
5112  *                             displacement_field[r, c, 1] = (b[1]) / nrm2
5113  *                     else:
5114  */
5115                 /*else*/ {
5116                   __pyx_t_21 = __pyx_v_r;
5117                   __pyx_t_18 = __pyx_v_c;
5118                   __pyx_t_17 = 0;
5119                   *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) )) = ((__pyx_v_b[0]) / __pyx_v_nrm2);
5120 
5121                   /* "dipy/align/sumsqdiff.pyx":270
5122  *                         else:
5123  *                             displacement_field[r, c, 0] = (b[0]) / nrm2
5124  *                             displacement_field[r, c, 1] = (b[1]) / nrm2             # <<<<<<<<<<<<<<
5125  *                     else:
5126  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
5127  */
5128                   __pyx_t_17 = __pyx_v_r;
5129                   __pyx_t_18 = __pyx_v_c;
5130                   __pyx_t_21 = 1;
5131                   *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) )) = ((__pyx_v_b[1]) / __pyx_v_nrm2);
5132                 }
5133                 __pyx_L22:;
5134 
5135                 /* "dipy/align/sumsqdiff.pyx":262
5136  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn
5137  *                     det = A[0] * A[2] - A[1] * A[1]
5138  *                     if(det < 1e-9):             # <<<<<<<<<<<<<<
5139  *                         nrm2 = (grad[r, c, 0] ** 2 +
5140  *                                 grad[r, c, 1] ** 2)
5141  */
5142                 goto __pyx_L21;
5143               }
5144 
5145               /* "dipy/align/sumsqdiff.pyx":272
5146  *                             displacement_field[r, c, 1] = (b[1]) / nrm2
5147  *                     else:
5148  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]             # <<<<<<<<<<<<<<
5149  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
5150  *                         _solve_2d_symmetric_positive_definite(A, y, det, d)
5151  */
5152               /*else*/ {
5153                 (__pyx_v_y[0]) = ((__pyx_v_b[0]) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[0])));
5154 
5155                 /* "dipy/align/sumsqdiff.pyx":273
5156  *                     else:
5157  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
5158  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]             # <<<<<<<<<<<<<<
5159  *                         _solve_2d_symmetric_positive_definite(A, y, det, d)
5160  *                         xx = displacement_field[r, c, 0] - d[0]
5161  */
5162                 (__pyx_v_y[1]) = ((__pyx_v_b[1]) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[1])));
5163 
5164                 /* "dipy/align/sumsqdiff.pyx":274
5165  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
5166  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
5167  *                         _solve_2d_symmetric_positive_definite(A, y, det, d)             # <<<<<<<<<<<<<<
5168  *                         xx = displacement_field[r, c, 0] - d[0]
5169  *                         yy = displacement_field[r, c, 1] - d[1]
5170  */
5171                 __pyx_f_4dipy_5align_9sumsqdiff__solve_2d_symmetric_positive_definite(__pyx_v_A, __pyx_v_y, __pyx_v_det, __pyx_v_d);
5172 
5173                 /* "dipy/align/sumsqdiff.pyx":275
5174  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
5175  *                         _solve_2d_symmetric_positive_definite(A, y, det, d)
5176  *                         xx = displacement_field[r, c, 0] - d[0]             # <<<<<<<<<<<<<<
5177  *                         yy = displacement_field[r, c, 1] - d[1]
5178  *                         displacement_field[r, c, 0] = d[0]
5179  */
5180                 __pyx_t_21 = __pyx_v_r;
5181                 __pyx_t_18 = __pyx_v_c;
5182                 __pyx_t_17 = 0;
5183                 __pyx_v_xx = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) ))) - (__pyx_v_d[0]));
5184 
5185                 /* "dipy/align/sumsqdiff.pyx":276
5186  *                         _solve_2d_symmetric_positive_definite(A, y, det, d)
5187  *                         xx = displacement_field[r, c, 0] - d[0]
5188  *                         yy = displacement_field[r, c, 1] - d[1]             # <<<<<<<<<<<<<<
5189  *                         displacement_field[r, c, 0] = d[0]
5190  *                         displacement_field[r, c, 1] = d[1]
5191  */
5192                 __pyx_t_17 = __pyx_v_r;
5193                 __pyx_t_18 = __pyx_v_c;
5194                 __pyx_t_21 = 1;
5195                 __pyx_v_yy = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) ))) - (__pyx_v_d[1]));
5196 
5197                 /* "dipy/align/sumsqdiff.pyx":277
5198  *                         xx = displacement_field[r, c, 0] - d[0]
5199  *                         yy = displacement_field[r, c, 1] - d[1]
5200  *                         displacement_field[r, c, 0] = d[0]             # <<<<<<<<<<<<<<
5201  *                         displacement_field[r, c, 1] = d[1]
5202  *                         opt = xx * xx + yy * yy
5203  */
5204                 __pyx_t_21 = __pyx_v_r;
5205                 __pyx_t_18 = __pyx_v_c;
5206                 __pyx_t_17 = 0;
5207                 *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) )) = (__pyx_v_d[0]);
5208 
5209                 /* "dipy/align/sumsqdiff.pyx":278
5210  *                         yy = displacement_field[r, c, 1] - d[1]
5211  *                         displacement_field[r, c, 0] = d[0]
5212  *                         displacement_field[r, c, 1] = d[1]             # <<<<<<<<<<<<<<
5213  *                         opt = xx * xx + yy * yy
5214  *                         if(max_displacement < opt):
5215  */
5216                 __pyx_t_17 = __pyx_v_r;
5217                 __pyx_t_18 = __pyx_v_c;
5218                 __pyx_t_21 = 1;
5219                 *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) )) = (__pyx_v_d[1]);
5220 
5221                 /* "dipy/align/sumsqdiff.pyx":279
5222  *                         displacement_field[r, c, 0] = d[0]
5223  *                         displacement_field[r, c, 1] = d[1]
5224  *                         opt = xx * xx + yy * yy             # <<<<<<<<<<<<<<
5225  *                         if(max_displacement < opt):
5226  *                             max_displacement = opt
5227  */
5228                 __pyx_v_opt = ((__pyx_v_xx * __pyx_v_xx) + (__pyx_v_yy * __pyx_v_yy));
5229 
5230                 /* "dipy/align/sumsqdiff.pyx":280
5231  *                         displacement_field[r, c, 1] = d[1]
5232  *                         opt = xx * xx + yy * yy
5233  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
5234  *                             max_displacement = opt
5235  *     return sqrt(max_displacement)
5236  */
5237                 __pyx_t_20 = ((__pyx_v_max_displacement < __pyx_v_opt) != 0);
5238                 if (__pyx_t_20) {
5239 
5240                   /* "dipy/align/sumsqdiff.pyx":281
5241  *                         opt = xx * xx + yy * yy
5242  *                         if(max_displacement < opt):
5243  *                             max_displacement = opt             # <<<<<<<<<<<<<<
5244  *     return sqrt(max_displacement)
5245  *
5246  */
5247                   __pyx_v_max_displacement = __pyx_v_opt;
5248 
5249                   /* "dipy/align/sumsqdiff.pyx":280
5250  *                         displacement_field[r, c, 1] = d[1]
5251  *                         opt = xx * xx + yy * yy
5252  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
5253  *                             max_displacement = opt
5254  *     return sqrt(max_displacement)
5255  */
5256                 }
5257               }
5258               __pyx_L21:;
5259             }
5260             __pyx_L19:;
5261           }
5262         }
5263       }
5264 
5265       /* "dipy/align/sumsqdiff.pyx":222
5266  *     max_displacement = 0
5267  *
5268  *     with nogil:             # <<<<<<<<<<<<<<
5269  *
5270  *         for r in range(nrows):
5271  */
5272       /*finally:*/ {
5273         /*normal exit:*/{
5274           #ifdef WITH_THREAD
5275           __Pyx_FastGIL_Forget();
5276           Py_BLOCK_THREADS
5277           #endif
5278           goto __pyx_L5;
5279         }
5280         __pyx_L5:;
5281       }
5282   }
5283 
5284   /* "dipy/align/sumsqdiff.pyx":282
5285  *                         if(max_displacement < opt):
5286  *                             max_displacement = opt
5287  *     return sqrt(max_displacement)             # <<<<<<<<<<<<<<
5288  *
5289  *
5290  */
5291   __pyx_r = sqrt(__pyx_v_max_displacement);
5292   goto __pyx_L0;
5293 
5294   /* "dipy/align/sumsqdiff.pyx":163
5295  * @cython.wraparound(False)
5296  * @cython.cdivision(True)
5297  * cpdef double iterate_residual_displacement_field_ssd_2d(             # <<<<<<<<<<<<<<
5298  *                 floating[:, :] delta_field, floating[:, :] sigmasq_field,
5299  *                 floating[:, :, :] grad, floating[:, :, :] target,
5300  */
5301 
5302   /* function exit code */
5303   __pyx_L1_error:;
5304   __Pyx_XDECREF(__pyx_t_1);
5305   __Pyx_XDECREF(__pyx_t_2);
5306   __Pyx_XDECREF(__pyx_t_3);
5307   __Pyx_XDECREF(__pyx_t_4);
5308   __Pyx_WriteUnraisable("dipy.align.sumsqdiff.iterate_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
5309   __pyx_r = 0;
5310   __pyx_L0:;
5311   __Pyx_XDECREF(__pyx_v_ftype);
5312   __Pyx_RefNannyFinishContext();
5313   return __pyx_r;
5314 }
5315 
5316 /* Python wrapper */
5317 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_21__pyx_fuse_0iterate_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5318 static PyMethodDef __pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_21__pyx_fuse_0iterate_residual_displacement_field_ssd_2d = {"__pyx_fuse_0iterate_residual_displacement_field_ssd_2d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_21__pyx_fuse_0iterate_residual_displacement_field_ssd_2d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_4iterate_residual_displacement_field_ssd_2d};
__pyx_pw_4dipy_5align_9sumsqdiff_21__pyx_fuse_0iterate_residual_displacement_field_ssd_2d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)5319 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_21__pyx_fuse_0iterate_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5320   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
5321   __Pyx_memviewslice __pyx_v_sigmasq_field = { 0, 0, { 0 }, { 0 }, { 0 } };
5322   __Pyx_memviewslice __pyx_v_grad = { 0, 0, { 0 }, { 0 }, { 0 } };
5323   __Pyx_memviewslice __pyx_v_target = { 0, 0, { 0 }, { 0 }, { 0 } };
5324   double __pyx_v_lambda_param;
5325   __Pyx_memviewslice __pyx_v_displacement_field = { 0, 0, { 0 }, { 0 }, { 0 } };
5326   int __pyx_lineno = 0;
5327   const char *__pyx_filename = NULL;
5328   int __pyx_clineno = 0;
5329   PyObject *__pyx_r = 0;
5330   __Pyx_RefNannyDeclarations
5331   __Pyx_RefNannySetupContext("__pyx_fuse_0iterate_residual_displacement_field_ssd_2d (wrapper)", 0);
5332   {
5333     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_sigmasq_field,&__pyx_n_s_grad,&__pyx_n_s_target,&__pyx_n_s_lambda_param,&__pyx_n_s_displacement_field,0};
5334     PyObject* values[6] = {0,0,0,0,0,0};
5335     if (unlikely(__pyx_kwds)) {
5336       Py_ssize_t kw_args;
5337       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5338       switch (pos_args) {
5339         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
5340         CYTHON_FALLTHROUGH;
5341         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
5342         CYTHON_FALLTHROUGH;
5343         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5344         CYTHON_FALLTHROUGH;
5345         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5346         CYTHON_FALLTHROUGH;
5347         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5348         CYTHON_FALLTHROUGH;
5349         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5350         CYTHON_FALLTHROUGH;
5351         case  0: break;
5352         default: goto __pyx_L5_argtuple_error;
5353       }
5354       kw_args = PyDict_Size(__pyx_kwds);
5355       switch (pos_args) {
5356         case  0:
5357         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
5358         else goto __pyx_L5_argtuple_error;
5359         CYTHON_FALLTHROUGH;
5360         case  1:
5361         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigmasq_field)) != 0)) kw_args--;
5362         else {
5363           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_2d", 1, 6, 6, 1); __PYX_ERR(0, 163, __pyx_L3_error)
5364         }
5365         CYTHON_FALLTHROUGH;
5366         case  2:
5367         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_grad)) != 0)) kw_args--;
5368         else {
5369           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_2d", 1, 6, 6, 2); __PYX_ERR(0, 163, __pyx_L3_error)
5370         }
5371         CYTHON_FALLTHROUGH;
5372         case  3:
5373         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--;
5374         else {
5375           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_2d", 1, 6, 6, 3); __PYX_ERR(0, 163, __pyx_L3_error)
5376         }
5377         CYTHON_FALLTHROUGH;
5378         case  4:
5379         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lambda_param)) != 0)) kw_args--;
5380         else {
5381           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_2d", 1, 6, 6, 4); __PYX_ERR(0, 163, __pyx_L3_error)
5382         }
5383         CYTHON_FALLTHROUGH;
5384         case  5:
5385         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_displacement_field)) != 0)) kw_args--;
5386         else {
5387           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_2d", 1, 6, 6, 5); __PYX_ERR(0, 163, __pyx_L3_error)
5388         }
5389       }
5390       if (unlikely(kw_args > 0)) {
5391         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fuse_0iterate_residual_displacement_field_ssd_2d") < 0)) __PYX_ERR(0, 163, __pyx_L3_error)
5392       }
5393     } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
5394       goto __pyx_L5_argtuple_error;
5395     } else {
5396       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5397       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5398       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5399       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5400       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
5401       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
5402     }
5403     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 164, __pyx_L3_error)
5404     __pyx_v_sigmasq_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_sigmasq_field.memview)) __PYX_ERR(0, 164, __pyx_L3_error)
5405     __pyx_v_grad = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_grad.memview)) __PYX_ERR(0, 165, __pyx_L3_error)
5406     __pyx_v_target = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_target.memview)) __PYX_ERR(0, 165, __pyx_L3_error)
5407     __pyx_v_lambda_param = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_lambda_param == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 166, __pyx_L3_error)
5408     __pyx_v_displacement_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_displacement_field.memview)) __PYX_ERR(0, 166, __pyx_L3_error)
5409   }
5410   goto __pyx_L4_argument_unpacking_done;
5411   __pyx_L5_argtuple_error:;
5412   __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_2d", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 163, __pyx_L3_error)
5413   __pyx_L3_error:;
5414   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_0iterate_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
5415   __Pyx_RefNannyFinishContext();
5416   return NULL;
5417   __pyx_L4_argument_unpacking_done:;
5418   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_20__pyx_fuse_0iterate_residual_displacement_field_ssd_2d(__pyx_self, __pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_grad, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_displacement_field);
5419 
5420   /* function exit code */
5421   __Pyx_RefNannyFinishContext();
5422   return __pyx_r;
5423 }
5424 
__pyx_pf_4dipy_5align_9sumsqdiff_20__pyx_fuse_0iterate_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_grad,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_displacement_field)5425 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_20__pyx_fuse_0iterate_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_displacement_field) {
5426   PyObject *__pyx_r = NULL;
5427   __Pyx_RefNannyDeclarations
5428   PyObject *__pyx_t_1 = NULL;
5429   int __pyx_lineno = 0;
5430   const char *__pyx_filename = NULL;
5431   int __pyx_clineno = 0;
5432   __Pyx_RefNannySetupContext("__pyx_fuse_0iterate_residual_displacement_field_ssd_2d", 0);
5433   __Pyx_XDECREF(__pyx_r);
5434   if (unlikely(!__pyx_v_delta_field.memview)) { __Pyx_RaiseUnboundLocalError("delta_field"); __PYX_ERR(0, 163, __pyx_L1_error) }
5435   if (unlikely(!__pyx_v_sigmasq_field.memview)) { __Pyx_RaiseUnboundLocalError("sigmasq_field"); __PYX_ERR(0, 163, __pyx_L1_error) }
5436   if (unlikely(!__pyx_v_grad.memview)) { __Pyx_RaiseUnboundLocalError("grad"); __PYX_ERR(0, 163, __pyx_L1_error) }
5437   if (unlikely(!__pyx_v_target.memview)) { __Pyx_RaiseUnboundLocalError("target"); __PYX_ERR(0, 163, __pyx_L1_error) }
5438   if (unlikely(!__pyx_v_displacement_field.memview)) { __Pyx_RaiseUnboundLocalError("displacement_field"); __PYX_ERR(0, 163, __pyx_L1_error) }
5439   __pyx_t_1 = PyFloat_FromDouble(__pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_2d(__pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_grad, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_displacement_field, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
5440   __Pyx_GOTREF(__pyx_t_1);
5441   __pyx_r = __pyx_t_1;
5442   __pyx_t_1 = 0;
5443   goto __pyx_L0;
5444 
5445   /* function exit code */
5446   __pyx_L1_error:;
5447   __Pyx_XDECREF(__pyx_t_1);
5448   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_0iterate_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
5449   __pyx_r = NULL;
5450   __pyx_L0:;
5451   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
5452   __PYX_XDEC_MEMVIEW(&__pyx_v_sigmasq_field, 1);
5453   __PYX_XDEC_MEMVIEW(&__pyx_v_grad, 1);
5454   __PYX_XDEC_MEMVIEW(&__pyx_v_target, 1);
5455   __PYX_XDEC_MEMVIEW(&__pyx_v_displacement_field, 1);
5456   __Pyx_XGIVEREF(__pyx_r);
5457   __Pyx_RefNannyFinishContext();
5458   return __pyx_r;
5459 }
5460 
5461 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_23__pyx_fuse_1iterate_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5462 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_5iterate_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_grad,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_displacement_field,CYTHON_UNUSED int __pyx_skip_dispatch)5463 static double __pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_displacement_field, CYTHON_UNUSED int __pyx_skip_dispatch) {
5464   CYTHON_UNUSED PyObject *__pyx_v_ftype = NULL;
5465   int __pyx_v_NUM_NEIGHBORS;
5466   int *__pyx_v_dRow;
5467   int *__pyx_v_dCol;
5468   npy_intp __pyx_v_nrows;
5469   npy_intp __pyx_v_ncols;
5470   npy_intp __pyx_v_r;
5471   npy_intp __pyx_v_c;
5472   npy_intp __pyx_v_dr;
5473   npy_intp __pyx_v_dc;
5474   npy_intp __pyx_v_nn;
5475   npy_intp __pyx_v_k;
5476   double *__pyx_v_b;
5477   double *__pyx_v_d;
5478   double *__pyx_v_y;
5479   double *__pyx_v_A;
5480   double __pyx_v_xx;
5481   double __pyx_v_yy;
5482   double __pyx_v_opt;
5483   double __pyx_v_nrm2;
5484   CYTHON_UNUSED double __pyx_v_delta;
5485   double __pyx_v_sigmasq;
5486   double __pyx_v_max_displacement;
5487   double __pyx_v_det;
5488   double __pyx_r;
5489   __Pyx_RefNannyDeclarations
5490   PyObject *__pyx_t_1 = NULL;
5491   PyObject *__pyx_t_2 = NULL;
5492   PyObject *__pyx_t_3 = NULL;
5493   PyObject *__pyx_t_4 = NULL;
5494   int __pyx_t_5[4];
5495   int __pyx_t_6[4];
5496   double __pyx_t_7[2];
5497   double __pyx_t_8[2];
5498   double __pyx_t_9[2];
5499   double __pyx_t_10[3];
5500   npy_intp __pyx_t_11;
5501   npy_intp __pyx_t_12;
5502   npy_intp __pyx_t_13;
5503   npy_intp __pyx_t_14;
5504   npy_intp __pyx_t_15;
5505   npy_intp __pyx_t_16;
5506   Py_ssize_t __pyx_t_17;
5507   Py_ssize_t __pyx_t_18;
5508   double __pyx_t_19;
5509   int __pyx_t_20;
5510   Py_ssize_t __pyx_t_21;
5511   Py_ssize_t __pyx_t_22;
5512   Py_ssize_t __pyx_t_23;
5513   int __pyx_t_24;
5514   int __pyx_t_25;
5515   npy_intp __pyx_t_26;
5516   int __pyx_t_27;
5517   long __pyx_t_28;
5518   Py_ssize_t __pyx_t_29;
5519   int __pyx_lineno = 0;
5520   const char *__pyx_filename = NULL;
5521   int __pyx_clineno = 0;
5522   __Pyx_RefNannySetupContext("__pyx_fuse_1iterate_residual_displacement_field_ssd_2d", 0);
5523 
5524   /* "dipy/align/sumsqdiff.pyx":204
5525  *               Vision, 2005. ICCV 2005.
5526  *     """
5527  *     ftype = np.asarray(delta_field).dtype             # <<<<<<<<<<<<<<
5528  *     cdef:
5529  *         int NUM_NEIGHBORS = 4
5530  */
5531   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
5532   __Pyx_GOTREF(__pyx_t_2);
5533   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
5534   __Pyx_GOTREF(__pyx_t_3);
5535   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5536   __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
5537   __Pyx_GOTREF(__pyx_t_2);
5538   __pyx_t_4 = NULL;
5539   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
5540     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
5541     if (likely(__pyx_t_4)) {
5542       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5543       __Pyx_INCREF(__pyx_t_4);
5544       __Pyx_INCREF(function);
5545       __Pyx_DECREF_SET(__pyx_t_3, function);
5546     }
5547   }
5548   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
5549   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5550   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5551   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
5552   __Pyx_GOTREF(__pyx_t_1);
5553   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5554   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
5555   __Pyx_GOTREF(__pyx_t_3);
5556   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5557   __pyx_v_ftype = __pyx_t_3;
5558   __pyx_t_3 = 0;
5559 
5560   /* "dipy/align/sumsqdiff.pyx":206
5561  *     ftype = np.asarray(delta_field).dtype
5562  *     cdef:
5563  *         int NUM_NEIGHBORS = 4             # <<<<<<<<<<<<<<
5564  *         int* dRow = [-1, 0, 1,  0]
5565  *         int* dCol = [0, 1, 0, -1]
5566  */
5567   __pyx_v_NUM_NEIGHBORS = 4;
5568 
5569   /* "dipy/align/sumsqdiff.pyx":207
5570  *     cdef:
5571  *         int NUM_NEIGHBORS = 4
5572  *         int* dRow = [-1, 0, 1,  0]             # <<<<<<<<<<<<<<
5573  *         int* dCol = [0, 1, 0, -1]
5574  *         cnp.npy_intp nrows = delta_field.shape[0]
5575  */
5576   __pyx_t_5[0] = -1;
5577   __pyx_t_5[1] = 0;
5578   __pyx_t_5[2] = 1;
5579   __pyx_t_5[3] = 0;
5580   __pyx_v_dRow = __pyx_t_5;
5581 
5582   /* "dipy/align/sumsqdiff.pyx":208
5583  *         int NUM_NEIGHBORS = 4
5584  *         int* dRow = [-1, 0, 1,  0]
5585  *         int* dCol = [0, 1, 0, -1]             # <<<<<<<<<<<<<<
5586  *         cnp.npy_intp nrows = delta_field.shape[0]
5587  *         cnp.npy_intp ncols = delta_field.shape[1]
5588  */
5589   __pyx_t_6[0] = 0;
5590   __pyx_t_6[1] = 1;
5591   __pyx_t_6[2] = 0;
5592   __pyx_t_6[3] = -1;
5593   __pyx_v_dCol = __pyx_t_6;
5594 
5595   /* "dipy/align/sumsqdiff.pyx":209
5596  *         int* dRow = [-1, 0, 1,  0]
5597  *         int* dCol = [0, 1, 0, -1]
5598  *         cnp.npy_intp nrows = delta_field.shape[0]             # <<<<<<<<<<<<<<
5599  *         cnp.npy_intp ncols = delta_field.shape[1]
5600  *         cnp.npy_intp r, c, dr, dc, nn, k
5601  */
5602   __pyx_v_nrows = (__pyx_v_delta_field.shape[0]);
5603 
5604   /* "dipy/align/sumsqdiff.pyx":210
5605  *         int* dCol = [0, 1, 0, -1]
5606  *         cnp.npy_intp nrows = delta_field.shape[0]
5607  *         cnp.npy_intp ncols = delta_field.shape[1]             # <<<<<<<<<<<<<<
5608  *         cnp.npy_intp r, c, dr, dc, nn, k
5609  *
5610  */
5611   __pyx_v_ncols = (__pyx_v_delta_field.shape[1]);
5612 
5613   /* "dipy/align/sumsqdiff.pyx":213
5614  *         cnp.npy_intp r, c, dr, dc, nn, k
5615  *
5616  *         double* b = [0, 0]             # <<<<<<<<<<<<<<
5617  *         double* d = [0, 0]
5618  *         double* y = [0, 0]
5619  */
5620   __pyx_t_7[0] = 0.0;
5621   __pyx_t_7[1] = 0.0;
5622   __pyx_v_b = __pyx_t_7;
5623 
5624   /* "dipy/align/sumsqdiff.pyx":214
5625  *
5626  *         double* b = [0, 0]
5627  *         double* d = [0, 0]             # <<<<<<<<<<<<<<
5628  *         double* y = [0, 0]
5629  *         double* A = [0, 0, 0]
5630  */
5631   __pyx_t_8[0] = 0.0;
5632   __pyx_t_8[1] = 0.0;
5633   __pyx_v_d = __pyx_t_8;
5634 
5635   /* "dipy/align/sumsqdiff.pyx":215
5636  *         double* b = [0, 0]
5637  *         double* d = [0, 0]
5638  *         double* y = [0, 0]             # <<<<<<<<<<<<<<
5639  *         double* A = [0, 0, 0]
5640  *
5641  */
5642   __pyx_t_9[0] = 0.0;
5643   __pyx_t_9[1] = 0.0;
5644   __pyx_v_y = __pyx_t_9;
5645 
5646   /* "dipy/align/sumsqdiff.pyx":216
5647  *         double* d = [0, 0]
5648  *         double* y = [0, 0]
5649  *         double* A = [0, 0, 0]             # <<<<<<<<<<<<<<
5650  *
5651  *         double xx, yy, opt, nrm2, delta, sigmasq, max_displacement, det
5652  */
5653   __pyx_t_10[0] = 0.0;
5654   __pyx_t_10[1] = 0.0;
5655   __pyx_t_10[2] = 0.0;
5656   __pyx_v_A = __pyx_t_10;
5657 
5658   /* "dipy/align/sumsqdiff.pyx":220
5659  *         double xx, yy, opt, nrm2, delta, sigmasq, max_displacement, det
5660  *
5661  *     max_displacement = 0             # <<<<<<<<<<<<<<
5662  *
5663  *     with nogil:
5664  */
5665   __pyx_v_max_displacement = 0.0;
5666 
5667   /* "dipy/align/sumsqdiff.pyx":222
5668  *     max_displacement = 0
5669  *
5670  *     with nogil:             # <<<<<<<<<<<<<<
5671  *
5672  *         for r in range(nrows):
5673  */
5674   {
5675       #ifdef WITH_THREAD
5676       PyThreadState *_save;
5677       Py_UNBLOCK_THREADS
5678       __Pyx_FastGIL_Remember();
5679       #endif
5680       /*try:*/ {
5681 
5682         /* "dipy/align/sumsqdiff.pyx":224
5683  *     with nogil:
5684  *
5685  *         for r in range(nrows):             # <<<<<<<<<<<<<<
5686  *             for c in range(ncols):
5687  *                 delta = delta_field[r, c]
5688  */
5689         __pyx_t_11 = __pyx_v_nrows;
5690         __pyx_t_12 = __pyx_t_11;
5691         for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
5692           __pyx_v_r = __pyx_t_13;
5693 
5694           /* "dipy/align/sumsqdiff.pyx":225
5695  *
5696  *         for r in range(nrows):
5697  *             for c in range(ncols):             # <<<<<<<<<<<<<<
5698  *                 delta = delta_field[r, c]
5699  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
5700  */
5701           __pyx_t_14 = __pyx_v_ncols;
5702           __pyx_t_15 = __pyx_t_14;
5703           for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
5704             __pyx_v_c = __pyx_t_16;
5705 
5706             /* "dipy/align/sumsqdiff.pyx":226
5707  *         for r in range(nrows):
5708  *             for c in range(ncols):
5709  *                 delta = delta_field[r, c]             # <<<<<<<<<<<<<<
5710  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
5711  *                 if(target is None):
5712  */
5713             __pyx_t_17 = __pyx_v_r;
5714             __pyx_t_18 = __pyx_v_c;
5715             __pyx_v_delta = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_17 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_18 * __pyx_v_delta_field.strides[1]) )));
5716 
5717             /* "dipy/align/sumsqdiff.pyx":227
5718  *             for c in range(ncols):
5719  *                 delta = delta_field[r, c]
5720  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1             # <<<<<<<<<<<<<<
5721  *                 if(target is None):
5722  *                     b[0] = delta_field[r, c] * grad[r, c, 0]
5723  */
5724             if (((((PyObject *) __pyx_v_sigmasq_field.memview) != Py_None) != 0)) {
5725               __pyx_t_18 = __pyx_v_r;
5726               __pyx_t_17 = __pyx_v_c;
5727               __pyx_t_19 = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_sigmasq_field.data + __pyx_t_18 * __pyx_v_sigmasq_field.strides[0]) ) + __pyx_t_17 * __pyx_v_sigmasq_field.strides[1]) )));
5728             } else {
5729               __pyx_t_19 = 1.0;
5730             }
5731             __pyx_v_sigmasq = __pyx_t_19;
5732 
5733             /* "dipy/align/sumsqdiff.pyx":228
5734  *                 delta = delta_field[r, c]
5735  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
5736  *                 if(target is None):             # <<<<<<<<<<<<<<
5737  *                     b[0] = delta_field[r, c] * grad[r, c, 0]
5738  *                     b[1] = delta_field[r, c] * grad[r, c, 1]
5739  */
5740             __pyx_t_20 = ((((PyObject *) __pyx_v_target.memview) == Py_None) != 0);
5741             if (__pyx_t_20) {
5742 
5743               /* "dipy/align/sumsqdiff.pyx":229
5744  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
5745  *                 if(target is None):
5746  *                     b[0] = delta_field[r, c] * grad[r, c, 0]             # <<<<<<<<<<<<<<
5747  *                     b[1] = delta_field[r, c] * grad[r, c, 1]
5748  *                 else:
5749  */
5750               __pyx_t_17 = __pyx_v_r;
5751               __pyx_t_18 = __pyx_v_c;
5752               __pyx_t_21 = __pyx_v_r;
5753               __pyx_t_22 = __pyx_v_c;
5754               __pyx_t_23 = 0;
5755               (__pyx_v_b[0]) = ((*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_17 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_18 * __pyx_v_delta_field.strides[1]) ))) * (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_21 * __pyx_v_grad.strides[0]) ) + __pyx_t_22 * __pyx_v_grad.strides[1]) ) + __pyx_t_23 * __pyx_v_grad.strides[2]) ))));
5756 
5757               /* "dipy/align/sumsqdiff.pyx":230
5758  *                 if(target is None):
5759  *                     b[0] = delta_field[r, c] * grad[r, c, 0]
5760  *                     b[1] = delta_field[r, c] * grad[r, c, 1]             # <<<<<<<<<<<<<<
5761  *                 else:
5762  *                     b[0] = target[r, c, 0]
5763  */
5764               __pyx_t_23 = __pyx_v_r;
5765               __pyx_t_22 = __pyx_v_c;
5766               __pyx_t_21 = __pyx_v_r;
5767               __pyx_t_18 = __pyx_v_c;
5768               __pyx_t_17 = 1;
5769               (__pyx_v_b[1]) = ((*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_23 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_22 * __pyx_v_delta_field.strides[1]) ))) * (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_21 * __pyx_v_grad.strides[0]) ) + __pyx_t_18 * __pyx_v_grad.strides[1]) ) + __pyx_t_17 * __pyx_v_grad.strides[2]) ))));
5770 
5771               /* "dipy/align/sumsqdiff.pyx":228
5772  *                 delta = delta_field[r, c]
5773  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
5774  *                 if(target is None):             # <<<<<<<<<<<<<<
5775  *                     b[0] = delta_field[r, c] * grad[r, c, 0]
5776  *                     b[1] = delta_field[r, c] * grad[r, c, 1]
5777  */
5778               goto __pyx_L10;
5779             }
5780 
5781             /* "dipy/align/sumsqdiff.pyx":232
5782  *                     b[1] = delta_field[r, c] * grad[r, c, 1]
5783  *                 else:
5784  *                     b[0] = target[r, c, 0]             # <<<<<<<<<<<<<<
5785  *                     b[1] = target[r, c, 1]
5786  *                 nn = 0
5787  */
5788             /*else*/ {
5789               __pyx_t_17 = __pyx_v_r;
5790               __pyx_t_18 = __pyx_v_c;
5791               __pyx_t_21 = 0;
5792               (__pyx_v_b[0]) = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_17 * __pyx_v_target.strides[0]) ) + __pyx_t_18 * __pyx_v_target.strides[1]) ) + __pyx_t_21 * __pyx_v_target.strides[2]) )));
5793 
5794               /* "dipy/align/sumsqdiff.pyx":233
5795  *                 else:
5796  *                     b[0] = target[r, c, 0]
5797  *                     b[1] = target[r, c, 1]             # <<<<<<<<<<<<<<
5798  *                 nn = 0
5799  *                 y[0] = 0
5800  */
5801               __pyx_t_21 = __pyx_v_r;
5802               __pyx_t_18 = __pyx_v_c;
5803               __pyx_t_17 = 1;
5804               (__pyx_v_b[1]) = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_21 * __pyx_v_target.strides[0]) ) + __pyx_t_18 * __pyx_v_target.strides[1]) ) + __pyx_t_17 * __pyx_v_target.strides[2]) )));
5805             }
5806             __pyx_L10:;
5807 
5808             /* "dipy/align/sumsqdiff.pyx":234
5809  *                     b[0] = target[r, c, 0]
5810  *                     b[1] = target[r, c, 1]
5811  *                 nn = 0             # <<<<<<<<<<<<<<
5812  *                 y[0] = 0
5813  *                 y[1] = 0
5814  */
5815             __pyx_v_nn = 0;
5816 
5817             /* "dipy/align/sumsqdiff.pyx":235
5818  *                     b[1] = target[r, c, 1]
5819  *                 nn = 0
5820  *                 y[0] = 0             # <<<<<<<<<<<<<<
5821  *                 y[1] = 0
5822  *                 for k in range(NUM_NEIGHBORS):
5823  */
5824             (__pyx_v_y[0]) = 0.0;
5825 
5826             /* "dipy/align/sumsqdiff.pyx":236
5827  *                 nn = 0
5828  *                 y[0] = 0
5829  *                 y[1] = 0             # <<<<<<<<<<<<<<
5830  *                 for k in range(NUM_NEIGHBORS):
5831  *                     dr = r + dRow[k]
5832  */
5833             (__pyx_v_y[1]) = 0.0;
5834 
5835             /* "dipy/align/sumsqdiff.pyx":237
5836  *                 y[0] = 0
5837  *                 y[1] = 0
5838  *                 for k in range(NUM_NEIGHBORS):             # <<<<<<<<<<<<<<
5839  *                     dr = r + dRow[k]
5840  *                     if((dr < 0) or (dr >= nrows)):
5841  */
5842             __pyx_t_24 = __pyx_v_NUM_NEIGHBORS;
5843             __pyx_t_25 = __pyx_t_24;
5844             for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_25; __pyx_t_26+=1) {
5845               __pyx_v_k = __pyx_t_26;
5846 
5847               /* "dipy/align/sumsqdiff.pyx":238
5848  *                 y[1] = 0
5849  *                 for k in range(NUM_NEIGHBORS):
5850  *                     dr = r + dRow[k]             # <<<<<<<<<<<<<<
5851  *                     if((dr < 0) or (dr >= nrows)):
5852  *                         continue
5853  */
5854               __pyx_v_dr = (__pyx_v_r + (__pyx_v_dRow[__pyx_v_k]));
5855 
5856               /* "dipy/align/sumsqdiff.pyx":239
5857  *                 for k in range(NUM_NEIGHBORS):
5858  *                     dr = r + dRow[k]
5859  *                     if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
5860  *                         continue
5861  *                     dc = c + dCol[k]
5862  */
5863               __pyx_t_27 = ((__pyx_v_dr < 0) != 0);
5864               if (!__pyx_t_27) {
5865               } else {
5866                 __pyx_t_20 = __pyx_t_27;
5867                 goto __pyx_L14_bool_binop_done;
5868               }
5869               __pyx_t_27 = ((__pyx_v_dr >= __pyx_v_nrows) != 0);
5870               __pyx_t_20 = __pyx_t_27;
5871               __pyx_L14_bool_binop_done:;
5872               if (__pyx_t_20) {
5873 
5874                 /* "dipy/align/sumsqdiff.pyx":240
5875  *                     dr = r + dRow[k]
5876  *                     if((dr < 0) or (dr >= nrows)):
5877  *                         continue             # <<<<<<<<<<<<<<
5878  *                     dc = c + dCol[k]
5879  *                     if((dc < 0) or (dc >= ncols)):
5880  */
5881                 goto __pyx_L11_continue;
5882 
5883                 /* "dipy/align/sumsqdiff.pyx":239
5884  *                 for k in range(NUM_NEIGHBORS):
5885  *                     dr = r + dRow[k]
5886  *                     if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
5887  *                         continue
5888  *                     dc = c + dCol[k]
5889  */
5890               }
5891 
5892               /* "dipy/align/sumsqdiff.pyx":241
5893  *                     if((dr < 0) or (dr >= nrows)):
5894  *                         continue
5895  *                     dc = c + dCol[k]             # <<<<<<<<<<<<<<
5896  *                     if((dc < 0) or (dc >= ncols)):
5897  *                         continue
5898  */
5899               __pyx_v_dc = (__pyx_v_c + (__pyx_v_dCol[__pyx_v_k]));
5900 
5901               /* "dipy/align/sumsqdiff.pyx":242
5902  *                         continue
5903  *                     dc = c + dCol[k]
5904  *                     if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
5905  *                         continue
5906  *                     nn += 1
5907  */
5908               __pyx_t_27 = ((__pyx_v_dc < 0) != 0);
5909               if (!__pyx_t_27) {
5910               } else {
5911                 __pyx_t_20 = __pyx_t_27;
5912                 goto __pyx_L17_bool_binop_done;
5913               }
5914               __pyx_t_27 = ((__pyx_v_dc >= __pyx_v_ncols) != 0);
5915               __pyx_t_20 = __pyx_t_27;
5916               __pyx_L17_bool_binop_done:;
5917               if (__pyx_t_20) {
5918 
5919                 /* "dipy/align/sumsqdiff.pyx":243
5920  *                     dc = c + dCol[k]
5921  *                     if((dc < 0) or (dc >= ncols)):
5922  *                         continue             # <<<<<<<<<<<<<<
5923  *                     nn += 1
5924  *                     y[0] += displacement_field[dr, dc, 0]
5925  */
5926                 goto __pyx_L11_continue;
5927 
5928                 /* "dipy/align/sumsqdiff.pyx":242
5929  *                         continue
5930  *                     dc = c + dCol[k]
5931  *                     if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
5932  *                         continue
5933  *                     nn += 1
5934  */
5935               }
5936 
5937               /* "dipy/align/sumsqdiff.pyx":244
5938  *                     if((dc < 0) or (dc >= ncols)):
5939  *                         continue
5940  *                     nn += 1             # <<<<<<<<<<<<<<
5941  *                     y[0] += displacement_field[dr, dc, 0]
5942  *                     y[1] += displacement_field[dr, dc, 1]
5943  */
5944               __pyx_v_nn = (__pyx_v_nn + 1);
5945 
5946               /* "dipy/align/sumsqdiff.pyx":245
5947  *                         continue
5948  *                     nn += 1
5949  *                     y[0] += displacement_field[dr, dc, 0]             # <<<<<<<<<<<<<<
5950  *                     y[1] += displacement_field[dr, dc, 1]
5951  *                 if dpy_isinf(sigmasq) != 0:
5952  */
5953               __pyx_t_28 = 0;
5954               __pyx_t_17 = __pyx_v_dr;
5955               __pyx_t_18 = __pyx_v_dc;
5956               __pyx_t_21 = 0;
5957               (__pyx_v_y[__pyx_t_28]) = ((__pyx_v_y[__pyx_t_28]) + (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) ))));
5958 
5959               /* "dipy/align/sumsqdiff.pyx":246
5960  *                     nn += 1
5961  *                     y[0] += displacement_field[dr, dc, 0]
5962  *                     y[1] += displacement_field[dr, dc, 1]             # <<<<<<<<<<<<<<
5963  *                 if dpy_isinf(sigmasq) != 0:
5964  *                     xx = displacement_field[r, c, 0]
5965  */
5966               __pyx_t_28 = 1;
5967               __pyx_t_21 = __pyx_v_dr;
5968               __pyx_t_18 = __pyx_v_dc;
5969               __pyx_t_17 = 1;
5970               (__pyx_v_y[__pyx_t_28]) = ((__pyx_v_y[__pyx_t_28]) + (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) ))));
5971               __pyx_L11_continue:;
5972             }
5973 
5974             /* "dipy/align/sumsqdiff.pyx":247
5975  *                     y[0] += displacement_field[dr, dc, 0]
5976  *                     y[1] += displacement_field[dr, dc, 1]
5977  *                 if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
5978  *                     xx = displacement_field[r, c, 0]
5979  *                     yy = displacement_field[r, c, 1]
5980  */
5981             __pyx_t_20 = ((dpy_isinf(__pyx_v_sigmasq) != 0) != 0);
5982             if (__pyx_t_20) {
5983 
5984               /* "dipy/align/sumsqdiff.pyx":248
5985  *                     y[1] += displacement_field[dr, dc, 1]
5986  *                 if dpy_isinf(sigmasq) != 0:
5987  *                     xx = displacement_field[r, c, 0]             # <<<<<<<<<<<<<<
5988  *                     yy = displacement_field[r, c, 1]
5989  *                     displacement_field[r, c, 0] = y[0] / nn
5990  */
5991               __pyx_t_17 = __pyx_v_r;
5992               __pyx_t_18 = __pyx_v_c;
5993               __pyx_t_21 = 0;
5994               __pyx_v_xx = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) )));
5995 
5996               /* "dipy/align/sumsqdiff.pyx":249
5997  *                 if dpy_isinf(sigmasq) != 0:
5998  *                     xx = displacement_field[r, c, 0]
5999  *                     yy = displacement_field[r, c, 1]             # <<<<<<<<<<<<<<
6000  *                     displacement_field[r, c, 0] = y[0] / nn
6001  *                     displacement_field[r, c, 1] = y[1] / nn
6002  */
6003               __pyx_t_21 = __pyx_v_r;
6004               __pyx_t_18 = __pyx_v_c;
6005               __pyx_t_17 = 1;
6006               __pyx_v_yy = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) )));
6007 
6008               /* "dipy/align/sumsqdiff.pyx":250
6009  *                     xx = displacement_field[r, c, 0]
6010  *                     yy = displacement_field[r, c, 1]
6011  *                     displacement_field[r, c, 0] = y[0] / nn             # <<<<<<<<<<<<<<
6012  *                     displacement_field[r, c, 1] = y[1] / nn
6013  *                     xx -= displacement_field[r, c, 0]
6014  */
6015               __pyx_t_17 = __pyx_v_r;
6016               __pyx_t_18 = __pyx_v_c;
6017               __pyx_t_21 = 0;
6018               *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) )) = ((__pyx_v_y[0]) / ((double)__pyx_v_nn));
6019 
6020               /* "dipy/align/sumsqdiff.pyx":251
6021  *                     yy = displacement_field[r, c, 1]
6022  *                     displacement_field[r, c, 0] = y[0] / nn
6023  *                     displacement_field[r, c, 1] = y[1] / nn             # <<<<<<<<<<<<<<
6024  *                     xx -= displacement_field[r, c, 0]
6025  *                     yy -= displacement_field[r, c, 1]
6026  */
6027               __pyx_t_21 = __pyx_v_r;
6028               __pyx_t_18 = __pyx_v_c;
6029               __pyx_t_17 = 1;
6030               *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) )) = ((__pyx_v_y[1]) / ((double)__pyx_v_nn));
6031 
6032               /* "dipy/align/sumsqdiff.pyx":252
6033  *                     displacement_field[r, c, 0] = y[0] / nn
6034  *                     displacement_field[r, c, 1] = y[1] / nn
6035  *                     xx -= displacement_field[r, c, 0]             # <<<<<<<<<<<<<<
6036  *                     yy -= displacement_field[r, c, 1]
6037  *                     opt = xx * xx + yy * yy
6038  */
6039               __pyx_t_17 = __pyx_v_r;
6040               __pyx_t_18 = __pyx_v_c;
6041               __pyx_t_21 = 0;
6042               __pyx_v_xx = (__pyx_v_xx - (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) ))));
6043 
6044               /* "dipy/align/sumsqdiff.pyx":253
6045  *                     displacement_field[r, c, 1] = y[1] / nn
6046  *                     xx -= displacement_field[r, c, 0]
6047  *                     yy -= displacement_field[r, c, 1]             # <<<<<<<<<<<<<<
6048  *                     opt = xx * xx + yy * yy
6049  *                     if(max_displacement < opt):
6050  */
6051               __pyx_t_21 = __pyx_v_r;
6052               __pyx_t_18 = __pyx_v_c;
6053               __pyx_t_17 = 1;
6054               __pyx_v_yy = (__pyx_v_yy - (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) ))));
6055 
6056               /* "dipy/align/sumsqdiff.pyx":254
6057  *                     xx -= displacement_field[r, c, 0]
6058  *                     yy -= displacement_field[r, c, 1]
6059  *                     opt = xx * xx + yy * yy             # <<<<<<<<<<<<<<
6060  *                     if(max_displacement < opt):
6061  *                         max_displacement = opt
6062  */
6063               __pyx_v_opt = ((__pyx_v_xx * __pyx_v_xx) + (__pyx_v_yy * __pyx_v_yy));
6064 
6065               /* "dipy/align/sumsqdiff.pyx":255
6066  *                     yy -= displacement_field[r, c, 1]
6067  *                     opt = xx * xx + yy * yy
6068  *                     if(max_displacement < opt):             # <<<<<<<<<<<<<<
6069  *                         max_displacement = opt
6070  *                 else:
6071  */
6072               __pyx_t_20 = ((__pyx_v_max_displacement < __pyx_v_opt) != 0);
6073               if (__pyx_t_20) {
6074 
6075                 /* "dipy/align/sumsqdiff.pyx":256
6076  *                     opt = xx * xx + yy * yy
6077  *                     if(max_displacement < opt):
6078  *                         max_displacement = opt             # <<<<<<<<<<<<<<
6079  *                 else:
6080  *                     A[0] = grad[r, c, 0] ** 2 + sigmasq * lambda_param * nn
6081  */
6082                 __pyx_v_max_displacement = __pyx_v_opt;
6083 
6084                 /* "dipy/align/sumsqdiff.pyx":255
6085  *                     yy -= displacement_field[r, c, 1]
6086  *                     opt = xx * xx + yy * yy
6087  *                     if(max_displacement < opt):             # <<<<<<<<<<<<<<
6088  *                         max_displacement = opt
6089  *                 else:
6090  */
6091               }
6092 
6093               /* "dipy/align/sumsqdiff.pyx":247
6094  *                     y[0] += displacement_field[dr, dc, 0]
6095  *                     y[1] += displacement_field[dr, dc, 1]
6096  *                 if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
6097  *                     xx = displacement_field[r, c, 0]
6098  *                     yy = displacement_field[r, c, 1]
6099  */
6100               goto __pyx_L19;
6101             }
6102 
6103             /* "dipy/align/sumsqdiff.pyx":258
6104  *                         max_displacement = opt
6105  *                 else:
6106  *                     A[0] = grad[r, c, 0] ** 2 + sigmasq * lambda_param * nn             # <<<<<<<<<<<<<<
6107  *                     A[1] = grad[r, c, 0] * grad[r, c, 1]
6108  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn
6109  */
6110             /*else*/ {
6111               __pyx_t_17 = __pyx_v_r;
6112               __pyx_t_18 = __pyx_v_c;
6113               __pyx_t_21 = 0;
6114               (__pyx_v_A[0]) = (pow((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_17 * __pyx_v_grad.strides[0]) ) + __pyx_t_18 * __pyx_v_grad.strides[1]) ) + __pyx_t_21 * __pyx_v_grad.strides[2]) ))), 2.0) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * __pyx_v_nn));
6115 
6116               /* "dipy/align/sumsqdiff.pyx":259
6117  *                 else:
6118  *                     A[0] = grad[r, c, 0] ** 2 + sigmasq * lambda_param * nn
6119  *                     A[1] = grad[r, c, 0] * grad[r, c, 1]             # <<<<<<<<<<<<<<
6120  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn
6121  *                     det = A[0] * A[2] - A[1] * A[1]
6122  */
6123               __pyx_t_21 = __pyx_v_r;
6124               __pyx_t_18 = __pyx_v_c;
6125               __pyx_t_17 = 0;
6126               __pyx_t_22 = __pyx_v_r;
6127               __pyx_t_23 = __pyx_v_c;
6128               __pyx_t_29 = 1;
6129               (__pyx_v_A[1]) = ((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_21 * __pyx_v_grad.strides[0]) ) + __pyx_t_18 * __pyx_v_grad.strides[1]) ) + __pyx_t_17 * __pyx_v_grad.strides[2]) ))) * (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_22 * __pyx_v_grad.strides[0]) ) + __pyx_t_23 * __pyx_v_grad.strides[1]) ) + __pyx_t_29 * __pyx_v_grad.strides[2]) ))));
6130 
6131               /* "dipy/align/sumsqdiff.pyx":260
6132  *                     A[0] = grad[r, c, 0] ** 2 + sigmasq * lambda_param * nn
6133  *                     A[1] = grad[r, c, 0] * grad[r, c, 1]
6134  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn             # <<<<<<<<<<<<<<
6135  *                     det = A[0] * A[2] - A[1] * A[1]
6136  *                     if(det < 1e-9):
6137  */
6138               __pyx_t_29 = __pyx_v_r;
6139               __pyx_t_23 = __pyx_v_c;
6140               __pyx_t_22 = 1;
6141               (__pyx_v_A[2]) = (pow((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_29 * __pyx_v_grad.strides[0]) ) + __pyx_t_23 * __pyx_v_grad.strides[1]) ) + __pyx_t_22 * __pyx_v_grad.strides[2]) ))), 2.0) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * __pyx_v_nn));
6142 
6143               /* "dipy/align/sumsqdiff.pyx":261
6144  *                     A[1] = grad[r, c, 0] * grad[r, c, 1]
6145  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn
6146  *                     det = A[0] * A[2] - A[1] * A[1]             # <<<<<<<<<<<<<<
6147  *                     if(det < 1e-9):
6148  *                         nrm2 = (grad[r, c, 0] ** 2 +
6149  */
6150               __pyx_v_det = (((__pyx_v_A[0]) * (__pyx_v_A[2])) - ((__pyx_v_A[1]) * (__pyx_v_A[1])));
6151 
6152               /* "dipy/align/sumsqdiff.pyx":262
6153  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn
6154  *                     det = A[0] * A[2] - A[1] * A[1]
6155  *                     if(det < 1e-9):             # <<<<<<<<<<<<<<
6156  *                         nrm2 = (grad[r, c, 0] ** 2 +
6157  *                                 grad[r, c, 1] ** 2)
6158  */
6159               __pyx_t_20 = ((__pyx_v_det < 1e-9) != 0);
6160               if (__pyx_t_20) {
6161 
6162                 /* "dipy/align/sumsqdiff.pyx":263
6163  *                     det = A[0] * A[2] - A[1] * A[1]
6164  *                     if(det < 1e-9):
6165  *                         nrm2 = (grad[r, c, 0] ** 2 +             # <<<<<<<<<<<<<<
6166  *                                 grad[r, c, 1] ** 2)
6167  *                         if(nrm2 < 1e-9):
6168  */
6169                 __pyx_t_22 = __pyx_v_r;
6170                 __pyx_t_23 = __pyx_v_c;
6171                 __pyx_t_29 = 0;
6172 
6173                 /* "dipy/align/sumsqdiff.pyx":264
6174  *                     if(det < 1e-9):
6175  *                         nrm2 = (grad[r, c, 0] ** 2 +
6176  *                                 grad[r, c, 1] ** 2)             # <<<<<<<<<<<<<<
6177  *                         if(nrm2 < 1e-9):
6178  *                             displacement_field[r, c, 0] = 0
6179  */
6180                 __pyx_t_17 = __pyx_v_r;
6181                 __pyx_t_18 = __pyx_v_c;
6182                 __pyx_t_21 = 1;
6183 
6184                 /* "dipy/align/sumsqdiff.pyx":263
6185  *                     det = A[0] * A[2] - A[1] * A[1]
6186  *                     if(det < 1e-9):
6187  *                         nrm2 = (grad[r, c, 0] ** 2 +             # <<<<<<<<<<<<<<
6188  *                                 grad[r, c, 1] ** 2)
6189  *                         if(nrm2 < 1e-9):
6190  */
6191                 __pyx_v_nrm2 = (pow((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_22 * __pyx_v_grad.strides[0]) ) + __pyx_t_23 * __pyx_v_grad.strides[1]) ) + __pyx_t_29 * __pyx_v_grad.strides[2]) ))), 2.0) + pow((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_17 * __pyx_v_grad.strides[0]) ) + __pyx_t_18 * __pyx_v_grad.strides[1]) ) + __pyx_t_21 * __pyx_v_grad.strides[2]) ))), 2.0));
6192 
6193                 /* "dipy/align/sumsqdiff.pyx":265
6194  *                         nrm2 = (grad[r, c, 0] ** 2 +
6195  *                                 grad[r, c, 1] ** 2)
6196  *                         if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
6197  *                             displacement_field[r, c, 0] = 0
6198  *                             displacement_field[r, c, 1] = 0
6199  */
6200                 __pyx_t_20 = ((__pyx_v_nrm2 < 1e-9) != 0);
6201                 if (__pyx_t_20) {
6202 
6203                   /* "dipy/align/sumsqdiff.pyx":266
6204  *                                 grad[r, c, 1] ** 2)
6205  *                         if(nrm2 < 1e-9):
6206  *                             displacement_field[r, c, 0] = 0             # <<<<<<<<<<<<<<
6207  *                             displacement_field[r, c, 1] = 0
6208  *                         else:
6209  */
6210                   __pyx_t_21 = __pyx_v_r;
6211                   __pyx_t_18 = __pyx_v_c;
6212                   __pyx_t_17 = 0;
6213                   *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) )) = 0.0;
6214 
6215                   /* "dipy/align/sumsqdiff.pyx":267
6216  *                         if(nrm2 < 1e-9):
6217  *                             displacement_field[r, c, 0] = 0
6218  *                             displacement_field[r, c, 1] = 0             # <<<<<<<<<<<<<<
6219  *                         else:
6220  *                             displacement_field[r, c, 0] = (b[0]) / nrm2
6221  */
6222                   __pyx_t_17 = __pyx_v_r;
6223                   __pyx_t_18 = __pyx_v_c;
6224                   __pyx_t_21 = 1;
6225                   *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) )) = 0.0;
6226 
6227                   /* "dipy/align/sumsqdiff.pyx":265
6228  *                         nrm2 = (grad[r, c, 0] ** 2 +
6229  *                                 grad[r, c, 1] ** 2)
6230  *                         if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
6231  *                             displacement_field[r, c, 0] = 0
6232  *                             displacement_field[r, c, 1] = 0
6233  */
6234                   goto __pyx_L22;
6235                 }
6236 
6237                 /* "dipy/align/sumsqdiff.pyx":269
6238  *                             displacement_field[r, c, 1] = 0
6239  *                         else:
6240  *                             displacement_field[r, c, 0] = (b[0]) / nrm2             # <<<<<<<<<<<<<<
6241  *                             displacement_field[r, c, 1] = (b[1]) / nrm2
6242  *                     else:
6243  */
6244                 /*else*/ {
6245                   __pyx_t_21 = __pyx_v_r;
6246                   __pyx_t_18 = __pyx_v_c;
6247                   __pyx_t_17 = 0;
6248                   *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) )) = ((__pyx_v_b[0]) / __pyx_v_nrm2);
6249 
6250                   /* "dipy/align/sumsqdiff.pyx":270
6251  *                         else:
6252  *                             displacement_field[r, c, 0] = (b[0]) / nrm2
6253  *                             displacement_field[r, c, 1] = (b[1]) / nrm2             # <<<<<<<<<<<<<<
6254  *                     else:
6255  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
6256  */
6257                   __pyx_t_17 = __pyx_v_r;
6258                   __pyx_t_18 = __pyx_v_c;
6259                   __pyx_t_21 = 1;
6260                   *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) )) = ((__pyx_v_b[1]) / __pyx_v_nrm2);
6261                 }
6262                 __pyx_L22:;
6263 
6264                 /* "dipy/align/sumsqdiff.pyx":262
6265  *                     A[2] = grad[r, c, 1] ** 2 + sigmasq * lambda_param * nn
6266  *                     det = A[0] * A[2] - A[1] * A[1]
6267  *                     if(det < 1e-9):             # <<<<<<<<<<<<<<
6268  *                         nrm2 = (grad[r, c, 0] ** 2 +
6269  *                                 grad[r, c, 1] ** 2)
6270  */
6271                 goto __pyx_L21;
6272               }
6273 
6274               /* "dipy/align/sumsqdiff.pyx":272
6275  *                             displacement_field[r, c, 1] = (b[1]) / nrm2
6276  *                     else:
6277  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]             # <<<<<<<<<<<<<<
6278  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
6279  *                         _solve_2d_symmetric_positive_definite(A, y, det, d)
6280  */
6281               /*else*/ {
6282                 (__pyx_v_y[0]) = ((__pyx_v_b[0]) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[0])));
6283 
6284                 /* "dipy/align/sumsqdiff.pyx":273
6285  *                     else:
6286  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
6287  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]             # <<<<<<<<<<<<<<
6288  *                         _solve_2d_symmetric_positive_definite(A, y, det, d)
6289  *                         xx = displacement_field[r, c, 0] - d[0]
6290  */
6291                 (__pyx_v_y[1]) = ((__pyx_v_b[1]) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[1])));
6292 
6293                 /* "dipy/align/sumsqdiff.pyx":274
6294  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
6295  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
6296  *                         _solve_2d_symmetric_positive_definite(A, y, det, d)             # <<<<<<<<<<<<<<
6297  *                         xx = displacement_field[r, c, 0] - d[0]
6298  *                         yy = displacement_field[r, c, 1] - d[1]
6299  */
6300                 __pyx_f_4dipy_5align_9sumsqdiff__solve_2d_symmetric_positive_definite(__pyx_v_A, __pyx_v_y, __pyx_v_det, __pyx_v_d);
6301 
6302                 /* "dipy/align/sumsqdiff.pyx":275
6303  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
6304  *                         _solve_2d_symmetric_positive_definite(A, y, det, d)
6305  *                         xx = displacement_field[r, c, 0] - d[0]             # <<<<<<<<<<<<<<
6306  *                         yy = displacement_field[r, c, 1] - d[1]
6307  *                         displacement_field[r, c, 0] = d[0]
6308  */
6309                 __pyx_t_21 = __pyx_v_r;
6310                 __pyx_t_18 = __pyx_v_c;
6311                 __pyx_t_17 = 0;
6312                 __pyx_v_xx = ((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) ))) - (__pyx_v_d[0]));
6313 
6314                 /* "dipy/align/sumsqdiff.pyx":276
6315  *                         _solve_2d_symmetric_positive_definite(A, y, det, d)
6316  *                         xx = displacement_field[r, c, 0] - d[0]
6317  *                         yy = displacement_field[r, c, 1] - d[1]             # <<<<<<<<<<<<<<
6318  *                         displacement_field[r, c, 0] = d[0]
6319  *                         displacement_field[r, c, 1] = d[1]
6320  */
6321                 __pyx_t_17 = __pyx_v_r;
6322                 __pyx_t_18 = __pyx_v_c;
6323                 __pyx_t_21 = 1;
6324                 __pyx_v_yy = ((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) ))) - (__pyx_v_d[1]));
6325 
6326                 /* "dipy/align/sumsqdiff.pyx":277
6327  *                         xx = displacement_field[r, c, 0] - d[0]
6328  *                         yy = displacement_field[r, c, 1] - d[1]
6329  *                         displacement_field[r, c, 0] = d[0]             # <<<<<<<<<<<<<<
6330  *                         displacement_field[r, c, 1] = d[1]
6331  *                         opt = xx * xx + yy * yy
6332  */
6333                 __pyx_t_21 = __pyx_v_r;
6334                 __pyx_t_18 = __pyx_v_c;
6335                 __pyx_t_17 = 0;
6336                 *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_21 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_17 * __pyx_v_displacement_field.strides[2]) )) = (__pyx_v_d[0]);
6337 
6338                 /* "dipy/align/sumsqdiff.pyx":278
6339  *                         yy = displacement_field[r, c, 1] - d[1]
6340  *                         displacement_field[r, c, 0] = d[0]
6341  *                         displacement_field[r, c, 1] = d[1]             # <<<<<<<<<<<<<<
6342  *                         opt = xx * xx + yy * yy
6343  *                         if(max_displacement < opt):
6344  */
6345                 __pyx_t_17 = __pyx_v_r;
6346                 __pyx_t_18 = __pyx_v_c;
6347                 __pyx_t_21 = 1;
6348                 *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_displacement_field.data + __pyx_t_17 * __pyx_v_displacement_field.strides[0]) ) + __pyx_t_18 * __pyx_v_displacement_field.strides[1]) ) + __pyx_t_21 * __pyx_v_displacement_field.strides[2]) )) = (__pyx_v_d[1]);
6349 
6350                 /* "dipy/align/sumsqdiff.pyx":279
6351  *                         displacement_field[r, c, 0] = d[0]
6352  *                         displacement_field[r, c, 1] = d[1]
6353  *                         opt = xx * xx + yy * yy             # <<<<<<<<<<<<<<
6354  *                         if(max_displacement < opt):
6355  *                             max_displacement = opt
6356  */
6357                 __pyx_v_opt = ((__pyx_v_xx * __pyx_v_xx) + (__pyx_v_yy * __pyx_v_yy));
6358 
6359                 /* "dipy/align/sumsqdiff.pyx":280
6360  *                         displacement_field[r, c, 1] = d[1]
6361  *                         opt = xx * xx + yy * yy
6362  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
6363  *                             max_displacement = opt
6364  *     return sqrt(max_displacement)
6365  */
6366                 __pyx_t_20 = ((__pyx_v_max_displacement < __pyx_v_opt) != 0);
6367                 if (__pyx_t_20) {
6368 
6369                   /* "dipy/align/sumsqdiff.pyx":281
6370  *                         opt = xx * xx + yy * yy
6371  *                         if(max_displacement < opt):
6372  *                             max_displacement = opt             # <<<<<<<<<<<<<<
6373  *     return sqrt(max_displacement)
6374  *
6375  */
6376                   __pyx_v_max_displacement = __pyx_v_opt;
6377 
6378                   /* "dipy/align/sumsqdiff.pyx":280
6379  *                         displacement_field[r, c, 1] = d[1]
6380  *                         opt = xx * xx + yy * yy
6381  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
6382  *                             max_displacement = opt
6383  *     return sqrt(max_displacement)
6384  */
6385                 }
6386               }
6387               __pyx_L21:;
6388             }
6389             __pyx_L19:;
6390           }
6391         }
6392       }
6393 
6394       /* "dipy/align/sumsqdiff.pyx":222
6395  *     max_displacement = 0
6396  *
6397  *     with nogil:             # <<<<<<<<<<<<<<
6398  *
6399  *         for r in range(nrows):
6400  */
6401       /*finally:*/ {
6402         /*normal exit:*/{
6403           #ifdef WITH_THREAD
6404           __Pyx_FastGIL_Forget();
6405           Py_BLOCK_THREADS
6406           #endif
6407           goto __pyx_L5;
6408         }
6409         __pyx_L5:;
6410       }
6411   }
6412 
6413   /* "dipy/align/sumsqdiff.pyx":282
6414  *                         if(max_displacement < opt):
6415  *                             max_displacement = opt
6416  *     return sqrt(max_displacement)             # <<<<<<<<<<<<<<
6417  *
6418  *
6419  */
6420   __pyx_r = sqrt(__pyx_v_max_displacement);
6421   goto __pyx_L0;
6422 
6423   /* "dipy/align/sumsqdiff.pyx":163
6424  * @cython.wraparound(False)
6425  * @cython.cdivision(True)
6426  * cpdef double iterate_residual_displacement_field_ssd_2d(             # <<<<<<<<<<<<<<
6427  *                 floating[:, :] delta_field, floating[:, :] sigmasq_field,
6428  *                 floating[:, :, :] grad, floating[:, :, :] target,
6429  */
6430 
6431   /* function exit code */
6432   __pyx_L1_error:;
6433   __Pyx_XDECREF(__pyx_t_1);
6434   __Pyx_XDECREF(__pyx_t_2);
6435   __Pyx_XDECREF(__pyx_t_3);
6436   __Pyx_XDECREF(__pyx_t_4);
6437   __Pyx_WriteUnraisable("dipy.align.sumsqdiff.iterate_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
6438   __pyx_r = 0;
6439   __pyx_L0:;
6440   __Pyx_XDECREF(__pyx_v_ftype);
6441   __Pyx_RefNannyFinishContext();
6442   return __pyx_r;
6443 }
6444 
6445 /* Python wrapper */
6446 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_23__pyx_fuse_1iterate_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6447 static PyMethodDef __pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_23__pyx_fuse_1iterate_residual_displacement_field_ssd_2d = {"__pyx_fuse_1iterate_residual_displacement_field_ssd_2d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_23__pyx_fuse_1iterate_residual_displacement_field_ssd_2d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_4iterate_residual_displacement_field_ssd_2d};
__pyx_pw_4dipy_5align_9sumsqdiff_23__pyx_fuse_1iterate_residual_displacement_field_ssd_2d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6448 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_23__pyx_fuse_1iterate_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6449   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
6450   __Pyx_memviewslice __pyx_v_sigmasq_field = { 0, 0, { 0 }, { 0 }, { 0 } };
6451   __Pyx_memviewslice __pyx_v_grad = { 0, 0, { 0 }, { 0 }, { 0 } };
6452   __Pyx_memviewslice __pyx_v_target = { 0, 0, { 0 }, { 0 }, { 0 } };
6453   double __pyx_v_lambda_param;
6454   __Pyx_memviewslice __pyx_v_displacement_field = { 0, 0, { 0 }, { 0 }, { 0 } };
6455   int __pyx_lineno = 0;
6456   const char *__pyx_filename = NULL;
6457   int __pyx_clineno = 0;
6458   PyObject *__pyx_r = 0;
6459   __Pyx_RefNannyDeclarations
6460   __Pyx_RefNannySetupContext("__pyx_fuse_1iterate_residual_displacement_field_ssd_2d (wrapper)", 0);
6461   {
6462     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_sigmasq_field,&__pyx_n_s_grad,&__pyx_n_s_target,&__pyx_n_s_lambda_param,&__pyx_n_s_displacement_field,0};
6463     PyObject* values[6] = {0,0,0,0,0,0};
6464     if (unlikely(__pyx_kwds)) {
6465       Py_ssize_t kw_args;
6466       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6467       switch (pos_args) {
6468         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
6469         CYTHON_FALLTHROUGH;
6470         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
6471         CYTHON_FALLTHROUGH;
6472         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6473         CYTHON_FALLTHROUGH;
6474         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6475         CYTHON_FALLTHROUGH;
6476         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6477         CYTHON_FALLTHROUGH;
6478         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6479         CYTHON_FALLTHROUGH;
6480         case  0: break;
6481         default: goto __pyx_L5_argtuple_error;
6482       }
6483       kw_args = PyDict_Size(__pyx_kwds);
6484       switch (pos_args) {
6485         case  0:
6486         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
6487         else goto __pyx_L5_argtuple_error;
6488         CYTHON_FALLTHROUGH;
6489         case  1:
6490         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigmasq_field)) != 0)) kw_args--;
6491         else {
6492           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_2d", 1, 6, 6, 1); __PYX_ERR(0, 163, __pyx_L3_error)
6493         }
6494         CYTHON_FALLTHROUGH;
6495         case  2:
6496         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_grad)) != 0)) kw_args--;
6497         else {
6498           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_2d", 1, 6, 6, 2); __PYX_ERR(0, 163, __pyx_L3_error)
6499         }
6500         CYTHON_FALLTHROUGH;
6501         case  3:
6502         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--;
6503         else {
6504           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_2d", 1, 6, 6, 3); __PYX_ERR(0, 163, __pyx_L3_error)
6505         }
6506         CYTHON_FALLTHROUGH;
6507         case  4:
6508         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lambda_param)) != 0)) kw_args--;
6509         else {
6510           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_2d", 1, 6, 6, 4); __PYX_ERR(0, 163, __pyx_L3_error)
6511         }
6512         CYTHON_FALLTHROUGH;
6513         case  5:
6514         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_displacement_field)) != 0)) kw_args--;
6515         else {
6516           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_2d", 1, 6, 6, 5); __PYX_ERR(0, 163, __pyx_L3_error)
6517         }
6518       }
6519       if (unlikely(kw_args > 0)) {
6520         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fuse_1iterate_residual_displacement_field_ssd_2d") < 0)) __PYX_ERR(0, 163, __pyx_L3_error)
6521       }
6522     } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
6523       goto __pyx_L5_argtuple_error;
6524     } else {
6525       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6526       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6527       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6528       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6529       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
6530       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
6531     }
6532     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 164, __pyx_L3_error)
6533     __pyx_v_sigmasq_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_sigmasq_field.memview)) __PYX_ERR(0, 164, __pyx_L3_error)
6534     __pyx_v_grad = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_grad.memview)) __PYX_ERR(0, 165, __pyx_L3_error)
6535     __pyx_v_target = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_target.memview)) __PYX_ERR(0, 165, __pyx_L3_error)
6536     __pyx_v_lambda_param = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_lambda_param == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 166, __pyx_L3_error)
6537     __pyx_v_displacement_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_displacement_field.memview)) __PYX_ERR(0, 166, __pyx_L3_error)
6538   }
6539   goto __pyx_L4_argument_unpacking_done;
6540   __pyx_L5_argtuple_error:;
6541   __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_2d", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 163, __pyx_L3_error)
6542   __pyx_L3_error:;
6543   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_1iterate_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
6544   __Pyx_RefNannyFinishContext();
6545   return NULL;
6546   __pyx_L4_argument_unpacking_done:;
6547   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_22__pyx_fuse_1iterate_residual_displacement_field_ssd_2d(__pyx_self, __pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_grad, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_displacement_field);
6548 
6549   /* function exit code */
6550   __Pyx_RefNannyFinishContext();
6551   return __pyx_r;
6552 }
6553 
__pyx_pf_4dipy_5align_9sumsqdiff_22__pyx_fuse_1iterate_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_grad,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_displacement_field)6554 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_22__pyx_fuse_1iterate_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_displacement_field) {
6555   PyObject *__pyx_r = NULL;
6556   __Pyx_RefNannyDeclarations
6557   PyObject *__pyx_t_1 = NULL;
6558   int __pyx_lineno = 0;
6559   const char *__pyx_filename = NULL;
6560   int __pyx_clineno = 0;
6561   __Pyx_RefNannySetupContext("__pyx_fuse_1iterate_residual_displacement_field_ssd_2d", 0);
6562   __Pyx_XDECREF(__pyx_r);
6563   if (unlikely(!__pyx_v_delta_field.memview)) { __Pyx_RaiseUnboundLocalError("delta_field"); __PYX_ERR(0, 163, __pyx_L1_error) }
6564   if (unlikely(!__pyx_v_sigmasq_field.memview)) { __Pyx_RaiseUnboundLocalError("sigmasq_field"); __PYX_ERR(0, 163, __pyx_L1_error) }
6565   if (unlikely(!__pyx_v_grad.memview)) { __Pyx_RaiseUnboundLocalError("grad"); __PYX_ERR(0, 163, __pyx_L1_error) }
6566   if (unlikely(!__pyx_v_target.memview)) { __Pyx_RaiseUnboundLocalError("target"); __PYX_ERR(0, 163, __pyx_L1_error) }
6567   if (unlikely(!__pyx_v_displacement_field.memview)) { __Pyx_RaiseUnboundLocalError("displacement_field"); __PYX_ERR(0, 163, __pyx_L1_error) }
6568   __pyx_t_1 = PyFloat_FromDouble(__pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_2d(__pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_grad, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_displacement_field, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
6569   __Pyx_GOTREF(__pyx_t_1);
6570   __pyx_r = __pyx_t_1;
6571   __pyx_t_1 = 0;
6572   goto __pyx_L0;
6573 
6574   /* function exit code */
6575   __pyx_L1_error:;
6576   __Pyx_XDECREF(__pyx_t_1);
6577   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_1iterate_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
6578   __pyx_r = NULL;
6579   __pyx_L0:;
6580   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
6581   __PYX_XDEC_MEMVIEW(&__pyx_v_sigmasq_field, 1);
6582   __PYX_XDEC_MEMVIEW(&__pyx_v_grad, 1);
6583   __PYX_XDEC_MEMVIEW(&__pyx_v_target, 1);
6584   __PYX_XDEC_MEMVIEW(&__pyx_v_displacement_field, 1);
6585   __Pyx_XGIVEREF(__pyx_r);
6586   __Pyx_RefNannyFinishContext();
6587   return __pyx_r;
6588 }
6589 
6590 /* "dipy/align/sumsqdiff.pyx":287
6591  * @cython.boundscheck(False)
6592  * @cython.wraparound(False)
6593  * cpdef double compute_energy_ssd_2d(floating[:, :] delta_field):             # <<<<<<<<<<<<<<
6594  *     r"""Sum of squared differences between two 2D images
6595  *
6596  */
6597 
6598 /* Python wrapper */
6599 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_7compute_energy_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6600 static char __pyx_doc_4dipy_5align_9sumsqdiff_6compute_energy_ssd_2d[] = "Sum of squared differences between two 2D images\n\n    Computes the Sum of Squared Differences between the static and moving image.\n    Those differences are given by delta_field\n\n    Parameters\n    ----------\n    delta_field : array, shape (R, C)\n        the difference between the static and moving image (the 'derivative\n        w.r.t. time' in the optical flow model)\n\n    Returns\n    -------\n    energy : float\n        the SSD energy at this iteration\n\n    Notes\n    -----\n    The numeric value of the energy is used only to detect convergence.\n    This function returns only the energy corresponding to the data term\n    (excluding the energy corresponding to the regularization term) because\n    the Greedy-SyN algorithm is an unconstrained gradient descent algorithm\n    in the space of diffeomorphisms: in each iteration it makes a step\n    along the negative smoothed gradient --of the data term-- and then makes\n    sure the resulting diffeomorphisms are invertible using an explicit\n    inversion algorithm. Since it is not clear how to reflect the energy\n    corresponding to this re-projection to the space of diffeomorphisms,\n    a more precise energy computation including the regularization term\n    is useless. Instead, convergence is checked considering the data-term\n    energy only and detecting oscilations in the energy profile.\n\n    ";
6601 static PyMethodDef __pyx_mdef_4dipy_5align_9sumsqdiff_7compute_energy_ssd_2d = {"compute_energy_ssd_2d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_7compute_energy_ssd_2d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_6compute_energy_ssd_2d};
__pyx_pw_4dipy_5align_9sumsqdiff_7compute_energy_ssd_2d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6602 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_7compute_energy_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6603   PyObject *__pyx_v_signatures = 0;
6604   PyObject *__pyx_v_args = 0;
6605   PyObject *__pyx_v_kwargs = 0;
6606   CYTHON_UNUSED PyObject *__pyx_v_defaults = 0;
6607   int __pyx_lineno = 0;
6608   const char *__pyx_filename = NULL;
6609   int __pyx_clineno = 0;
6610   PyObject *__pyx_r = 0;
6611   __Pyx_RefNannyDeclarations
6612   __Pyx_RefNannySetupContext("__pyx_fused_cpdef (wrapper)", 0);
6613   {
6614     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signatures,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_defaults,0};
6615     PyObject* values[4] = {0,0,0,0};
6616     if (unlikely(__pyx_kwds)) {
6617       Py_ssize_t kw_args;
6618       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6619       switch (pos_args) {
6620         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6621         CYTHON_FALLTHROUGH;
6622         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6623         CYTHON_FALLTHROUGH;
6624         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6625         CYTHON_FALLTHROUGH;
6626         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6627         CYTHON_FALLTHROUGH;
6628         case  0: break;
6629         default: goto __pyx_L5_argtuple_error;
6630       }
6631       kw_args = PyDict_Size(__pyx_kwds);
6632       switch (pos_args) {
6633         case  0:
6634         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signatures)) != 0)) kw_args--;
6635         else goto __pyx_L5_argtuple_error;
6636         CYTHON_FALLTHROUGH;
6637         case  1:
6638         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
6639         else {
6640           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 1); __PYX_ERR(0, 287, __pyx_L3_error)
6641         }
6642         CYTHON_FALLTHROUGH;
6643         case  2:
6644         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
6645         else {
6646           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); __PYX_ERR(0, 287, __pyx_L3_error)
6647         }
6648         CYTHON_FALLTHROUGH;
6649         case  3:
6650         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--;
6651         else {
6652           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); __PYX_ERR(0, 287, __pyx_L3_error)
6653         }
6654       }
6655       if (unlikely(kw_args > 0)) {
6656         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) __PYX_ERR(0, 287, __pyx_L3_error)
6657       }
6658     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
6659       goto __pyx_L5_argtuple_error;
6660     } else {
6661       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6662       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6663       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6664       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6665     }
6666     __pyx_v_signatures = values[0];
6667     __pyx_v_args = values[1];
6668     __pyx_v_kwargs = values[2];
6669     __pyx_v_defaults = values[3];
6670   }
6671   goto __pyx_L4_argument_unpacking_done;
6672   __pyx_L5_argtuple_error:;
6673   __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 287, __pyx_L3_error)
6674   __pyx_L3_error:;
6675   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
6676   __Pyx_RefNannyFinishContext();
6677   return NULL;
6678   __pyx_L4_argument_unpacking_done:;
6679   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_6compute_energy_ssd_2d(__pyx_self, __pyx_v_signatures, __pyx_v_args, __pyx_v_kwargs, __pyx_v_defaults);
6680 
6681   /* function exit code */
6682   __Pyx_RefNannyFinishContext();
6683   return __pyx_r;
6684 }
6685 
__pyx_pf_4dipy_5align_9sumsqdiff_6compute_energy_ssd_2d(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_signatures,PyObject * __pyx_v_args,PyObject * __pyx_v_kwargs,CYTHON_UNUSED PyObject * __pyx_v_defaults)6686 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_6compute_energy_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults) {
6687   PyObject *__pyx_v_dest_sig = NULL;
6688   Py_ssize_t __pyx_v_i;
6689   PyTypeObject *__pyx_v_ndarray = 0;
6690   __Pyx_memviewslice __pyx_v_memslice;
6691   Py_ssize_t __pyx_v_itemsize;
6692   CYTHON_UNUSED int __pyx_v_dtype_signed;
6693   char __pyx_v_kind;
6694   PyObject *__pyx_v_arg = NULL;
6695   PyObject *__pyx_v_dtype = NULL;
6696   PyObject *__pyx_v_arg_base = NULL;
6697   PyObject *__pyx_v_candidates = NULL;
6698   PyObject *__pyx_v_sig = NULL;
6699   int __pyx_v_match_found;
6700   PyObject *__pyx_v_src_sig = NULL;
6701   PyObject *__pyx_v_dst_type = NULL;
6702   PyObject *__pyx_r = NULL;
6703   __Pyx_RefNannyDeclarations
6704   PyObject *__pyx_t_1 = NULL;
6705   int __pyx_t_2;
6706   int __pyx_t_3;
6707   int __pyx_t_4;
6708   Py_ssize_t __pyx_t_5;
6709   PyObject *__pyx_t_6 = NULL;
6710   long __pyx_t_7;
6711   __Pyx_memviewslice __pyx_t_8;
6712   Py_ssize_t __pyx_t_9;
6713   int __pyx_t_10;
6714   int __pyx_t_11;
6715   PyObject *__pyx_t_12 = NULL;
6716   PyObject *__pyx_t_13 = NULL;
6717   PyObject *__pyx_t_14 = NULL;
6718   Py_ssize_t __pyx_t_15;
6719   Py_ssize_t __pyx_t_16;
6720   Py_ssize_t __pyx_t_17;
6721   int __pyx_t_18;
6722   int __pyx_lineno = 0;
6723   const char *__pyx_filename = NULL;
6724   int __pyx_clineno = 0;
6725   __Pyx_RefNannySetupContext("compute_energy_ssd_2d", 0);
6726   __Pyx_INCREF(__pyx_v_kwargs);
6727   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
6728   __Pyx_GOTREF(__pyx_t_1);
6729   __Pyx_INCREF(Py_None);
6730   __Pyx_GIVEREF(Py_None);
6731   PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
6732   __pyx_v_dest_sig = ((PyObject*)__pyx_t_1);
6733   __pyx_t_1 = 0;
6734   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
6735   __pyx_t_4 = (__pyx_t_3 != 0);
6736   if (__pyx_t_4) {
6737   } else {
6738     __pyx_t_2 = __pyx_t_4;
6739     goto __pyx_L4_bool_binop_done;
6740   }
6741   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 287, __pyx_L1_error)
6742   __pyx_t_3 = ((!__pyx_t_4) != 0);
6743   __pyx_t_2 = __pyx_t_3;
6744   __pyx_L4_bool_binop_done:;
6745   if (__pyx_t_2) {
6746     __Pyx_INCREF(Py_None);
6747     __Pyx_DECREF_SET(__pyx_v_kwargs, Py_None);
6748   }
6749   __pyx_t_1 = ((PyObject *)__Pyx_ImportNumPyArrayTypeIfAvailable()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
6750   __Pyx_GOTREF(__pyx_t_1);
6751   __pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1);
6752   __pyx_t_1 = 0;
6753   __pyx_v_itemsize = -1L;
6754   if (unlikely(__pyx_v_args == Py_None)) {
6755     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
6756     __PYX_ERR(0, 287, __pyx_L1_error)
6757   }
6758   __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 287, __pyx_L1_error)
6759   __pyx_t_2 = ((0 < __pyx_t_5) != 0);
6760   if (__pyx_t_2) {
6761     if (unlikely(__pyx_v_args == Py_None)) {
6762       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6763       __PYX_ERR(0, 287, __pyx_L1_error)
6764     }
6765     __pyx_t_1 = PyTuple_GET_ITEM(((PyObject*)__pyx_v_args), 0);
6766     __Pyx_INCREF(__pyx_t_1);
6767     __pyx_v_arg = __pyx_t_1;
6768     __pyx_t_1 = 0;
6769     goto __pyx_L6;
6770   }
6771   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
6772   __pyx_t_4 = (__pyx_t_3 != 0);
6773   if (__pyx_t_4) {
6774   } else {
6775     __pyx_t_2 = __pyx_t_4;
6776     goto __pyx_L7_bool_binop_done;
6777   }
6778   if (unlikely(__pyx_v_kwargs == Py_None)) {
6779     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
6780     __PYX_ERR(0, 287, __pyx_L1_error)
6781   }
6782   __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_delta_field, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 287, __pyx_L1_error)
6783   __pyx_t_3 = (__pyx_t_4 != 0);
6784   __pyx_t_2 = __pyx_t_3;
6785   __pyx_L7_bool_binop_done:;
6786   if (__pyx_t_2) {
6787     if (unlikely(__pyx_v_kwargs == Py_None)) {
6788       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6789       __PYX_ERR(0, 287, __pyx_L1_error)
6790     }
6791     __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_delta_field); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
6792     __Pyx_GOTREF(__pyx_t_1);
6793     __pyx_v_arg = __pyx_t_1;
6794     __pyx_t_1 = 0;
6795     goto __pyx_L6;
6796   }
6797   /*else*/ {
6798     if (unlikely(__pyx_v_args == Py_None)) {
6799       PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
6800       __PYX_ERR(0, 287, __pyx_L1_error)
6801     }
6802     __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 287, __pyx_L1_error)
6803     __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
6804     __Pyx_GOTREF(__pyx_t_1);
6805     __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
6806     __Pyx_GOTREF(__pyx_t_6);
6807     __Pyx_INCREF(__pyx_int_1);
6808     __Pyx_GIVEREF(__pyx_int_1);
6809     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
6810     __Pyx_INCREF(__pyx_kp_s__7);
6811     __Pyx_GIVEREF(__pyx_kp_s__7);
6812     PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_kp_s__7);
6813     __Pyx_GIVEREF(__pyx_t_1);
6814     PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
6815     __pyx_t_1 = 0;
6816     __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
6817     __Pyx_GOTREF(__pyx_t_1);
6818     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6819     __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
6820     __Pyx_GOTREF(__pyx_t_6);
6821     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6822     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
6823     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6824     __PYX_ERR(0, 287, __pyx_L1_error)
6825   }
6826   __pyx_L6:;
6827   while (1) {
6828     __pyx_t_2 = (__pyx_v_ndarray != ((PyTypeObject*)Py_None));
6829     __pyx_t_3 = (__pyx_t_2 != 0);
6830     if (__pyx_t_3) {
6831       __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray);
6832       __pyx_t_2 = (__pyx_t_3 != 0);
6833       if (__pyx_t_2) {
6834         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
6835         __Pyx_GOTREF(__pyx_t_6);
6836         __pyx_v_dtype = __pyx_t_6;
6837         __pyx_t_6 = 0;
6838         goto __pyx_L12;
6839       }
6840       __pyx_t_2 = __pyx_memoryview_check(__pyx_v_arg);
6841       __pyx_t_3 = (__pyx_t_2 != 0);
6842       if (__pyx_t_3) {
6843         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
6844         __Pyx_GOTREF(__pyx_t_6);
6845         __pyx_v_arg_base = __pyx_t_6;
6846         __pyx_t_6 = 0;
6847         __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray);
6848         __pyx_t_2 = (__pyx_t_3 != 0);
6849         if (__pyx_t_2) {
6850           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
6851           __Pyx_GOTREF(__pyx_t_6);
6852           __pyx_v_dtype = __pyx_t_6;
6853           __pyx_t_6 = 0;
6854           goto __pyx_L13;
6855         }
6856         /*else*/ {
6857           __Pyx_INCREF(Py_None);
6858           __pyx_v_dtype = Py_None;
6859         }
6860         __pyx_L13:;
6861         goto __pyx_L12;
6862       }
6863       /*else*/ {
6864         __Pyx_INCREF(Py_None);
6865         __pyx_v_dtype = Py_None;
6866       }
6867       __pyx_L12:;
6868       __pyx_v_itemsize = -1L;
6869       __pyx_t_2 = (__pyx_v_dtype != Py_None);
6870       __pyx_t_3 = (__pyx_t_2 != 0);
6871       if (__pyx_t_3) {
6872         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
6873         __Pyx_GOTREF(__pyx_t_6);
6874         __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 287, __pyx_L1_error)
6875         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6876         __pyx_v_itemsize = __pyx_t_5;
6877         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
6878         __Pyx_GOTREF(__pyx_t_6);
6879         __pyx_t_7 = __Pyx_PyObject_Ord(__pyx_t_6); if (unlikely(__pyx_t_7 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 287, __pyx_L1_error)
6880         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6881         __pyx_v_kind = __pyx_t_7;
6882         __pyx_v_dtype_signed = (__pyx_v_kind == 'i');
6883         switch (__pyx_v_kind) {
6884           case 'i':
6885           case 'u':
6886           break;
6887           case 'f':
6888           __pyx_t_2 = (((sizeof(float)) == __pyx_v_itemsize) != 0);
6889           if (__pyx_t_2) {
6890           } else {
6891             __pyx_t_3 = __pyx_t_2;
6892             goto __pyx_L16_bool_binop_done;
6893           }
6894           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
6895           __Pyx_GOTREF(__pyx_t_6);
6896           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 287, __pyx_L1_error)
6897           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6898           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 2) != 0);
6899           __pyx_t_3 = __pyx_t_2;
6900           __pyx_L16_bool_binop_done:;
6901           if (__pyx_t_3) {
6902             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 287, __pyx_L1_error)
6903             goto __pyx_L10_break;
6904           }
6905           __pyx_t_2 = (((sizeof(double)) == __pyx_v_itemsize) != 0);
6906           if (__pyx_t_2) {
6907           } else {
6908             __pyx_t_3 = __pyx_t_2;
6909             goto __pyx_L19_bool_binop_done;
6910           }
6911           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
6912           __Pyx_GOTREF(__pyx_t_6);
6913           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 287, __pyx_L1_error)
6914           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6915           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 2) != 0);
6916           __pyx_t_3 = __pyx_t_2;
6917           __pyx_L19_bool_binop_done:;
6918           if (__pyx_t_3) {
6919             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 287, __pyx_L1_error)
6920             goto __pyx_L10_break;
6921           }
6922           break;
6923           case 'c':
6924           break;
6925           case 'O':
6926           break;
6927           default: break;
6928         }
6929       }
6930     }
6931     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
6932     if (!__pyx_t_2) {
6933     } else {
6934       __pyx_t_3 = __pyx_t_2;
6935       goto __pyx_L22_bool_binop_done;
6936     }
6937     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(float))) != 0);
6938     __pyx_t_3 = __pyx_t_2;
6939     __pyx_L22_bool_binop_done:;
6940     if (__pyx_t_3) {
6941       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_v_arg, 0);
6942       __pyx_v_memslice = __pyx_t_8;
6943       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
6944       if (__pyx_t_3) {
6945         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
6946         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 287, __pyx_L1_error)
6947         goto __pyx_L10_break;
6948       }
6949       /*else*/ {
6950         PyErr_Clear();
6951       }
6952     }
6953     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
6954     if (!__pyx_t_2) {
6955     } else {
6956       __pyx_t_3 = __pyx_t_2;
6957       goto __pyx_L26_bool_binop_done;
6958     }
6959     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(double))) != 0);
6960     __pyx_t_3 = __pyx_t_2;
6961     __pyx_L26_bool_binop_done:;
6962     if (__pyx_t_3) {
6963       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_v_arg, 0);
6964       __pyx_v_memslice = __pyx_t_8;
6965       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
6966       if (__pyx_t_3) {
6967         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
6968         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 287, __pyx_L1_error)
6969         goto __pyx_L10_break;
6970       }
6971       /*else*/ {
6972         PyErr_Clear();
6973       }
6974     }
6975     if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 287, __pyx_L1_error)
6976     goto __pyx_L10_break;
6977   }
6978   __pyx_L10_break:;
6979   __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
6980   __Pyx_GOTREF(__pyx_t_6);
6981   __pyx_v_candidates = ((PyObject*)__pyx_t_6);
6982   __pyx_t_6 = 0;
6983   __pyx_t_5 = 0;
6984   if (unlikely(__pyx_v_signatures == Py_None)) {
6985     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
6986     __PYX_ERR(0, 287, __pyx_L1_error)
6987   }
6988   __pyx_t_1 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
6989   __Pyx_GOTREF(__pyx_t_1);
6990   __Pyx_XDECREF(__pyx_t_6);
6991   __pyx_t_6 = __pyx_t_1;
6992   __pyx_t_1 = 0;
6993   while (1) {
6994     __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_5, &__pyx_t_1, NULL, NULL, __pyx_t_10);
6995     if (unlikely(__pyx_t_11 == 0)) break;
6996     if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 287, __pyx_L1_error)
6997     __Pyx_GOTREF(__pyx_t_1);
6998     __Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_1);
6999     __pyx_t_1 = 0;
7000     __pyx_v_match_found = 0;
7001     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 287, __pyx_L1_error)
7002     __Pyx_GOTREF(__pyx_t_13);
7003     __pyx_t_14 = NULL;
7004     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
7005       __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
7006       if (likely(__pyx_t_14)) {
7007         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
7008         __Pyx_INCREF(__pyx_t_14);
7009         __Pyx_INCREF(function);
7010         __Pyx_DECREF_SET(__pyx_t_13, function);
7011       }
7012     }
7013     __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_kp_s__3) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__3);
7014     __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
7015     if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 287, __pyx_L1_error)
7016     __Pyx_GOTREF(__pyx_t_12);
7017     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
7018     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_split); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 287, __pyx_L1_error)
7019     __Pyx_GOTREF(__pyx_t_13);
7020     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
7021     __pyx_t_12 = NULL;
7022     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
7023       __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
7024       if (likely(__pyx_t_12)) {
7025         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
7026         __Pyx_INCREF(__pyx_t_12);
7027         __Pyx_INCREF(function);
7028         __Pyx_DECREF_SET(__pyx_t_13, function);
7029       }
7030     }
7031     __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_kp_s__4) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__4);
7032     __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
7033     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
7034     __Pyx_GOTREF(__pyx_t_1);
7035     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
7036     __Pyx_XDECREF_SET(__pyx_v_src_sig, __pyx_t_1);
7037     __pyx_t_1 = 0;
7038     __pyx_t_15 = PyList_GET_SIZE(__pyx_v_dest_sig); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 287, __pyx_L1_error)
7039     __pyx_t_16 = __pyx_t_15;
7040     for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
7041       __pyx_v_i = __pyx_t_17;
7042       __pyx_t_1 = PyList_GET_ITEM(__pyx_v_dest_sig, __pyx_v_i);
7043       __Pyx_INCREF(__pyx_t_1);
7044       __Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_1);
7045       __pyx_t_1 = 0;
7046       __pyx_t_3 = (__pyx_v_dst_type != Py_None);
7047       __pyx_t_2 = (__pyx_t_3 != 0);
7048       if (__pyx_t_2) {
7049         __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
7050         __Pyx_GOTREF(__pyx_t_1);
7051         __pyx_t_13 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 287, __pyx_L1_error)
7052         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7053         __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 287, __pyx_L1_error)
7054         __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
7055         if (__pyx_t_2) {
7056           __pyx_v_match_found = 1;
7057           goto __pyx_L34;
7058         }
7059         /*else*/ {
7060           __pyx_v_match_found = 0;
7061           goto __pyx_L32_break;
7062         }
7063         __pyx_L34:;
7064       }
7065     }
7066     __pyx_L32_break:;
7067     __pyx_t_2 = (__pyx_v_match_found != 0);
7068     if (__pyx_t_2) {
7069       __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 287, __pyx_L1_error)
7070     }
7071   }
7072   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7073   __pyx_t_2 = (PyList_GET_SIZE(__pyx_v_candidates) != 0);
7074   __pyx_t_3 = ((!__pyx_t_2) != 0);
7075   if (__pyx_t_3) {
7076     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
7077     __Pyx_GOTREF(__pyx_t_6);
7078     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
7079     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7080     __PYX_ERR(0, 287, __pyx_L1_error)
7081   }
7082   __pyx_t_9 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 287, __pyx_L1_error)
7083   __pyx_t_3 = ((__pyx_t_9 > 1) != 0);
7084   if (__pyx_t_3) {
7085     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
7086     __Pyx_GOTREF(__pyx_t_6);
7087     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
7088     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7089     __PYX_ERR(0, 287, __pyx_L1_error)
7090   }
7091   /*else*/ {
7092     __Pyx_XDECREF(__pyx_r);
7093     if (unlikely(__pyx_v_signatures == Py_None)) {
7094       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
7095       __PYX_ERR(0, 287, __pyx_L1_error)
7096     }
7097     __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), PyList_GET_ITEM(__pyx_v_candidates, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
7098     __Pyx_GOTREF(__pyx_t_6);
7099     __pyx_r = __pyx_t_6;
7100     __pyx_t_6 = 0;
7101     goto __pyx_L0;
7102   }
7103 
7104   /* function exit code */
7105   __pyx_L1_error:;
7106   __Pyx_XDECREF(__pyx_t_1);
7107   __Pyx_XDECREF(__pyx_t_6);
7108   __Pyx_XDECREF(__pyx_t_12);
7109   __Pyx_XDECREF(__pyx_t_13);
7110   __Pyx_XDECREF(__pyx_t_14);
7111   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
7112   __pyx_r = NULL;
7113   __pyx_L0:;
7114   __Pyx_XDECREF(__pyx_v_dest_sig);
7115   __Pyx_XDECREF(__pyx_v_ndarray);
7116   __Pyx_XDECREF(__pyx_v_arg);
7117   __Pyx_XDECREF(__pyx_v_dtype);
7118   __Pyx_XDECREF(__pyx_v_arg_base);
7119   __Pyx_XDECREF(__pyx_v_candidates);
7120   __Pyx_XDECREF(__pyx_v_sig);
7121   __Pyx_XDECREF(__pyx_v_src_sig);
7122   __Pyx_XDECREF(__pyx_v_dst_type);
7123   __Pyx_XDECREF(__pyx_v_kwargs);
7124   __Pyx_XGIVEREF(__pyx_r);
7125   __Pyx_RefNannyFinishContext();
7126   return __pyx_r;
7127 }
7128 
7129 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_27__pyx_fuse_0compute_energy_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field); /*proto*/
7130 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_7compute_energy_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field,CYTHON_UNUSED int __pyx_skip_dispatch)7131 static double __pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field, CYTHON_UNUSED int __pyx_skip_dispatch) {
7132   npy_intp __pyx_v_nrows;
7133   npy_intp __pyx_v_ncols;
7134   npy_intp __pyx_v_r;
7135   npy_intp __pyx_v_c;
7136   double __pyx_v_energy;
7137   double __pyx_r;
7138   __Pyx_RefNannyDeclarations
7139   npy_intp __pyx_t_1;
7140   npy_intp __pyx_t_2;
7141   npy_intp __pyx_t_3;
7142   npy_intp __pyx_t_4;
7143   npy_intp __pyx_t_5;
7144   npy_intp __pyx_t_6;
7145   Py_ssize_t __pyx_t_7;
7146   Py_ssize_t __pyx_t_8;
7147   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_energy_ssd_2d", 0);
7148 
7149   /* "dipy/align/sumsqdiff.pyx":321
7150  *     """
7151  *     cdef:
7152  *         cnp.npy_intp nrows = delta_field.shape[0]             # <<<<<<<<<<<<<<
7153  *         cnp.npy_intp ncols = delta_field.shape[1]
7154  *         cnp.npy_intp r, c
7155  */
7156   __pyx_v_nrows = (__pyx_v_delta_field.shape[0]);
7157 
7158   /* "dipy/align/sumsqdiff.pyx":322
7159  *     cdef:
7160  *         cnp.npy_intp nrows = delta_field.shape[0]
7161  *         cnp.npy_intp ncols = delta_field.shape[1]             # <<<<<<<<<<<<<<
7162  *         cnp.npy_intp r, c
7163  *         double energy = 0
7164  */
7165   __pyx_v_ncols = (__pyx_v_delta_field.shape[1]);
7166 
7167   /* "dipy/align/sumsqdiff.pyx":324
7168  *         cnp.npy_intp ncols = delta_field.shape[1]
7169  *         cnp.npy_intp r, c
7170  *         double energy = 0             # <<<<<<<<<<<<<<
7171  *
7172  *     with nogil:
7173  */
7174   __pyx_v_energy = 0.0;
7175 
7176   /* "dipy/align/sumsqdiff.pyx":326
7177  *         double energy = 0
7178  *
7179  *     with nogil:             # <<<<<<<<<<<<<<
7180  *         for r in range(nrows):
7181  *             for c in range(ncols):
7182  */
7183   {
7184       #ifdef WITH_THREAD
7185       PyThreadState *_save;
7186       Py_UNBLOCK_THREADS
7187       __Pyx_FastGIL_Remember();
7188       #endif
7189       /*try:*/ {
7190 
7191         /* "dipy/align/sumsqdiff.pyx":327
7192  *
7193  *     with nogil:
7194  *         for r in range(nrows):             # <<<<<<<<<<<<<<
7195  *             for c in range(ncols):
7196  *                 energy += delta_field[r, c] ** 2
7197  */
7198         __pyx_t_1 = __pyx_v_nrows;
7199         __pyx_t_2 = __pyx_t_1;
7200         for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
7201           __pyx_v_r = __pyx_t_3;
7202 
7203           /* "dipy/align/sumsqdiff.pyx":328
7204  *     with nogil:
7205  *         for r in range(nrows):
7206  *             for c in range(ncols):             # <<<<<<<<<<<<<<
7207  *                 energy += delta_field[r, c] ** 2
7208  *     return energy
7209  */
7210           __pyx_t_4 = __pyx_v_ncols;
7211           __pyx_t_5 = __pyx_t_4;
7212           for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
7213             __pyx_v_c = __pyx_t_6;
7214 
7215             /* "dipy/align/sumsqdiff.pyx":329
7216  *         for r in range(nrows):
7217  *             for c in range(ncols):
7218  *                 energy += delta_field[r, c] ** 2             # <<<<<<<<<<<<<<
7219  *     return energy
7220  *
7221  */
7222             __pyx_t_7 = __pyx_v_r;
7223             __pyx_t_8 = __pyx_v_c;
7224             __pyx_v_energy = (__pyx_v_energy + powf((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_7 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_8 * __pyx_v_delta_field.strides[1]) ))), 2.0));
7225           }
7226         }
7227       }
7228 
7229       /* "dipy/align/sumsqdiff.pyx":326
7230  *         double energy = 0
7231  *
7232  *     with nogil:             # <<<<<<<<<<<<<<
7233  *         for r in range(nrows):
7234  *             for c in range(ncols):
7235  */
7236       /*finally:*/ {
7237         /*normal exit:*/{
7238           #ifdef WITH_THREAD
7239           __Pyx_FastGIL_Forget();
7240           Py_BLOCK_THREADS
7241           #endif
7242           goto __pyx_L5;
7243         }
7244         __pyx_L5:;
7245       }
7246   }
7247 
7248   /* "dipy/align/sumsqdiff.pyx":330
7249  *             for c in range(ncols):
7250  *                 energy += delta_field[r, c] ** 2
7251  *     return energy             # <<<<<<<<<<<<<<
7252  *
7253  *
7254  */
7255   __pyx_r = __pyx_v_energy;
7256   goto __pyx_L0;
7257 
7258   /* "dipy/align/sumsqdiff.pyx":287
7259  * @cython.boundscheck(False)
7260  * @cython.wraparound(False)
7261  * cpdef double compute_energy_ssd_2d(floating[:, :] delta_field):             # <<<<<<<<<<<<<<
7262  *     r"""Sum of squared differences between two 2D images
7263  *
7264  */
7265 
7266   /* function exit code */
7267   __pyx_L0:;
7268   __Pyx_RefNannyFinishContext();
7269   return __pyx_r;
7270 }
7271 
7272 /* Python wrapper */
7273 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_27__pyx_fuse_0compute_energy_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field); /*proto*/
7274 static PyMethodDef __pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_27__pyx_fuse_0compute_energy_ssd_2d = {"__pyx_fuse_0compute_energy_ssd_2d", (PyCFunction)__pyx_pw_4dipy_5align_9sumsqdiff_27__pyx_fuse_0compute_energy_ssd_2d, METH_O, __pyx_doc_4dipy_5align_9sumsqdiff_6compute_energy_ssd_2d};
__pyx_pw_4dipy_5align_9sumsqdiff_27__pyx_fuse_0compute_energy_ssd_2d(PyObject * __pyx_self,PyObject * __pyx_arg_delta_field)7275 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_27__pyx_fuse_0compute_energy_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field) {
7276   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
7277   int __pyx_lineno = 0;
7278   const char *__pyx_filename = NULL;
7279   int __pyx_clineno = 0;
7280   PyObject *__pyx_r = 0;
7281   __Pyx_RefNannyDeclarations
7282   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_energy_ssd_2d (wrapper)", 0);
7283   assert(__pyx_arg_delta_field); {
7284     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_arg_delta_field, PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 287, __pyx_L3_error)
7285   }
7286   goto __pyx_L4_argument_unpacking_done;
7287   __pyx_L3_error:;
7288   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_0compute_energy_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
7289   __Pyx_RefNannyFinishContext();
7290   return NULL;
7291   __pyx_L4_argument_unpacking_done:;
7292   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_26__pyx_fuse_0compute_energy_ssd_2d(__pyx_self, __pyx_v_delta_field);
7293 
7294   /* function exit code */
7295   __Pyx_RefNannyFinishContext();
7296   return __pyx_r;
7297 }
7298 
__pyx_pf_4dipy_5align_9sumsqdiff_26__pyx_fuse_0compute_energy_ssd_2d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field)7299 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_26__pyx_fuse_0compute_energy_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field) {
7300   PyObject *__pyx_r = NULL;
7301   __Pyx_RefNannyDeclarations
7302   PyObject *__pyx_t_1 = NULL;
7303   int __pyx_lineno = 0;
7304   const char *__pyx_filename = NULL;
7305   int __pyx_clineno = 0;
7306   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_energy_ssd_2d", 0);
7307   __Pyx_XDECREF(__pyx_r);
7308   if (unlikely(!__pyx_v_delta_field.memview)) { __Pyx_RaiseUnboundLocalError("delta_field"); __PYX_ERR(0, 287, __pyx_L1_error) }
7309   __pyx_t_1 = PyFloat_FromDouble(__pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_2d(__pyx_v_delta_field, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
7310   __Pyx_GOTREF(__pyx_t_1);
7311   __pyx_r = __pyx_t_1;
7312   __pyx_t_1 = 0;
7313   goto __pyx_L0;
7314 
7315   /* function exit code */
7316   __pyx_L1_error:;
7317   __Pyx_XDECREF(__pyx_t_1);
7318   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_0compute_energy_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
7319   __pyx_r = NULL;
7320   __pyx_L0:;
7321   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
7322   __Pyx_XGIVEREF(__pyx_r);
7323   __Pyx_RefNannyFinishContext();
7324   return __pyx_r;
7325 }
7326 
7327 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_29__pyx_fuse_1compute_energy_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field); /*proto*/
7328 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_7compute_energy_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field,CYTHON_UNUSED int __pyx_skip_dispatch)7329 static double __pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field, CYTHON_UNUSED int __pyx_skip_dispatch) {
7330   npy_intp __pyx_v_nrows;
7331   npy_intp __pyx_v_ncols;
7332   npy_intp __pyx_v_r;
7333   npy_intp __pyx_v_c;
7334   double __pyx_v_energy;
7335   double __pyx_r;
7336   __Pyx_RefNannyDeclarations
7337   npy_intp __pyx_t_1;
7338   npy_intp __pyx_t_2;
7339   npy_intp __pyx_t_3;
7340   npy_intp __pyx_t_4;
7341   npy_intp __pyx_t_5;
7342   npy_intp __pyx_t_6;
7343   Py_ssize_t __pyx_t_7;
7344   Py_ssize_t __pyx_t_8;
7345   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_energy_ssd_2d", 0);
7346 
7347   /* "dipy/align/sumsqdiff.pyx":321
7348  *     """
7349  *     cdef:
7350  *         cnp.npy_intp nrows = delta_field.shape[0]             # <<<<<<<<<<<<<<
7351  *         cnp.npy_intp ncols = delta_field.shape[1]
7352  *         cnp.npy_intp r, c
7353  */
7354   __pyx_v_nrows = (__pyx_v_delta_field.shape[0]);
7355 
7356   /* "dipy/align/sumsqdiff.pyx":322
7357  *     cdef:
7358  *         cnp.npy_intp nrows = delta_field.shape[0]
7359  *         cnp.npy_intp ncols = delta_field.shape[1]             # <<<<<<<<<<<<<<
7360  *         cnp.npy_intp r, c
7361  *         double energy = 0
7362  */
7363   __pyx_v_ncols = (__pyx_v_delta_field.shape[1]);
7364 
7365   /* "dipy/align/sumsqdiff.pyx":324
7366  *         cnp.npy_intp ncols = delta_field.shape[1]
7367  *         cnp.npy_intp r, c
7368  *         double energy = 0             # <<<<<<<<<<<<<<
7369  *
7370  *     with nogil:
7371  */
7372   __pyx_v_energy = 0.0;
7373 
7374   /* "dipy/align/sumsqdiff.pyx":326
7375  *         double energy = 0
7376  *
7377  *     with nogil:             # <<<<<<<<<<<<<<
7378  *         for r in range(nrows):
7379  *             for c in range(ncols):
7380  */
7381   {
7382       #ifdef WITH_THREAD
7383       PyThreadState *_save;
7384       Py_UNBLOCK_THREADS
7385       __Pyx_FastGIL_Remember();
7386       #endif
7387       /*try:*/ {
7388 
7389         /* "dipy/align/sumsqdiff.pyx":327
7390  *
7391  *     with nogil:
7392  *         for r in range(nrows):             # <<<<<<<<<<<<<<
7393  *             for c in range(ncols):
7394  *                 energy += delta_field[r, c] ** 2
7395  */
7396         __pyx_t_1 = __pyx_v_nrows;
7397         __pyx_t_2 = __pyx_t_1;
7398         for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
7399           __pyx_v_r = __pyx_t_3;
7400 
7401           /* "dipy/align/sumsqdiff.pyx":328
7402  *     with nogil:
7403  *         for r in range(nrows):
7404  *             for c in range(ncols):             # <<<<<<<<<<<<<<
7405  *                 energy += delta_field[r, c] ** 2
7406  *     return energy
7407  */
7408           __pyx_t_4 = __pyx_v_ncols;
7409           __pyx_t_5 = __pyx_t_4;
7410           for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
7411             __pyx_v_c = __pyx_t_6;
7412 
7413             /* "dipy/align/sumsqdiff.pyx":329
7414  *         for r in range(nrows):
7415  *             for c in range(ncols):
7416  *                 energy += delta_field[r, c] ** 2             # <<<<<<<<<<<<<<
7417  *     return energy
7418  *
7419  */
7420             __pyx_t_7 = __pyx_v_r;
7421             __pyx_t_8 = __pyx_v_c;
7422             __pyx_v_energy = (__pyx_v_energy + pow((*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_7 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_8 * __pyx_v_delta_field.strides[1]) ))), 2.0));
7423           }
7424         }
7425       }
7426 
7427       /* "dipy/align/sumsqdiff.pyx":326
7428  *         double energy = 0
7429  *
7430  *     with nogil:             # <<<<<<<<<<<<<<
7431  *         for r in range(nrows):
7432  *             for c in range(ncols):
7433  */
7434       /*finally:*/ {
7435         /*normal exit:*/{
7436           #ifdef WITH_THREAD
7437           __Pyx_FastGIL_Forget();
7438           Py_BLOCK_THREADS
7439           #endif
7440           goto __pyx_L5;
7441         }
7442         __pyx_L5:;
7443       }
7444   }
7445 
7446   /* "dipy/align/sumsqdiff.pyx":330
7447  *             for c in range(ncols):
7448  *                 energy += delta_field[r, c] ** 2
7449  *     return energy             # <<<<<<<<<<<<<<
7450  *
7451  *
7452  */
7453   __pyx_r = __pyx_v_energy;
7454   goto __pyx_L0;
7455 
7456   /* "dipy/align/sumsqdiff.pyx":287
7457  * @cython.boundscheck(False)
7458  * @cython.wraparound(False)
7459  * cpdef double compute_energy_ssd_2d(floating[:, :] delta_field):             # <<<<<<<<<<<<<<
7460  *     r"""Sum of squared differences between two 2D images
7461  *
7462  */
7463 
7464   /* function exit code */
7465   __pyx_L0:;
7466   __Pyx_RefNannyFinishContext();
7467   return __pyx_r;
7468 }
7469 
7470 /* Python wrapper */
7471 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_29__pyx_fuse_1compute_energy_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field); /*proto*/
7472 static PyMethodDef __pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_29__pyx_fuse_1compute_energy_ssd_2d = {"__pyx_fuse_1compute_energy_ssd_2d", (PyCFunction)__pyx_pw_4dipy_5align_9sumsqdiff_29__pyx_fuse_1compute_energy_ssd_2d, METH_O, __pyx_doc_4dipy_5align_9sumsqdiff_6compute_energy_ssd_2d};
__pyx_pw_4dipy_5align_9sumsqdiff_29__pyx_fuse_1compute_energy_ssd_2d(PyObject * __pyx_self,PyObject * __pyx_arg_delta_field)7473 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_29__pyx_fuse_1compute_energy_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field) {
7474   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
7475   int __pyx_lineno = 0;
7476   const char *__pyx_filename = NULL;
7477   int __pyx_clineno = 0;
7478   PyObject *__pyx_r = 0;
7479   __Pyx_RefNannyDeclarations
7480   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_energy_ssd_2d (wrapper)", 0);
7481   assert(__pyx_arg_delta_field); {
7482     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_arg_delta_field, PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 287, __pyx_L3_error)
7483   }
7484   goto __pyx_L4_argument_unpacking_done;
7485   __pyx_L3_error:;
7486   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_1compute_energy_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
7487   __Pyx_RefNannyFinishContext();
7488   return NULL;
7489   __pyx_L4_argument_unpacking_done:;
7490   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_28__pyx_fuse_1compute_energy_ssd_2d(__pyx_self, __pyx_v_delta_field);
7491 
7492   /* function exit code */
7493   __Pyx_RefNannyFinishContext();
7494   return __pyx_r;
7495 }
7496 
__pyx_pf_4dipy_5align_9sumsqdiff_28__pyx_fuse_1compute_energy_ssd_2d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field)7497 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_28__pyx_fuse_1compute_energy_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field) {
7498   PyObject *__pyx_r = NULL;
7499   __Pyx_RefNannyDeclarations
7500   PyObject *__pyx_t_1 = NULL;
7501   int __pyx_lineno = 0;
7502   const char *__pyx_filename = NULL;
7503   int __pyx_clineno = 0;
7504   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_energy_ssd_2d", 0);
7505   __Pyx_XDECREF(__pyx_r);
7506   if (unlikely(!__pyx_v_delta_field.memview)) { __Pyx_RaiseUnboundLocalError("delta_field"); __PYX_ERR(0, 287, __pyx_L1_error) }
7507   __pyx_t_1 = PyFloat_FromDouble(__pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_2d(__pyx_v_delta_field, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
7508   __Pyx_GOTREF(__pyx_t_1);
7509   __pyx_r = __pyx_t_1;
7510   __pyx_t_1 = 0;
7511   goto __pyx_L0;
7512 
7513   /* function exit code */
7514   __pyx_L1_error:;
7515   __Pyx_XDECREF(__pyx_t_1);
7516   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_1compute_energy_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
7517   __pyx_r = NULL;
7518   __pyx_L0:;
7519   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
7520   __Pyx_XGIVEREF(__pyx_r);
7521   __Pyx_RefNannyFinishContext();
7522   return __pyx_r;
7523 }
7524 
7525 /* "dipy/align/sumsqdiff.pyx":336
7526  * @cython.wraparound(False)
7527  * @cython.cdivision(True)
7528  * cpdef double iterate_residual_displacement_field_ssd_3d(             # <<<<<<<<<<<<<<
7529  *                 floating[:, :, :] delta_field, floating[:, :, :] sigmasq_field,
7530  *                 floating[:, :, :, :] grad, floating[:, :, :, :] target,
7531  */
7532 
7533 /* Python wrapper */
7534 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_9iterate_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
7535 static char __pyx_doc_4dipy_5align_9sumsqdiff_8iterate_residual_displacement_field_ssd_3d[] = "One iteration of a large linear system solver for 3D SSD registration\n\n    Performs one iteration at one level of the Multi-resolution Gauss-Seidel\n    solver proposed by Bruhn and Weickert [Bruhn05].\n\n    Parameters\n    ----------\n    delta_field : array, shape (S, R, C)\n        the difference between the static and moving image (the 'derivative\n        w.r.t. time' in the optical flow model)\n    sigmasq_field : array, shape (S, R, C)\n        the variance of the gray level value at each voxel, according to the\n        EM model (for SSD, it is 1 for all voxels). Inf and 0 values\n        are processed specially to support infinite and zero variance.\n    grad : array, shape (S, R, C, 3)\n        the gradient of the moving image\n    target : array, shape (S, R, C, 3)\n        right-hand side of the linear system to be solved in the Weickert's\n        multi-resolution algorithm\n    lambda_param : float\n        smoothness parameter of the objective function\n    disp : array, shape (S, R, C, 3)\n        the displacement field to start the optimization from\n\n    Returns\n    -------\n    max_displacement : float\n        the norm of the maximum change in the displacement field after the\n        iteration\n\n    References\n    ----------\n    [Bruhn05] Andres Bruhn and Joachim Weickert, \"Towards ultimate motion\n              estimation: combining highest accuracy with real-time\n              performance\", 10th IEEE International Conference on Computer\n              Vision, 2005. ICCV 2005.\n    ";
7536 static PyMethodDef __pyx_mdef_4dipy_5align_9sumsqdiff_9iterate_residual_displacement_field_ssd_3d = {"iterate_residual_displacement_field_ssd_3d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_9iterate_residual_displacement_field_ssd_3d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_8iterate_residual_displacement_field_ssd_3d};
__pyx_pw_4dipy_5align_9sumsqdiff_9iterate_residual_displacement_field_ssd_3d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)7537 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_9iterate_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7538   PyObject *__pyx_v_signatures = 0;
7539   PyObject *__pyx_v_args = 0;
7540   PyObject *__pyx_v_kwargs = 0;
7541   CYTHON_UNUSED PyObject *__pyx_v_defaults = 0;
7542   int __pyx_lineno = 0;
7543   const char *__pyx_filename = NULL;
7544   int __pyx_clineno = 0;
7545   PyObject *__pyx_r = 0;
7546   __Pyx_RefNannyDeclarations
7547   __Pyx_RefNannySetupContext("__pyx_fused_cpdef (wrapper)", 0);
7548   {
7549     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signatures,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_defaults,0};
7550     PyObject* values[4] = {0,0,0,0};
7551     if (unlikely(__pyx_kwds)) {
7552       Py_ssize_t kw_args;
7553       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
7554       switch (pos_args) {
7555         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
7556         CYTHON_FALLTHROUGH;
7557         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7558         CYTHON_FALLTHROUGH;
7559         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7560         CYTHON_FALLTHROUGH;
7561         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7562         CYTHON_FALLTHROUGH;
7563         case  0: break;
7564         default: goto __pyx_L5_argtuple_error;
7565       }
7566       kw_args = PyDict_Size(__pyx_kwds);
7567       switch (pos_args) {
7568         case  0:
7569         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signatures)) != 0)) kw_args--;
7570         else goto __pyx_L5_argtuple_error;
7571         CYTHON_FALLTHROUGH;
7572         case  1:
7573         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
7574         else {
7575           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 1); __PYX_ERR(0, 336, __pyx_L3_error)
7576         }
7577         CYTHON_FALLTHROUGH;
7578         case  2:
7579         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
7580         else {
7581           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); __PYX_ERR(0, 336, __pyx_L3_error)
7582         }
7583         CYTHON_FALLTHROUGH;
7584         case  3:
7585         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--;
7586         else {
7587           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); __PYX_ERR(0, 336, __pyx_L3_error)
7588         }
7589       }
7590       if (unlikely(kw_args > 0)) {
7591         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) __PYX_ERR(0, 336, __pyx_L3_error)
7592       }
7593     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
7594       goto __pyx_L5_argtuple_error;
7595     } else {
7596       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7597       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7598       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7599       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
7600     }
7601     __pyx_v_signatures = values[0];
7602     __pyx_v_args = values[1];
7603     __pyx_v_kwargs = values[2];
7604     __pyx_v_defaults = values[3];
7605   }
7606   goto __pyx_L4_argument_unpacking_done;
7607   __pyx_L5_argtuple_error:;
7608   __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 336, __pyx_L3_error)
7609   __pyx_L3_error:;
7610   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
7611   __Pyx_RefNannyFinishContext();
7612   return NULL;
7613   __pyx_L4_argument_unpacking_done:;
7614   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_8iterate_residual_displacement_field_ssd_3d(__pyx_self, __pyx_v_signatures, __pyx_v_args, __pyx_v_kwargs, __pyx_v_defaults);
7615 
7616   /* function exit code */
7617   __Pyx_RefNannyFinishContext();
7618   return __pyx_r;
7619 }
7620 
__pyx_pf_4dipy_5align_9sumsqdiff_8iterate_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_signatures,PyObject * __pyx_v_args,PyObject * __pyx_v_kwargs,CYTHON_UNUSED PyObject * __pyx_v_defaults)7621 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_8iterate_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults) {
7622   PyObject *__pyx_v_dest_sig = NULL;
7623   Py_ssize_t __pyx_v_i;
7624   PyTypeObject *__pyx_v_ndarray = 0;
7625   __Pyx_memviewslice __pyx_v_memslice;
7626   Py_ssize_t __pyx_v_itemsize;
7627   CYTHON_UNUSED int __pyx_v_dtype_signed;
7628   char __pyx_v_kind;
7629   PyObject *__pyx_v_arg = NULL;
7630   PyObject *__pyx_v_dtype = NULL;
7631   PyObject *__pyx_v_arg_base = NULL;
7632   PyObject *__pyx_v_candidates = NULL;
7633   PyObject *__pyx_v_sig = NULL;
7634   int __pyx_v_match_found;
7635   PyObject *__pyx_v_src_sig = NULL;
7636   PyObject *__pyx_v_dst_type = NULL;
7637   PyObject *__pyx_r = NULL;
7638   __Pyx_RefNannyDeclarations
7639   PyObject *__pyx_t_1 = NULL;
7640   int __pyx_t_2;
7641   int __pyx_t_3;
7642   int __pyx_t_4;
7643   Py_ssize_t __pyx_t_5;
7644   PyObject *__pyx_t_6 = NULL;
7645   long __pyx_t_7;
7646   __Pyx_memviewslice __pyx_t_8;
7647   Py_ssize_t __pyx_t_9;
7648   int __pyx_t_10;
7649   int __pyx_t_11;
7650   PyObject *__pyx_t_12 = NULL;
7651   PyObject *__pyx_t_13 = NULL;
7652   PyObject *__pyx_t_14 = NULL;
7653   Py_ssize_t __pyx_t_15;
7654   Py_ssize_t __pyx_t_16;
7655   Py_ssize_t __pyx_t_17;
7656   int __pyx_t_18;
7657   int __pyx_lineno = 0;
7658   const char *__pyx_filename = NULL;
7659   int __pyx_clineno = 0;
7660   __Pyx_RefNannySetupContext("iterate_residual_displacement_field_ssd_3d", 0);
7661   __Pyx_INCREF(__pyx_v_kwargs);
7662   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
7663   __Pyx_GOTREF(__pyx_t_1);
7664   __Pyx_INCREF(Py_None);
7665   __Pyx_GIVEREF(Py_None);
7666   PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
7667   __pyx_v_dest_sig = ((PyObject*)__pyx_t_1);
7668   __pyx_t_1 = 0;
7669   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
7670   __pyx_t_4 = (__pyx_t_3 != 0);
7671   if (__pyx_t_4) {
7672   } else {
7673     __pyx_t_2 = __pyx_t_4;
7674     goto __pyx_L4_bool_binop_done;
7675   }
7676   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 336, __pyx_L1_error)
7677   __pyx_t_3 = ((!__pyx_t_4) != 0);
7678   __pyx_t_2 = __pyx_t_3;
7679   __pyx_L4_bool_binop_done:;
7680   if (__pyx_t_2) {
7681     __Pyx_INCREF(Py_None);
7682     __Pyx_DECREF_SET(__pyx_v_kwargs, Py_None);
7683   }
7684   __pyx_t_1 = ((PyObject *)__Pyx_ImportNumPyArrayTypeIfAvailable()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
7685   __Pyx_GOTREF(__pyx_t_1);
7686   __pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1);
7687   __pyx_t_1 = 0;
7688   __pyx_v_itemsize = -1L;
7689   if (unlikely(__pyx_v_args == Py_None)) {
7690     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
7691     __PYX_ERR(0, 336, __pyx_L1_error)
7692   }
7693   __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 336, __pyx_L1_error)
7694   __pyx_t_2 = ((0 < __pyx_t_5) != 0);
7695   if (__pyx_t_2) {
7696     if (unlikely(__pyx_v_args == Py_None)) {
7697       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
7698       __PYX_ERR(0, 336, __pyx_L1_error)
7699     }
7700     __pyx_t_1 = PyTuple_GET_ITEM(((PyObject*)__pyx_v_args), 0);
7701     __Pyx_INCREF(__pyx_t_1);
7702     __pyx_v_arg = __pyx_t_1;
7703     __pyx_t_1 = 0;
7704     goto __pyx_L6;
7705   }
7706   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
7707   __pyx_t_4 = (__pyx_t_3 != 0);
7708   if (__pyx_t_4) {
7709   } else {
7710     __pyx_t_2 = __pyx_t_4;
7711     goto __pyx_L7_bool_binop_done;
7712   }
7713   if (unlikely(__pyx_v_kwargs == Py_None)) {
7714     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
7715     __PYX_ERR(0, 336, __pyx_L1_error)
7716   }
7717   __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_delta_field, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 336, __pyx_L1_error)
7718   __pyx_t_3 = (__pyx_t_4 != 0);
7719   __pyx_t_2 = __pyx_t_3;
7720   __pyx_L7_bool_binop_done:;
7721   if (__pyx_t_2) {
7722     if (unlikely(__pyx_v_kwargs == Py_None)) {
7723       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
7724       __PYX_ERR(0, 336, __pyx_L1_error)
7725     }
7726     __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_delta_field); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
7727     __Pyx_GOTREF(__pyx_t_1);
7728     __pyx_v_arg = __pyx_t_1;
7729     __pyx_t_1 = 0;
7730     goto __pyx_L6;
7731   }
7732   /*else*/ {
7733     if (unlikely(__pyx_v_args == Py_None)) {
7734       PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
7735       __PYX_ERR(0, 336, __pyx_L1_error)
7736     }
7737     __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 336, __pyx_L1_error)
7738     __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
7739     __Pyx_GOTREF(__pyx_t_1);
7740     __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
7741     __Pyx_GOTREF(__pyx_t_6);
7742     __Pyx_INCREF(__pyx_int_6);
7743     __Pyx_GIVEREF(__pyx_int_6);
7744     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_6);
7745     __Pyx_INCREF(__pyx_n_s_s);
7746     __Pyx_GIVEREF(__pyx_n_s_s);
7747     PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_s);
7748     __Pyx_GIVEREF(__pyx_t_1);
7749     PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
7750     __pyx_t_1 = 0;
7751     __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
7752     __Pyx_GOTREF(__pyx_t_1);
7753     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7754     __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
7755     __Pyx_GOTREF(__pyx_t_6);
7756     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7757     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
7758     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7759     __PYX_ERR(0, 336, __pyx_L1_error)
7760   }
7761   __pyx_L6:;
7762   while (1) {
7763     __pyx_t_2 = (__pyx_v_ndarray != ((PyTypeObject*)Py_None));
7764     __pyx_t_3 = (__pyx_t_2 != 0);
7765     if (__pyx_t_3) {
7766       __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray);
7767       __pyx_t_2 = (__pyx_t_3 != 0);
7768       if (__pyx_t_2) {
7769         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
7770         __Pyx_GOTREF(__pyx_t_6);
7771         __pyx_v_dtype = __pyx_t_6;
7772         __pyx_t_6 = 0;
7773         goto __pyx_L12;
7774       }
7775       __pyx_t_2 = __pyx_memoryview_check(__pyx_v_arg);
7776       __pyx_t_3 = (__pyx_t_2 != 0);
7777       if (__pyx_t_3) {
7778         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
7779         __Pyx_GOTREF(__pyx_t_6);
7780         __pyx_v_arg_base = __pyx_t_6;
7781         __pyx_t_6 = 0;
7782         __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray);
7783         __pyx_t_2 = (__pyx_t_3 != 0);
7784         if (__pyx_t_2) {
7785           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
7786           __Pyx_GOTREF(__pyx_t_6);
7787           __pyx_v_dtype = __pyx_t_6;
7788           __pyx_t_6 = 0;
7789           goto __pyx_L13;
7790         }
7791         /*else*/ {
7792           __Pyx_INCREF(Py_None);
7793           __pyx_v_dtype = Py_None;
7794         }
7795         __pyx_L13:;
7796         goto __pyx_L12;
7797       }
7798       /*else*/ {
7799         __Pyx_INCREF(Py_None);
7800         __pyx_v_dtype = Py_None;
7801       }
7802       __pyx_L12:;
7803       __pyx_v_itemsize = -1L;
7804       __pyx_t_2 = (__pyx_v_dtype != Py_None);
7805       __pyx_t_3 = (__pyx_t_2 != 0);
7806       if (__pyx_t_3) {
7807         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
7808         __Pyx_GOTREF(__pyx_t_6);
7809         __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 336, __pyx_L1_error)
7810         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7811         __pyx_v_itemsize = __pyx_t_5;
7812         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
7813         __Pyx_GOTREF(__pyx_t_6);
7814         __pyx_t_7 = __Pyx_PyObject_Ord(__pyx_t_6); if (unlikely(__pyx_t_7 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 336, __pyx_L1_error)
7815         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7816         __pyx_v_kind = __pyx_t_7;
7817         __pyx_v_dtype_signed = (__pyx_v_kind == 'i');
7818         switch (__pyx_v_kind) {
7819           case 'i':
7820           case 'u':
7821           break;
7822           case 'f':
7823           __pyx_t_2 = (((sizeof(float)) == __pyx_v_itemsize) != 0);
7824           if (__pyx_t_2) {
7825           } else {
7826             __pyx_t_3 = __pyx_t_2;
7827             goto __pyx_L16_bool_binop_done;
7828           }
7829           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
7830           __Pyx_GOTREF(__pyx_t_6);
7831           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 336, __pyx_L1_error)
7832           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7833           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0);
7834           __pyx_t_3 = __pyx_t_2;
7835           __pyx_L16_bool_binop_done:;
7836           if (__pyx_t_3) {
7837             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 336, __pyx_L1_error)
7838             goto __pyx_L10_break;
7839           }
7840           __pyx_t_2 = (((sizeof(double)) == __pyx_v_itemsize) != 0);
7841           if (__pyx_t_2) {
7842           } else {
7843             __pyx_t_3 = __pyx_t_2;
7844             goto __pyx_L19_bool_binop_done;
7845           }
7846           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
7847           __Pyx_GOTREF(__pyx_t_6);
7848           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 336, __pyx_L1_error)
7849           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7850           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0);
7851           __pyx_t_3 = __pyx_t_2;
7852           __pyx_L19_bool_binop_done:;
7853           if (__pyx_t_3) {
7854             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 336, __pyx_L1_error)
7855             goto __pyx_L10_break;
7856           }
7857           break;
7858           case 'c':
7859           break;
7860           case 'O':
7861           break;
7862           default: break;
7863         }
7864       }
7865     }
7866     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
7867     if (!__pyx_t_2) {
7868     } else {
7869       __pyx_t_3 = __pyx_t_2;
7870       goto __pyx_L22_bool_binop_done;
7871     }
7872     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(float))) != 0);
7873     __pyx_t_3 = __pyx_t_2;
7874     __pyx_L22_bool_binop_done:;
7875     if (__pyx_t_3) {
7876       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(__pyx_v_arg, 0);
7877       __pyx_v_memslice = __pyx_t_8;
7878       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
7879       if (__pyx_t_3) {
7880         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
7881         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 336, __pyx_L1_error)
7882         goto __pyx_L10_break;
7883       }
7884       /*else*/ {
7885         PyErr_Clear();
7886       }
7887     }
7888     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
7889     if (!__pyx_t_2) {
7890     } else {
7891       __pyx_t_3 = __pyx_t_2;
7892       goto __pyx_L26_bool_binop_done;
7893     }
7894     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(double))) != 0);
7895     __pyx_t_3 = __pyx_t_2;
7896     __pyx_L26_bool_binop_done:;
7897     if (__pyx_t_3) {
7898       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(__pyx_v_arg, 0);
7899       __pyx_v_memslice = __pyx_t_8;
7900       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
7901       if (__pyx_t_3) {
7902         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
7903         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 336, __pyx_L1_error)
7904         goto __pyx_L10_break;
7905       }
7906       /*else*/ {
7907         PyErr_Clear();
7908       }
7909     }
7910     if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 336, __pyx_L1_error)
7911     goto __pyx_L10_break;
7912   }
7913   __pyx_L10_break:;
7914   __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
7915   __Pyx_GOTREF(__pyx_t_6);
7916   __pyx_v_candidates = ((PyObject*)__pyx_t_6);
7917   __pyx_t_6 = 0;
7918   __pyx_t_5 = 0;
7919   if (unlikely(__pyx_v_signatures == Py_None)) {
7920     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
7921     __PYX_ERR(0, 336, __pyx_L1_error)
7922   }
7923   __pyx_t_1 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
7924   __Pyx_GOTREF(__pyx_t_1);
7925   __Pyx_XDECREF(__pyx_t_6);
7926   __pyx_t_6 = __pyx_t_1;
7927   __pyx_t_1 = 0;
7928   while (1) {
7929     __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_5, &__pyx_t_1, NULL, NULL, __pyx_t_10);
7930     if (unlikely(__pyx_t_11 == 0)) break;
7931     if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 336, __pyx_L1_error)
7932     __Pyx_GOTREF(__pyx_t_1);
7933     __Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_1);
7934     __pyx_t_1 = 0;
7935     __pyx_v_match_found = 0;
7936     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 336, __pyx_L1_error)
7937     __Pyx_GOTREF(__pyx_t_13);
7938     __pyx_t_14 = NULL;
7939     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
7940       __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
7941       if (likely(__pyx_t_14)) {
7942         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
7943         __Pyx_INCREF(__pyx_t_14);
7944         __Pyx_INCREF(function);
7945         __Pyx_DECREF_SET(__pyx_t_13, function);
7946       }
7947     }
7948     __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_kp_s__3) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__3);
7949     __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
7950     if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 336, __pyx_L1_error)
7951     __Pyx_GOTREF(__pyx_t_12);
7952     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
7953     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_split); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 336, __pyx_L1_error)
7954     __Pyx_GOTREF(__pyx_t_13);
7955     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
7956     __pyx_t_12 = NULL;
7957     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
7958       __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
7959       if (likely(__pyx_t_12)) {
7960         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
7961         __Pyx_INCREF(__pyx_t_12);
7962         __Pyx_INCREF(function);
7963         __Pyx_DECREF_SET(__pyx_t_13, function);
7964       }
7965     }
7966     __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_kp_s__4) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__4);
7967     __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
7968     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
7969     __Pyx_GOTREF(__pyx_t_1);
7970     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
7971     __Pyx_XDECREF_SET(__pyx_v_src_sig, __pyx_t_1);
7972     __pyx_t_1 = 0;
7973     __pyx_t_15 = PyList_GET_SIZE(__pyx_v_dest_sig); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 336, __pyx_L1_error)
7974     __pyx_t_16 = __pyx_t_15;
7975     for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
7976       __pyx_v_i = __pyx_t_17;
7977       __pyx_t_1 = PyList_GET_ITEM(__pyx_v_dest_sig, __pyx_v_i);
7978       __Pyx_INCREF(__pyx_t_1);
7979       __Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_1);
7980       __pyx_t_1 = 0;
7981       __pyx_t_3 = (__pyx_v_dst_type != Py_None);
7982       __pyx_t_2 = (__pyx_t_3 != 0);
7983       if (__pyx_t_2) {
7984         __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
7985         __Pyx_GOTREF(__pyx_t_1);
7986         __pyx_t_13 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 336, __pyx_L1_error)
7987         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7988         __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 336, __pyx_L1_error)
7989         __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
7990         if (__pyx_t_2) {
7991           __pyx_v_match_found = 1;
7992           goto __pyx_L34;
7993         }
7994         /*else*/ {
7995           __pyx_v_match_found = 0;
7996           goto __pyx_L32_break;
7997         }
7998         __pyx_L34:;
7999       }
8000     }
8001     __pyx_L32_break:;
8002     __pyx_t_2 = (__pyx_v_match_found != 0);
8003     if (__pyx_t_2) {
8004       __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 336, __pyx_L1_error)
8005     }
8006   }
8007   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8008   __pyx_t_2 = (PyList_GET_SIZE(__pyx_v_candidates) != 0);
8009   __pyx_t_3 = ((!__pyx_t_2) != 0);
8010   if (__pyx_t_3) {
8011     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
8012     __Pyx_GOTREF(__pyx_t_6);
8013     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
8014     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8015     __PYX_ERR(0, 336, __pyx_L1_error)
8016   }
8017   __pyx_t_9 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 336, __pyx_L1_error)
8018   __pyx_t_3 = ((__pyx_t_9 > 1) != 0);
8019   if (__pyx_t_3) {
8020     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
8021     __Pyx_GOTREF(__pyx_t_6);
8022     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
8023     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8024     __PYX_ERR(0, 336, __pyx_L1_error)
8025   }
8026   /*else*/ {
8027     __Pyx_XDECREF(__pyx_r);
8028     if (unlikely(__pyx_v_signatures == Py_None)) {
8029       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
8030       __PYX_ERR(0, 336, __pyx_L1_error)
8031     }
8032     __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), PyList_GET_ITEM(__pyx_v_candidates, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 336, __pyx_L1_error)
8033     __Pyx_GOTREF(__pyx_t_6);
8034     __pyx_r = __pyx_t_6;
8035     __pyx_t_6 = 0;
8036     goto __pyx_L0;
8037   }
8038 
8039   /* function exit code */
8040   __pyx_L1_error:;
8041   __Pyx_XDECREF(__pyx_t_1);
8042   __Pyx_XDECREF(__pyx_t_6);
8043   __Pyx_XDECREF(__pyx_t_12);
8044   __Pyx_XDECREF(__pyx_t_13);
8045   __Pyx_XDECREF(__pyx_t_14);
8046   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
8047   __pyx_r = NULL;
8048   __pyx_L0:;
8049   __Pyx_XDECREF(__pyx_v_dest_sig);
8050   __Pyx_XDECREF(__pyx_v_ndarray);
8051   __Pyx_XDECREF(__pyx_v_arg);
8052   __Pyx_XDECREF(__pyx_v_dtype);
8053   __Pyx_XDECREF(__pyx_v_arg_base);
8054   __Pyx_XDECREF(__pyx_v_candidates);
8055   __Pyx_XDECREF(__pyx_v_sig);
8056   __Pyx_XDECREF(__pyx_v_src_sig);
8057   __Pyx_XDECREF(__pyx_v_dst_type);
8058   __Pyx_XDECREF(__pyx_v_kwargs);
8059   __Pyx_XGIVEREF(__pyx_r);
8060   __Pyx_RefNannyFinishContext();
8061   return __pyx_r;
8062 }
8063 
8064 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_33__pyx_fuse_0iterate_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8065 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_9iterate_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_3d(__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_grad,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_disp,CYTHON_UNUSED int __pyx_skip_dispatch)8066 static double __pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_3d(__Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_disp, CYTHON_UNUSED int __pyx_skip_dispatch) {
8067   CYTHON_UNUSED PyObject *__pyx_v_ftype = NULL;
8068   int __pyx_v_NUM_NEIGHBORS;
8069   int *__pyx_v_dSlice;
8070   int *__pyx_v_dRow;
8071   int *__pyx_v_dCol;
8072   npy_intp __pyx_v_nslices;
8073   npy_intp __pyx_v_nrows;
8074   npy_intp __pyx_v_ncols;
8075   int __pyx_v_nn;
8076   double *__pyx_v_g;
8077   double *__pyx_v_b;
8078   double *__pyx_v_d;
8079   double *__pyx_v_y;
8080   CYTHON_UNUSED double *__pyx_v_A;
8081   double __pyx_v_xx;
8082   double __pyx_v_yy;
8083   double __pyx_v_zz;
8084   double __pyx_v_opt;
8085   double __pyx_v_nrm2;
8086   CYTHON_UNUSED double __pyx_v_delta;
8087   double __pyx_v_sigmasq;
8088   double __pyx_v_max_displacement;
8089   npy_intp __pyx_v_dr;
8090   npy_intp __pyx_v_ds;
8091   npy_intp __pyx_v_dc;
8092   npy_intp __pyx_v_s;
8093   npy_intp __pyx_v_r;
8094   npy_intp __pyx_v_c;
8095   int __pyx_v_k;
8096   double __pyx_v_tau;
8097   int __pyx_v_is_singular;
8098   double __pyx_r;
8099   __Pyx_RefNannyDeclarations
8100   PyObject *__pyx_t_1 = NULL;
8101   PyObject *__pyx_t_2 = NULL;
8102   PyObject *__pyx_t_3 = NULL;
8103   PyObject *__pyx_t_4 = NULL;
8104   int __pyx_t_5[6];
8105   int __pyx_t_6[6];
8106   int __pyx_t_7[6];
8107   double __pyx_t_8[3];
8108   double __pyx_t_9[3];
8109   double __pyx_t_10[3];
8110   double __pyx_t_11[3];
8111   double __pyx_t_12[6];
8112   npy_intp __pyx_t_13;
8113   npy_intp __pyx_t_14;
8114   npy_intp __pyx_t_15;
8115   npy_intp __pyx_t_16;
8116   npy_intp __pyx_t_17;
8117   npy_intp __pyx_t_18;
8118   npy_intp __pyx_t_19;
8119   npy_intp __pyx_t_20;
8120   npy_intp __pyx_t_21;
8121   Py_ssize_t __pyx_t_22;
8122   Py_ssize_t __pyx_t_23;
8123   Py_ssize_t __pyx_t_24;
8124   Py_ssize_t __pyx_t_25;
8125   double __pyx_t_26;
8126   int __pyx_t_27;
8127   int __pyx_t_28;
8128   int __pyx_t_29;
8129   int __pyx_t_30;
8130   int __pyx_t_31;
8131   long __pyx_t_32;
8132   int __pyx_lineno = 0;
8133   const char *__pyx_filename = NULL;
8134   int __pyx_clineno = 0;
8135   __Pyx_RefNannySetupContext("__pyx_fuse_0iterate_residual_displacement_field_ssd_3d", 0);
8136 
8137   /* "dipy/align/sumsqdiff.pyx":377
8138  *               Vision, 2005. ICCV 2005.
8139  *     """
8140  *     ftype = np.asarray(delta_field).dtype             # <<<<<<<<<<<<<<
8141  *     cdef:
8142  *         int NUM_NEIGHBORS = 6
8143  */
8144   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 377, __pyx_L1_error)
8145   __Pyx_GOTREF(__pyx_t_2);
8146   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 377, __pyx_L1_error)
8147   __Pyx_GOTREF(__pyx_t_3);
8148   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8149   __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 3, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 377, __pyx_L1_error)
8150   __Pyx_GOTREF(__pyx_t_2);
8151   __pyx_t_4 = NULL;
8152   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
8153     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
8154     if (likely(__pyx_t_4)) {
8155       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
8156       __Pyx_INCREF(__pyx_t_4);
8157       __Pyx_INCREF(function);
8158       __Pyx_DECREF_SET(__pyx_t_3, function);
8159     }
8160   }
8161   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
8162   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
8163   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8164   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error)
8165   __Pyx_GOTREF(__pyx_t_1);
8166   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8167   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 377, __pyx_L1_error)
8168   __Pyx_GOTREF(__pyx_t_3);
8169   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8170   __pyx_v_ftype = __pyx_t_3;
8171   __pyx_t_3 = 0;
8172 
8173   /* "dipy/align/sumsqdiff.pyx":379
8174  *     ftype = np.asarray(delta_field).dtype
8175  *     cdef:
8176  *         int NUM_NEIGHBORS = 6             # <<<<<<<<<<<<<<
8177  *         int* dSlice = [-1, 0, 0, 0,  0, 1]
8178  *         int* dRow = [0, -1, 0, 1,  0, 0]
8179  */
8180   __pyx_v_NUM_NEIGHBORS = 6;
8181 
8182   /* "dipy/align/sumsqdiff.pyx":380
8183  *     cdef:
8184  *         int NUM_NEIGHBORS = 6
8185  *         int* dSlice = [-1, 0, 0, 0,  0, 1]             # <<<<<<<<<<<<<<
8186  *         int* dRow = [0, -1, 0, 1,  0, 0]
8187  *         int* dCol = [0,  0, 1, 0, -1, 0]
8188  */
8189   __pyx_t_5[0] = -1;
8190   __pyx_t_5[1] = 0;
8191   __pyx_t_5[2] = 0;
8192   __pyx_t_5[3] = 0;
8193   __pyx_t_5[4] = 0;
8194   __pyx_t_5[5] = 1;
8195   __pyx_v_dSlice = __pyx_t_5;
8196 
8197   /* "dipy/align/sumsqdiff.pyx":381
8198  *         int NUM_NEIGHBORS = 6
8199  *         int* dSlice = [-1, 0, 0, 0,  0, 1]
8200  *         int* dRow = [0, -1, 0, 1,  0, 0]             # <<<<<<<<<<<<<<
8201  *         int* dCol = [0,  0, 1, 0, -1, 0]
8202  *         cnp.npy_intp nslices = delta_field.shape[0]
8203  */
8204   __pyx_t_6[0] = 0;
8205   __pyx_t_6[1] = -1;
8206   __pyx_t_6[2] = 0;
8207   __pyx_t_6[3] = 1;
8208   __pyx_t_6[4] = 0;
8209   __pyx_t_6[5] = 0;
8210   __pyx_v_dRow = __pyx_t_6;
8211 
8212   /* "dipy/align/sumsqdiff.pyx":382
8213  *         int* dSlice = [-1, 0, 0, 0,  0, 1]
8214  *         int* dRow = [0, -1, 0, 1,  0, 0]
8215  *         int* dCol = [0,  0, 1, 0, -1, 0]             # <<<<<<<<<<<<<<
8216  *         cnp.npy_intp nslices = delta_field.shape[0]
8217  *         cnp.npy_intp nrows = delta_field.shape[1]
8218  */
8219   __pyx_t_7[0] = 0;
8220   __pyx_t_7[1] = 0;
8221   __pyx_t_7[2] = 1;
8222   __pyx_t_7[3] = 0;
8223   __pyx_t_7[4] = -1;
8224   __pyx_t_7[5] = 0;
8225   __pyx_v_dCol = __pyx_t_7;
8226 
8227   /* "dipy/align/sumsqdiff.pyx":383
8228  *         int* dRow = [0, -1, 0, 1,  0, 0]
8229  *         int* dCol = [0,  0, 1, 0, -1, 0]
8230  *         cnp.npy_intp nslices = delta_field.shape[0]             # <<<<<<<<<<<<<<
8231  *         cnp.npy_intp nrows = delta_field.shape[1]
8232  *         cnp.npy_intp ncols = delta_field.shape[2]
8233  */
8234   __pyx_v_nslices = (__pyx_v_delta_field.shape[0]);
8235 
8236   /* "dipy/align/sumsqdiff.pyx":384
8237  *         int* dCol = [0,  0, 1, 0, -1, 0]
8238  *         cnp.npy_intp nslices = delta_field.shape[0]
8239  *         cnp.npy_intp nrows = delta_field.shape[1]             # <<<<<<<<<<<<<<
8240  *         cnp.npy_intp ncols = delta_field.shape[2]
8241  *         int nn
8242  */
8243   __pyx_v_nrows = (__pyx_v_delta_field.shape[1]);
8244 
8245   /* "dipy/align/sumsqdiff.pyx":385
8246  *         cnp.npy_intp nslices = delta_field.shape[0]
8247  *         cnp.npy_intp nrows = delta_field.shape[1]
8248  *         cnp.npy_intp ncols = delta_field.shape[2]             # <<<<<<<<<<<<<<
8249  *         int nn
8250  *         double* g = [0, 0, 0]
8251  */
8252   __pyx_v_ncols = (__pyx_v_delta_field.shape[2]);
8253 
8254   /* "dipy/align/sumsqdiff.pyx":387
8255  *         cnp.npy_intp ncols = delta_field.shape[2]
8256  *         int nn
8257  *         double* g = [0, 0, 0]             # <<<<<<<<<<<<<<
8258  *         double* b = [0, 0, 0]
8259  *         double* d = [0, 0, 0]
8260  */
8261   __pyx_t_8[0] = 0.0;
8262   __pyx_t_8[1] = 0.0;
8263   __pyx_t_8[2] = 0.0;
8264   __pyx_v_g = __pyx_t_8;
8265 
8266   /* "dipy/align/sumsqdiff.pyx":388
8267  *         int nn
8268  *         double* g = [0, 0, 0]
8269  *         double* b = [0, 0, 0]             # <<<<<<<<<<<<<<
8270  *         double* d = [0, 0, 0]
8271  *         double* y = [0, 0, 0]
8272  */
8273   __pyx_t_9[0] = 0.0;
8274   __pyx_t_9[1] = 0.0;
8275   __pyx_t_9[2] = 0.0;
8276   __pyx_v_b = __pyx_t_9;
8277 
8278   /* "dipy/align/sumsqdiff.pyx":389
8279  *         double* g = [0, 0, 0]
8280  *         double* b = [0, 0, 0]
8281  *         double* d = [0, 0, 0]             # <<<<<<<<<<<<<<
8282  *         double* y = [0, 0, 0]
8283  *         double* A = [0, 0, 0, 0, 0, 0]
8284  */
8285   __pyx_t_10[0] = 0.0;
8286   __pyx_t_10[1] = 0.0;
8287   __pyx_t_10[2] = 0.0;
8288   __pyx_v_d = __pyx_t_10;
8289 
8290   /* "dipy/align/sumsqdiff.pyx":390
8291  *         double* b = [0, 0, 0]
8292  *         double* d = [0, 0, 0]
8293  *         double* y = [0, 0, 0]             # <<<<<<<<<<<<<<
8294  *         double* A = [0, 0, 0, 0, 0, 0]
8295  *         double xx, yy, zz, opt, nrm2, delta, sigmasq, max_displacement
8296  */
8297   __pyx_t_11[0] = 0.0;
8298   __pyx_t_11[1] = 0.0;
8299   __pyx_t_11[2] = 0.0;
8300   __pyx_v_y = __pyx_t_11;
8301 
8302   /* "dipy/align/sumsqdiff.pyx":391
8303  *         double* d = [0, 0, 0]
8304  *         double* y = [0, 0, 0]
8305  *         double* A = [0, 0, 0, 0, 0, 0]             # <<<<<<<<<<<<<<
8306  *         double xx, yy, zz, opt, nrm2, delta, sigmasq, max_displacement
8307  *         cnp.npy_intp dr, ds, dc, s, r, c
8308  */
8309   __pyx_t_12[0] = 0.0;
8310   __pyx_t_12[1] = 0.0;
8311   __pyx_t_12[2] = 0.0;
8312   __pyx_t_12[3] = 0.0;
8313   __pyx_t_12[4] = 0.0;
8314   __pyx_t_12[5] = 0.0;
8315   __pyx_v_A = __pyx_t_12;
8316 
8317   /* "dipy/align/sumsqdiff.pyx":394
8318  *         double xx, yy, zz, opt, nrm2, delta, sigmasq, max_displacement
8319  *         cnp.npy_intp dr, ds, dc, s, r, c
8320  *     max_displacement = 0             # <<<<<<<<<<<<<<
8321  *
8322  *     with nogil:
8323  */
8324   __pyx_v_max_displacement = 0.0;
8325 
8326   /* "dipy/align/sumsqdiff.pyx":396
8327  *     max_displacement = 0
8328  *
8329  *     with nogil:             # <<<<<<<<<<<<<<
8330  *
8331  *         for s in range(nslices):
8332  */
8333   {
8334       #ifdef WITH_THREAD
8335       PyThreadState *_save;
8336       Py_UNBLOCK_THREADS
8337       __Pyx_FastGIL_Remember();
8338       #endif
8339       /*try:*/ {
8340 
8341         /* "dipy/align/sumsqdiff.pyx":398
8342  *     with nogil:
8343  *
8344  *         for s in range(nslices):             # <<<<<<<<<<<<<<
8345  *             for r in range(nrows):
8346  *                 for c in range(ncols):
8347  */
8348         __pyx_t_13 = __pyx_v_nslices;
8349         __pyx_t_14 = __pyx_t_13;
8350         for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
8351           __pyx_v_s = __pyx_t_15;
8352 
8353           /* "dipy/align/sumsqdiff.pyx":399
8354  *
8355  *         for s in range(nslices):
8356  *             for r in range(nrows):             # <<<<<<<<<<<<<<
8357  *                 for c in range(ncols):
8358  *                     g[0] = grad[s, r, c, 0]
8359  */
8360           __pyx_t_16 = __pyx_v_nrows;
8361           __pyx_t_17 = __pyx_t_16;
8362           for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
8363             __pyx_v_r = __pyx_t_18;
8364 
8365             /* "dipy/align/sumsqdiff.pyx":400
8366  *         for s in range(nslices):
8367  *             for r in range(nrows):
8368  *                 for c in range(ncols):             # <<<<<<<<<<<<<<
8369  *                     g[0] = grad[s, r, c, 0]
8370  *                     g[1] = grad[s, r, c, 1]
8371  */
8372             __pyx_t_19 = __pyx_v_ncols;
8373             __pyx_t_20 = __pyx_t_19;
8374             for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) {
8375               __pyx_v_c = __pyx_t_21;
8376 
8377               /* "dipy/align/sumsqdiff.pyx":401
8378  *             for r in range(nrows):
8379  *                 for c in range(ncols):
8380  *                     g[0] = grad[s, r, c, 0]             # <<<<<<<<<<<<<<
8381  *                     g[1] = grad[s, r, c, 1]
8382  *                     g[2] = grad[s, r, c, 2]
8383  */
8384               __pyx_t_22 = __pyx_v_s;
8385               __pyx_t_23 = __pyx_v_r;
8386               __pyx_t_24 = __pyx_v_c;
8387               __pyx_t_25 = 0;
8388               (__pyx_v_g[0]) = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_22 * __pyx_v_grad.strides[0]) ) + __pyx_t_23 * __pyx_v_grad.strides[1]) ) + __pyx_t_24 * __pyx_v_grad.strides[2]) ) + __pyx_t_25 * __pyx_v_grad.strides[3]) )));
8389 
8390               /* "dipy/align/sumsqdiff.pyx":402
8391  *                 for c in range(ncols):
8392  *                     g[0] = grad[s, r, c, 0]
8393  *                     g[1] = grad[s, r, c, 1]             # <<<<<<<<<<<<<<
8394  *                     g[2] = grad[s, r, c, 2]
8395  *                     delta = delta_field[s, r, c]
8396  */
8397               __pyx_t_25 = __pyx_v_s;
8398               __pyx_t_24 = __pyx_v_r;
8399               __pyx_t_23 = __pyx_v_c;
8400               __pyx_t_22 = 1;
8401               (__pyx_v_g[1]) = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_25 * __pyx_v_grad.strides[0]) ) + __pyx_t_24 * __pyx_v_grad.strides[1]) ) + __pyx_t_23 * __pyx_v_grad.strides[2]) ) + __pyx_t_22 * __pyx_v_grad.strides[3]) )));
8402 
8403               /* "dipy/align/sumsqdiff.pyx":403
8404  *                     g[0] = grad[s, r, c, 0]
8405  *                     g[1] = grad[s, r, c, 1]
8406  *                     g[2] = grad[s, r, c, 2]             # <<<<<<<<<<<<<<
8407  *                     delta = delta_field[s, r, c]
8408  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
8409  */
8410               __pyx_t_22 = __pyx_v_s;
8411               __pyx_t_23 = __pyx_v_r;
8412               __pyx_t_24 = __pyx_v_c;
8413               __pyx_t_25 = 2;
8414               (__pyx_v_g[2]) = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_22 * __pyx_v_grad.strides[0]) ) + __pyx_t_23 * __pyx_v_grad.strides[1]) ) + __pyx_t_24 * __pyx_v_grad.strides[2]) ) + __pyx_t_25 * __pyx_v_grad.strides[3]) )));
8415 
8416               /* "dipy/align/sumsqdiff.pyx":404
8417  *                     g[1] = grad[s, r, c, 1]
8418  *                     g[2] = grad[s, r, c, 2]
8419  *                     delta = delta_field[s, r, c]             # <<<<<<<<<<<<<<
8420  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
8421  *                     if(target is None):
8422  */
8423               __pyx_t_25 = __pyx_v_s;
8424               __pyx_t_24 = __pyx_v_r;
8425               __pyx_t_23 = __pyx_v_c;
8426               __pyx_v_delta = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_25 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_24 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_23 * __pyx_v_delta_field.strides[2]) )));
8427 
8428               /* "dipy/align/sumsqdiff.pyx":405
8429  *                     g[2] = grad[s, r, c, 2]
8430  *                     delta = delta_field[s, r, c]
8431  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1             # <<<<<<<<<<<<<<
8432  *                     if(target is None):
8433  *                         b[0] = delta_field[s, r, c] * g[0]
8434  */
8435               if (((((PyObject *) __pyx_v_sigmasq_field.memview) != Py_None) != 0)) {
8436                 __pyx_t_23 = __pyx_v_s;
8437                 __pyx_t_24 = __pyx_v_r;
8438                 __pyx_t_25 = __pyx_v_c;
8439                 __pyx_t_26 = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_sigmasq_field.data + __pyx_t_23 * __pyx_v_sigmasq_field.strides[0]) ) + __pyx_t_24 * __pyx_v_sigmasq_field.strides[1]) ) + __pyx_t_25 * __pyx_v_sigmasq_field.strides[2]) )));
8440               } else {
8441                 __pyx_t_26 = 1.0;
8442               }
8443               __pyx_v_sigmasq = __pyx_t_26;
8444 
8445               /* "dipy/align/sumsqdiff.pyx":406
8446  *                     delta = delta_field[s, r, c]
8447  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
8448  *                     if(target is None):             # <<<<<<<<<<<<<<
8449  *                         b[0] = delta_field[s, r, c] * g[0]
8450  *                         b[1] = delta_field[s, r, c] * g[1]
8451  */
8452               __pyx_t_27 = ((((PyObject *) __pyx_v_target.memview) == Py_None) != 0);
8453               if (__pyx_t_27) {
8454 
8455                 /* "dipy/align/sumsqdiff.pyx":407
8456  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
8457  *                     if(target is None):
8458  *                         b[0] = delta_field[s, r, c] * g[0]             # <<<<<<<<<<<<<<
8459  *                         b[1] = delta_field[s, r, c] * g[1]
8460  *                         b[2] = delta_field[s, r, c] * g[2]
8461  */
8462                 __pyx_t_25 = __pyx_v_s;
8463                 __pyx_t_24 = __pyx_v_r;
8464                 __pyx_t_23 = __pyx_v_c;
8465                 (__pyx_v_b[0]) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_25 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_24 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_23 * __pyx_v_delta_field.strides[2]) ))) * (__pyx_v_g[0]));
8466 
8467                 /* "dipy/align/sumsqdiff.pyx":408
8468  *                     if(target is None):
8469  *                         b[0] = delta_field[s, r, c] * g[0]
8470  *                         b[1] = delta_field[s, r, c] * g[1]             # <<<<<<<<<<<<<<
8471  *                         b[2] = delta_field[s, r, c] * g[2]
8472  *                     else:
8473  */
8474                 __pyx_t_23 = __pyx_v_s;
8475                 __pyx_t_24 = __pyx_v_r;
8476                 __pyx_t_25 = __pyx_v_c;
8477                 (__pyx_v_b[1]) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_23 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_24 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_25 * __pyx_v_delta_field.strides[2]) ))) * (__pyx_v_g[1]));
8478 
8479                 /* "dipy/align/sumsqdiff.pyx":409
8480  *                         b[0] = delta_field[s, r, c] * g[0]
8481  *                         b[1] = delta_field[s, r, c] * g[1]
8482  *                         b[2] = delta_field[s, r, c] * g[2]             # <<<<<<<<<<<<<<
8483  *                     else:
8484  *                         b[0] = target[s, r, c, 0]
8485  */
8486                 __pyx_t_25 = __pyx_v_s;
8487                 __pyx_t_24 = __pyx_v_r;
8488                 __pyx_t_23 = __pyx_v_c;
8489                 (__pyx_v_b[2]) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_25 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_24 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_23 * __pyx_v_delta_field.strides[2]) ))) * (__pyx_v_g[2]));
8490 
8491                 /* "dipy/align/sumsqdiff.pyx":406
8492  *                     delta = delta_field[s, r, c]
8493  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
8494  *                     if(target is None):             # <<<<<<<<<<<<<<
8495  *                         b[0] = delta_field[s, r, c] * g[0]
8496  *                         b[1] = delta_field[s, r, c] * g[1]
8497  */
8498                 goto __pyx_L12;
8499               }
8500 
8501               /* "dipy/align/sumsqdiff.pyx":411
8502  *                         b[2] = delta_field[s, r, c] * g[2]
8503  *                     else:
8504  *                         b[0] = target[s, r, c, 0]             # <<<<<<<<<<<<<<
8505  *                         b[1] = target[s, r, c, 1]
8506  *                         b[2] = target[s, r, c, 2]
8507  */
8508               /*else*/ {
8509                 __pyx_t_23 = __pyx_v_s;
8510                 __pyx_t_24 = __pyx_v_r;
8511                 __pyx_t_25 = __pyx_v_c;
8512                 __pyx_t_22 = 0;
8513                 (__pyx_v_b[0]) = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_23 * __pyx_v_target.strides[0]) ) + __pyx_t_24 * __pyx_v_target.strides[1]) ) + __pyx_t_25 * __pyx_v_target.strides[2]) ) + __pyx_t_22 * __pyx_v_target.strides[3]) )));
8514 
8515                 /* "dipy/align/sumsqdiff.pyx":412
8516  *                     else:
8517  *                         b[0] = target[s, r, c, 0]
8518  *                         b[1] = target[s, r, c, 1]             # <<<<<<<<<<<<<<
8519  *                         b[2] = target[s, r, c, 2]
8520  *                     nn = 0
8521  */
8522                 __pyx_t_22 = __pyx_v_s;
8523                 __pyx_t_25 = __pyx_v_r;
8524                 __pyx_t_24 = __pyx_v_c;
8525                 __pyx_t_23 = 1;
8526                 (__pyx_v_b[1]) = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_22 * __pyx_v_target.strides[0]) ) + __pyx_t_25 * __pyx_v_target.strides[1]) ) + __pyx_t_24 * __pyx_v_target.strides[2]) ) + __pyx_t_23 * __pyx_v_target.strides[3]) )));
8527 
8528                 /* "dipy/align/sumsqdiff.pyx":413
8529  *                         b[0] = target[s, r, c, 0]
8530  *                         b[1] = target[s, r, c, 1]
8531  *                         b[2] = target[s, r, c, 2]             # <<<<<<<<<<<<<<
8532  *                     nn = 0
8533  *                     y[0] = 0
8534  */
8535                 __pyx_t_23 = __pyx_v_s;
8536                 __pyx_t_24 = __pyx_v_r;
8537                 __pyx_t_25 = __pyx_v_c;
8538                 __pyx_t_22 = 2;
8539                 (__pyx_v_b[2]) = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_23 * __pyx_v_target.strides[0]) ) + __pyx_t_24 * __pyx_v_target.strides[1]) ) + __pyx_t_25 * __pyx_v_target.strides[2]) ) + __pyx_t_22 * __pyx_v_target.strides[3]) )));
8540               }
8541               __pyx_L12:;
8542 
8543               /* "dipy/align/sumsqdiff.pyx":414
8544  *                         b[1] = target[s, r, c, 1]
8545  *                         b[2] = target[s, r, c, 2]
8546  *                     nn = 0             # <<<<<<<<<<<<<<
8547  *                     y[0] = 0
8548  *                     y[1] = 0
8549  */
8550               __pyx_v_nn = 0;
8551 
8552               /* "dipy/align/sumsqdiff.pyx":415
8553  *                         b[2] = target[s, r, c, 2]
8554  *                     nn = 0
8555  *                     y[0] = 0             # <<<<<<<<<<<<<<
8556  *                     y[1] = 0
8557  *                     y[2] = 0
8558  */
8559               (__pyx_v_y[0]) = 0.0;
8560 
8561               /* "dipy/align/sumsqdiff.pyx":416
8562  *                     nn = 0
8563  *                     y[0] = 0
8564  *                     y[1] = 0             # <<<<<<<<<<<<<<
8565  *                     y[2] = 0
8566  *                     for k in range(NUM_NEIGHBORS):
8567  */
8568               (__pyx_v_y[1]) = 0.0;
8569 
8570               /* "dipy/align/sumsqdiff.pyx":417
8571  *                     y[0] = 0
8572  *                     y[1] = 0
8573  *                     y[2] = 0             # <<<<<<<<<<<<<<
8574  *                     for k in range(NUM_NEIGHBORS):
8575  *                         ds = s + dSlice[k]
8576  */
8577               (__pyx_v_y[2]) = 0.0;
8578 
8579               /* "dipy/align/sumsqdiff.pyx":418
8580  *                     y[1] = 0
8581  *                     y[2] = 0
8582  *                     for k in range(NUM_NEIGHBORS):             # <<<<<<<<<<<<<<
8583  *                         ds = s + dSlice[k]
8584  *                         if((ds < 0) or (ds >= nslices)):
8585  */
8586               __pyx_t_28 = __pyx_v_NUM_NEIGHBORS;
8587               __pyx_t_29 = __pyx_t_28;
8588               for (__pyx_t_30 = 0; __pyx_t_30 < __pyx_t_29; __pyx_t_30+=1) {
8589                 __pyx_v_k = __pyx_t_30;
8590 
8591                 /* "dipy/align/sumsqdiff.pyx":419
8592  *                     y[2] = 0
8593  *                     for k in range(NUM_NEIGHBORS):
8594  *                         ds = s + dSlice[k]             # <<<<<<<<<<<<<<
8595  *                         if((ds < 0) or (ds >= nslices)):
8596  *                             continue
8597  */
8598                 __pyx_v_ds = (__pyx_v_s + (__pyx_v_dSlice[__pyx_v_k]));
8599 
8600                 /* "dipy/align/sumsqdiff.pyx":420
8601  *                     for k in range(NUM_NEIGHBORS):
8602  *                         ds = s + dSlice[k]
8603  *                         if((ds < 0) or (ds >= nslices)):             # <<<<<<<<<<<<<<
8604  *                             continue
8605  *                         dr = r + dRow[k]
8606  */
8607                 __pyx_t_31 = ((__pyx_v_ds < 0) != 0);
8608                 if (!__pyx_t_31) {
8609                 } else {
8610                   __pyx_t_27 = __pyx_t_31;
8611                   goto __pyx_L16_bool_binop_done;
8612                 }
8613                 __pyx_t_31 = ((__pyx_v_ds >= __pyx_v_nslices) != 0);
8614                 __pyx_t_27 = __pyx_t_31;
8615                 __pyx_L16_bool_binop_done:;
8616                 if (__pyx_t_27) {
8617 
8618                   /* "dipy/align/sumsqdiff.pyx":421
8619  *                         ds = s + dSlice[k]
8620  *                         if((ds < 0) or (ds >= nslices)):
8621  *                             continue             # <<<<<<<<<<<<<<
8622  *                         dr = r + dRow[k]
8623  *                         if((dr < 0) or (dr >= nrows)):
8624  */
8625                   goto __pyx_L13_continue;
8626 
8627                   /* "dipy/align/sumsqdiff.pyx":420
8628  *                     for k in range(NUM_NEIGHBORS):
8629  *                         ds = s + dSlice[k]
8630  *                         if((ds < 0) or (ds >= nslices)):             # <<<<<<<<<<<<<<
8631  *                             continue
8632  *                         dr = r + dRow[k]
8633  */
8634                 }
8635 
8636                 /* "dipy/align/sumsqdiff.pyx":422
8637  *                         if((ds < 0) or (ds >= nslices)):
8638  *                             continue
8639  *                         dr = r + dRow[k]             # <<<<<<<<<<<<<<
8640  *                         if((dr < 0) or (dr >= nrows)):
8641  *                             continue
8642  */
8643                 __pyx_v_dr = (__pyx_v_r + (__pyx_v_dRow[__pyx_v_k]));
8644 
8645                 /* "dipy/align/sumsqdiff.pyx":423
8646  *                             continue
8647  *                         dr = r + dRow[k]
8648  *                         if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
8649  *                             continue
8650  *                         dc = c + dCol[k]
8651  */
8652                 __pyx_t_31 = ((__pyx_v_dr < 0) != 0);
8653                 if (!__pyx_t_31) {
8654                 } else {
8655                   __pyx_t_27 = __pyx_t_31;
8656                   goto __pyx_L19_bool_binop_done;
8657                 }
8658                 __pyx_t_31 = ((__pyx_v_dr >= __pyx_v_nrows) != 0);
8659                 __pyx_t_27 = __pyx_t_31;
8660                 __pyx_L19_bool_binop_done:;
8661                 if (__pyx_t_27) {
8662 
8663                   /* "dipy/align/sumsqdiff.pyx":424
8664  *                         dr = r + dRow[k]
8665  *                         if((dr < 0) or (dr >= nrows)):
8666  *                             continue             # <<<<<<<<<<<<<<
8667  *                         dc = c + dCol[k]
8668  *                         if((dc < 0) or (dc >= ncols)):
8669  */
8670                   goto __pyx_L13_continue;
8671 
8672                   /* "dipy/align/sumsqdiff.pyx":423
8673  *                             continue
8674  *                         dr = r + dRow[k]
8675  *                         if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
8676  *                             continue
8677  *                         dc = c + dCol[k]
8678  */
8679                 }
8680 
8681                 /* "dipy/align/sumsqdiff.pyx":425
8682  *                         if((dr < 0) or (dr >= nrows)):
8683  *                             continue
8684  *                         dc = c + dCol[k]             # <<<<<<<<<<<<<<
8685  *                         if((dc < 0) or (dc >= ncols)):
8686  *                             continue
8687  */
8688                 __pyx_v_dc = (__pyx_v_c + (__pyx_v_dCol[__pyx_v_k]));
8689 
8690                 /* "dipy/align/sumsqdiff.pyx":426
8691  *                             continue
8692  *                         dc = c + dCol[k]
8693  *                         if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
8694  *                             continue
8695  *                         nn += 1
8696  */
8697                 __pyx_t_31 = ((__pyx_v_dc < 0) != 0);
8698                 if (!__pyx_t_31) {
8699                 } else {
8700                   __pyx_t_27 = __pyx_t_31;
8701                   goto __pyx_L22_bool_binop_done;
8702                 }
8703                 __pyx_t_31 = ((__pyx_v_dc >= __pyx_v_ncols) != 0);
8704                 __pyx_t_27 = __pyx_t_31;
8705                 __pyx_L22_bool_binop_done:;
8706                 if (__pyx_t_27) {
8707 
8708                   /* "dipy/align/sumsqdiff.pyx":427
8709  *                         dc = c + dCol[k]
8710  *                         if((dc < 0) or (dc >= ncols)):
8711  *                             continue             # <<<<<<<<<<<<<<
8712  *                         nn += 1
8713  *                         y[0] += disp[ds, dr, dc, 0]
8714  */
8715                   goto __pyx_L13_continue;
8716 
8717                   /* "dipy/align/sumsqdiff.pyx":426
8718  *                             continue
8719  *                         dc = c + dCol[k]
8720  *                         if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
8721  *                             continue
8722  *                         nn += 1
8723  */
8724                 }
8725 
8726                 /* "dipy/align/sumsqdiff.pyx":428
8727  *                         if((dc < 0) or (dc >= ncols)):
8728  *                             continue
8729  *                         nn += 1             # <<<<<<<<<<<<<<
8730  *                         y[0] += disp[ds, dr, dc, 0]
8731  *                         y[1] += disp[ds, dr, dc, 1]
8732  */
8733                 __pyx_v_nn = (__pyx_v_nn + 1);
8734 
8735                 /* "dipy/align/sumsqdiff.pyx":429
8736  *                             continue
8737  *                         nn += 1
8738  *                         y[0] += disp[ds, dr, dc, 0]             # <<<<<<<<<<<<<<
8739  *                         y[1] += disp[ds, dr, dc, 1]
8740  *                         y[2] += disp[ds, dr, dc, 2]
8741  */
8742                 __pyx_t_32 = 0;
8743                 __pyx_t_22 = __pyx_v_ds;
8744                 __pyx_t_25 = __pyx_v_dr;
8745                 __pyx_t_24 = __pyx_v_dc;
8746                 __pyx_t_23 = 0;
8747                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) ))));
8748 
8749                 /* "dipy/align/sumsqdiff.pyx":430
8750  *                         nn += 1
8751  *                         y[0] += disp[ds, dr, dc, 0]
8752  *                         y[1] += disp[ds, dr, dc, 1]             # <<<<<<<<<<<<<<
8753  *                         y[2] += disp[ds, dr, dc, 2]
8754  *                     if dpy_isinf(sigmasq) != 0:
8755  */
8756                 __pyx_t_32 = 1;
8757                 __pyx_t_23 = __pyx_v_ds;
8758                 __pyx_t_24 = __pyx_v_dr;
8759                 __pyx_t_25 = __pyx_v_dc;
8760                 __pyx_t_22 = 1;
8761                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) ))));
8762 
8763                 /* "dipy/align/sumsqdiff.pyx":431
8764  *                         y[0] += disp[ds, dr, dc, 0]
8765  *                         y[1] += disp[ds, dr, dc, 1]
8766  *                         y[2] += disp[ds, dr, dc, 2]             # <<<<<<<<<<<<<<
8767  *                     if dpy_isinf(sigmasq) != 0:
8768  *                         xx = disp[s, r, c, 0]
8769  */
8770                 __pyx_t_32 = 2;
8771                 __pyx_t_22 = __pyx_v_ds;
8772                 __pyx_t_25 = __pyx_v_dr;
8773                 __pyx_t_24 = __pyx_v_dc;
8774                 __pyx_t_23 = 2;
8775                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) ))));
8776                 __pyx_L13_continue:;
8777               }
8778 
8779               /* "dipy/align/sumsqdiff.pyx":432
8780  *                         y[1] += disp[ds, dr, dc, 1]
8781  *                         y[2] += disp[ds, dr, dc, 2]
8782  *                     if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
8783  *                         xx = disp[s, r, c, 0]
8784  *                         yy = disp[s, r, c, 1]
8785  */
8786               __pyx_t_27 = ((dpy_isinf(__pyx_v_sigmasq) != 0) != 0);
8787               if (__pyx_t_27) {
8788 
8789                 /* "dipy/align/sumsqdiff.pyx":433
8790  *                         y[2] += disp[ds, dr, dc, 2]
8791  *                     if dpy_isinf(sigmasq) != 0:
8792  *                         xx = disp[s, r, c, 0]             # <<<<<<<<<<<<<<
8793  *                         yy = disp[s, r, c, 1]
8794  *                         zz = disp[s, r, c, 2]
8795  */
8796                 __pyx_t_23 = __pyx_v_s;
8797                 __pyx_t_24 = __pyx_v_r;
8798                 __pyx_t_25 = __pyx_v_c;
8799                 __pyx_t_22 = 0;
8800                 __pyx_v_xx = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )));
8801 
8802                 /* "dipy/align/sumsqdiff.pyx":434
8803  *                     if dpy_isinf(sigmasq) != 0:
8804  *                         xx = disp[s, r, c, 0]
8805  *                         yy = disp[s, r, c, 1]             # <<<<<<<<<<<<<<
8806  *                         zz = disp[s, r, c, 2]
8807  *                         disp[s, r, c, 0] = y[0] / nn
8808  */
8809                 __pyx_t_22 = __pyx_v_s;
8810                 __pyx_t_25 = __pyx_v_r;
8811                 __pyx_t_24 = __pyx_v_c;
8812                 __pyx_t_23 = 1;
8813                 __pyx_v_yy = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )));
8814 
8815                 /* "dipy/align/sumsqdiff.pyx":435
8816  *                         xx = disp[s, r, c, 0]
8817  *                         yy = disp[s, r, c, 1]
8818  *                         zz = disp[s, r, c, 2]             # <<<<<<<<<<<<<<
8819  *                         disp[s, r, c, 0] = y[0] / nn
8820  *                         disp[s, r, c, 1] = y[1] / nn
8821  */
8822                 __pyx_t_23 = __pyx_v_s;
8823                 __pyx_t_24 = __pyx_v_r;
8824                 __pyx_t_25 = __pyx_v_c;
8825                 __pyx_t_22 = 2;
8826                 __pyx_v_zz = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )));
8827 
8828                 /* "dipy/align/sumsqdiff.pyx":436
8829  *                         yy = disp[s, r, c, 1]
8830  *                         zz = disp[s, r, c, 2]
8831  *                         disp[s, r, c, 0] = y[0] / nn             # <<<<<<<<<<<<<<
8832  *                         disp[s, r, c, 1] = y[1] / nn
8833  *                         disp[s, r, c, 2] = y[2] / nn
8834  */
8835                 __pyx_t_22 = __pyx_v_s;
8836                 __pyx_t_25 = __pyx_v_r;
8837                 __pyx_t_24 = __pyx_v_c;
8838                 __pyx_t_23 = 0;
8839                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_y[0]) / ((double)__pyx_v_nn));
8840 
8841                 /* "dipy/align/sumsqdiff.pyx":437
8842  *                         zz = disp[s, r, c, 2]
8843  *                         disp[s, r, c, 0] = y[0] / nn
8844  *                         disp[s, r, c, 1] = y[1] / nn             # <<<<<<<<<<<<<<
8845  *                         disp[s, r, c, 2] = y[2] / nn
8846  *                         xx -= disp[s, r, c, 0]
8847  */
8848                 __pyx_t_23 = __pyx_v_s;
8849                 __pyx_t_24 = __pyx_v_r;
8850                 __pyx_t_25 = __pyx_v_c;
8851                 __pyx_t_22 = 1;
8852                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_y[1]) / ((double)__pyx_v_nn));
8853 
8854                 /* "dipy/align/sumsqdiff.pyx":438
8855  *                         disp[s, r, c, 0] = y[0] / nn
8856  *                         disp[s, r, c, 1] = y[1] / nn
8857  *                         disp[s, r, c, 2] = y[2] / nn             # <<<<<<<<<<<<<<
8858  *                         xx -= disp[s, r, c, 0]
8859  *                         yy -= disp[s, r, c, 1]
8860  */
8861                 __pyx_t_22 = __pyx_v_s;
8862                 __pyx_t_25 = __pyx_v_r;
8863                 __pyx_t_24 = __pyx_v_c;
8864                 __pyx_t_23 = 2;
8865                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_y[2]) / ((double)__pyx_v_nn));
8866 
8867                 /* "dipy/align/sumsqdiff.pyx":439
8868  *                         disp[s, r, c, 1] = y[1] / nn
8869  *                         disp[s, r, c, 2] = y[2] / nn
8870  *                         xx -= disp[s, r, c, 0]             # <<<<<<<<<<<<<<
8871  *                         yy -= disp[s, r, c, 1]
8872  *                         zz -= disp[s, r, c, 2]
8873  */
8874                 __pyx_t_23 = __pyx_v_s;
8875                 __pyx_t_24 = __pyx_v_r;
8876                 __pyx_t_25 = __pyx_v_c;
8877                 __pyx_t_22 = 0;
8878                 __pyx_v_xx = (__pyx_v_xx - (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) ))));
8879 
8880                 /* "dipy/align/sumsqdiff.pyx":440
8881  *                         disp[s, r, c, 2] = y[2] / nn
8882  *                         xx -= disp[s, r, c, 0]
8883  *                         yy -= disp[s, r, c, 1]             # <<<<<<<<<<<<<<
8884  *                         zz -= disp[s, r, c, 2]
8885  *                         opt = xx * xx + yy * yy + zz * zz
8886  */
8887                 __pyx_t_22 = __pyx_v_s;
8888                 __pyx_t_25 = __pyx_v_r;
8889                 __pyx_t_24 = __pyx_v_c;
8890                 __pyx_t_23 = 1;
8891                 __pyx_v_yy = (__pyx_v_yy - (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) ))));
8892 
8893                 /* "dipy/align/sumsqdiff.pyx":441
8894  *                         xx -= disp[s, r, c, 0]
8895  *                         yy -= disp[s, r, c, 1]
8896  *                         zz -= disp[s, r, c, 2]             # <<<<<<<<<<<<<<
8897  *                         opt = xx * xx + yy * yy + zz * zz
8898  *                         if(max_displacement < opt):
8899  */
8900                 __pyx_t_23 = __pyx_v_s;
8901                 __pyx_t_24 = __pyx_v_r;
8902                 __pyx_t_25 = __pyx_v_c;
8903                 __pyx_t_22 = 2;
8904                 __pyx_v_zz = (__pyx_v_zz - (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) ))));
8905 
8906                 /* "dipy/align/sumsqdiff.pyx":442
8907  *                         yy -= disp[s, r, c, 1]
8908  *                         zz -= disp[s, r, c, 2]
8909  *                         opt = xx * xx + yy * yy + zz * zz             # <<<<<<<<<<<<<<
8910  *                         if(max_displacement < opt):
8911  *                             max_displacement = opt
8912  */
8913                 __pyx_v_opt = (((__pyx_v_xx * __pyx_v_xx) + (__pyx_v_yy * __pyx_v_yy)) + (__pyx_v_zz * __pyx_v_zz));
8914 
8915                 /* "dipy/align/sumsqdiff.pyx":443
8916  *                         zz -= disp[s, r, c, 2]
8917  *                         opt = xx * xx + yy * yy + zz * zz
8918  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
8919  *                             max_displacement = opt
8920  *                     elif(sigmasq < 1e-9):
8921  */
8922                 __pyx_t_27 = ((__pyx_v_max_displacement < __pyx_v_opt) != 0);
8923                 if (__pyx_t_27) {
8924 
8925                   /* "dipy/align/sumsqdiff.pyx":444
8926  *                         opt = xx * xx + yy * yy + zz * zz
8927  *                         if(max_displacement < opt):
8928  *                             max_displacement = opt             # <<<<<<<<<<<<<<
8929  *                     elif(sigmasq < 1e-9):
8930  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
8931  */
8932                   __pyx_v_max_displacement = __pyx_v_opt;
8933 
8934                   /* "dipy/align/sumsqdiff.pyx":443
8935  *                         zz -= disp[s, r, c, 2]
8936  *                         opt = xx * xx + yy * yy + zz * zz
8937  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
8938  *                             max_displacement = opt
8939  *                     elif(sigmasq < 1e-9):
8940  */
8941                 }
8942 
8943                 /* "dipy/align/sumsqdiff.pyx":432
8944  *                         y[1] += disp[ds, dr, dc, 1]
8945  *                         y[2] += disp[ds, dr, dc, 2]
8946  *                     if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
8947  *                         xx = disp[s, r, c, 0]
8948  *                         yy = disp[s, r, c, 1]
8949  */
8950                 goto __pyx_L24;
8951               }
8952 
8953               /* "dipy/align/sumsqdiff.pyx":445
8954  *                         if(max_displacement < opt):
8955  *                             max_displacement = opt
8956  *                     elif(sigmasq < 1e-9):             # <<<<<<<<<<<<<<
8957  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
8958  *                             if(nrm2 < 1e-9):
8959  */
8960               __pyx_t_27 = ((__pyx_v_sigmasq < 1e-9) != 0);
8961               if (__pyx_t_27) {
8962 
8963                 /* "dipy/align/sumsqdiff.pyx":446
8964  *                             max_displacement = opt
8965  *                     elif(sigmasq < 1e-9):
8966  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2             # <<<<<<<<<<<<<<
8967  *                             if(nrm2 < 1e-9):
8968  *                                 disp[s, r, c, 0] = 0
8969  */
8970                 __pyx_v_nrm2 = ((pow((__pyx_v_g[0]), 2.0) + pow((__pyx_v_g[1]), 2.0)) + pow((__pyx_v_g[2]), 2.0));
8971 
8972                 /* "dipy/align/sumsqdiff.pyx":447
8973  *                     elif(sigmasq < 1e-9):
8974  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
8975  *                             if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
8976  *                                 disp[s, r, c, 0] = 0
8977  *                                 disp[s, r, c, 1] = 0
8978  */
8979                 __pyx_t_27 = ((__pyx_v_nrm2 < 1e-9) != 0);
8980                 if (__pyx_t_27) {
8981 
8982                   /* "dipy/align/sumsqdiff.pyx":448
8983  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
8984  *                             if(nrm2 < 1e-9):
8985  *                                 disp[s, r, c, 0] = 0             # <<<<<<<<<<<<<<
8986  *                                 disp[s, r, c, 1] = 0
8987  *                                 disp[s, r, c, 2] = 0
8988  */
8989                   __pyx_t_22 = __pyx_v_s;
8990                   __pyx_t_25 = __pyx_v_r;
8991                   __pyx_t_24 = __pyx_v_c;
8992                   __pyx_t_23 = 0;
8993                   *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = 0.0;
8994 
8995                   /* "dipy/align/sumsqdiff.pyx":449
8996  *                             if(nrm2 < 1e-9):
8997  *                                 disp[s, r, c, 0] = 0
8998  *                                 disp[s, r, c, 1] = 0             # <<<<<<<<<<<<<<
8999  *                                 disp[s, r, c, 2] = 0
9000  *                             else:
9001  */
9002                   __pyx_t_23 = __pyx_v_s;
9003                   __pyx_t_24 = __pyx_v_r;
9004                   __pyx_t_25 = __pyx_v_c;
9005                   __pyx_t_22 = 1;
9006                   *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = 0.0;
9007 
9008                   /* "dipy/align/sumsqdiff.pyx":450
9009  *                                 disp[s, r, c, 0] = 0
9010  *                                 disp[s, r, c, 1] = 0
9011  *                                 disp[s, r, c, 2] = 0             # <<<<<<<<<<<<<<
9012  *                             else:
9013  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
9014  */
9015                   __pyx_t_22 = __pyx_v_s;
9016                   __pyx_t_25 = __pyx_v_r;
9017                   __pyx_t_24 = __pyx_v_c;
9018                   __pyx_t_23 = 2;
9019                   *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = 0.0;
9020 
9021                   /* "dipy/align/sumsqdiff.pyx":447
9022  *                     elif(sigmasq < 1e-9):
9023  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
9024  *                             if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
9025  *                                 disp[s, r, c, 0] = 0
9026  *                                 disp[s, r, c, 1] = 0
9027  */
9028                   goto __pyx_L26;
9029                 }
9030 
9031                 /* "dipy/align/sumsqdiff.pyx":452
9032  *                                 disp[s, r, c, 2] = 0
9033  *                             else:
9034  *                                 disp[s, r, c, 0] = (b[0]) / nrm2             # <<<<<<<<<<<<<<
9035  *                                 disp[s, r, c, 1] = (b[1]) / nrm2
9036  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
9037  */
9038                 /*else*/ {
9039                   __pyx_t_23 = __pyx_v_s;
9040                   __pyx_t_24 = __pyx_v_r;
9041                   __pyx_t_25 = __pyx_v_c;
9042                   __pyx_t_22 = 0;
9043                   *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[0]) / __pyx_v_nrm2);
9044 
9045                   /* "dipy/align/sumsqdiff.pyx":453
9046  *                             else:
9047  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
9048  *                                 disp[s, r, c, 1] = (b[1]) / nrm2             # <<<<<<<<<<<<<<
9049  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
9050  *                     else:
9051  */
9052                   __pyx_t_22 = __pyx_v_s;
9053                   __pyx_t_25 = __pyx_v_r;
9054                   __pyx_t_24 = __pyx_v_c;
9055                   __pyx_t_23 = 1;
9056                   *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[1]) / __pyx_v_nrm2);
9057 
9058                   /* "dipy/align/sumsqdiff.pyx":454
9059  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
9060  *                                 disp[s, r, c, 1] = (b[1]) / nrm2
9061  *                                 disp[s, r, c, 2] = (b[2]) / nrm2             # <<<<<<<<<<<<<<
9062  *                     else:
9063  *                         tau = sigmasq * lambda_param * nn
9064  */
9065                   __pyx_t_23 = __pyx_v_s;
9066                   __pyx_t_24 = __pyx_v_r;
9067                   __pyx_t_25 = __pyx_v_c;
9068                   __pyx_t_22 = 2;
9069                   *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[2]) / __pyx_v_nrm2);
9070                 }
9071                 __pyx_L26:;
9072 
9073                 /* "dipy/align/sumsqdiff.pyx":445
9074  *                         if(max_displacement < opt):
9075  *                             max_displacement = opt
9076  *                     elif(sigmasq < 1e-9):             # <<<<<<<<<<<<<<
9077  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
9078  *                             if(nrm2 < 1e-9):
9079  */
9080                 goto __pyx_L24;
9081               }
9082 
9083               /* "dipy/align/sumsqdiff.pyx":456
9084  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
9085  *                     else:
9086  *                         tau = sigmasq * lambda_param * nn             # <<<<<<<<<<<<<<
9087  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
9088  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
9089  */
9090               /*else*/ {
9091                 __pyx_v_tau = ((__pyx_v_sigmasq * __pyx_v_lambda_param) * __pyx_v_nn);
9092 
9093                 /* "dipy/align/sumsqdiff.pyx":457
9094  *                     else:
9095  *                         tau = sigmasq * lambda_param * nn
9096  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]             # <<<<<<<<<<<<<<
9097  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
9098  *                         y[2] = b[2] + sigmasq * lambda_param * y[2]
9099  */
9100                 (__pyx_v_y[0]) = ((__pyx_v_b[0]) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[0])));
9101 
9102                 /* "dipy/align/sumsqdiff.pyx":458
9103  *                         tau = sigmasq * lambda_param * nn
9104  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
9105  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]             # <<<<<<<<<<<<<<
9106  *                         y[2] = b[2] + sigmasq * lambda_param * y[2]
9107  *                         is_singular = _solve_3d_symmetric_positive_definite(
9108  */
9109                 (__pyx_v_y[1]) = ((__pyx_v_b[1]) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[1])));
9110 
9111                 /* "dipy/align/sumsqdiff.pyx":459
9112  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
9113  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
9114  *                         y[2] = b[2] + sigmasq * lambda_param * y[2]             # <<<<<<<<<<<<<<
9115  *                         is_singular = _solve_3d_symmetric_positive_definite(
9116  *                                                                 g, y, tau, d)
9117  */
9118                 (__pyx_v_y[2]) = ((__pyx_v_b[2]) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[2])));
9119 
9120                 /* "dipy/align/sumsqdiff.pyx":460
9121  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
9122  *                         y[2] = b[2] + sigmasq * lambda_param * y[2]
9123  *                         is_singular = _solve_3d_symmetric_positive_definite(             # <<<<<<<<<<<<<<
9124  *                                                                 g, y, tau, d)
9125  *                         if is_singular == 1:
9126  */
9127                 __pyx_v_is_singular = __pyx_f_4dipy_5align_9sumsqdiff__solve_3d_symmetric_positive_definite(__pyx_v_g, __pyx_v_y, __pyx_v_tau, __pyx_v_d);
9128 
9129                 /* "dipy/align/sumsqdiff.pyx":462
9130  *                         is_singular = _solve_3d_symmetric_positive_definite(
9131  *                                                                 g, y, tau, d)
9132  *                         if is_singular == 1:             # <<<<<<<<<<<<<<
9133  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
9134  *                             if(nrm2 < 1e-9):
9135  */
9136                 __pyx_t_27 = ((__pyx_v_is_singular == 1) != 0);
9137                 if (__pyx_t_27) {
9138 
9139                   /* "dipy/align/sumsqdiff.pyx":463
9140  *                                                                 g, y, tau, d)
9141  *                         if is_singular == 1:
9142  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2             # <<<<<<<<<<<<<<
9143  *                             if(nrm2 < 1e-9):
9144  *                                 disp[s, r, c, 0] = 0
9145  */
9146                   __pyx_v_nrm2 = ((pow((__pyx_v_g[0]), 2.0) + pow((__pyx_v_g[1]), 2.0)) + pow((__pyx_v_g[2]), 2.0));
9147 
9148                   /* "dipy/align/sumsqdiff.pyx":464
9149  *                         if is_singular == 1:
9150  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
9151  *                             if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
9152  *                                 disp[s, r, c, 0] = 0
9153  *                                 disp[s, r, c, 1] = 0
9154  */
9155                   __pyx_t_27 = ((__pyx_v_nrm2 < 1e-9) != 0);
9156                   if (__pyx_t_27) {
9157 
9158                     /* "dipy/align/sumsqdiff.pyx":465
9159  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
9160  *                             if(nrm2 < 1e-9):
9161  *                                 disp[s, r, c, 0] = 0             # <<<<<<<<<<<<<<
9162  *                                 disp[s, r, c, 1] = 0
9163  *                                 disp[s, r, c, 2] = 0
9164  */
9165                     __pyx_t_22 = __pyx_v_s;
9166                     __pyx_t_25 = __pyx_v_r;
9167                     __pyx_t_24 = __pyx_v_c;
9168                     __pyx_t_23 = 0;
9169                     *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = 0.0;
9170 
9171                     /* "dipy/align/sumsqdiff.pyx":466
9172  *                             if(nrm2 < 1e-9):
9173  *                                 disp[s, r, c, 0] = 0
9174  *                                 disp[s, r, c, 1] = 0             # <<<<<<<<<<<<<<
9175  *                                 disp[s, r, c, 2] = 0
9176  *                             else:
9177  */
9178                     __pyx_t_23 = __pyx_v_s;
9179                     __pyx_t_24 = __pyx_v_r;
9180                     __pyx_t_25 = __pyx_v_c;
9181                     __pyx_t_22 = 1;
9182                     *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = 0.0;
9183 
9184                     /* "dipy/align/sumsqdiff.pyx":467
9185  *                                 disp[s, r, c, 0] = 0
9186  *                                 disp[s, r, c, 1] = 0
9187  *                                 disp[s, r, c, 2] = 0             # <<<<<<<<<<<<<<
9188  *                             else:
9189  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
9190  */
9191                     __pyx_t_22 = __pyx_v_s;
9192                     __pyx_t_25 = __pyx_v_r;
9193                     __pyx_t_24 = __pyx_v_c;
9194                     __pyx_t_23 = 2;
9195                     *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = 0.0;
9196 
9197                     /* "dipy/align/sumsqdiff.pyx":464
9198  *                         if is_singular == 1:
9199  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
9200  *                             if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
9201  *                                 disp[s, r, c, 0] = 0
9202  *                                 disp[s, r, c, 1] = 0
9203  */
9204                     goto __pyx_L28;
9205                   }
9206 
9207                   /* "dipy/align/sumsqdiff.pyx":469
9208  *                                 disp[s, r, c, 2] = 0
9209  *                             else:
9210  *                                 disp[s, r, c, 0] = (b[0]) / nrm2             # <<<<<<<<<<<<<<
9211  *                                 disp[s, r, c, 1] = (b[1]) / nrm2
9212  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
9213  */
9214                   /*else*/ {
9215                     __pyx_t_23 = __pyx_v_s;
9216                     __pyx_t_24 = __pyx_v_r;
9217                     __pyx_t_25 = __pyx_v_c;
9218                     __pyx_t_22 = 0;
9219                     *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[0]) / __pyx_v_nrm2);
9220 
9221                     /* "dipy/align/sumsqdiff.pyx":470
9222  *                             else:
9223  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
9224  *                                 disp[s, r, c, 1] = (b[1]) / nrm2             # <<<<<<<<<<<<<<
9225  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
9226  *                         xx = disp[s, r, c, 0] - d[0]
9227  */
9228                     __pyx_t_22 = __pyx_v_s;
9229                     __pyx_t_25 = __pyx_v_r;
9230                     __pyx_t_24 = __pyx_v_c;
9231                     __pyx_t_23 = 1;
9232                     *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[1]) / __pyx_v_nrm2);
9233 
9234                     /* "dipy/align/sumsqdiff.pyx":471
9235  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
9236  *                                 disp[s, r, c, 1] = (b[1]) / nrm2
9237  *                                 disp[s, r, c, 2] = (b[2]) / nrm2             # <<<<<<<<<<<<<<
9238  *                         xx = disp[s, r, c, 0] - d[0]
9239  *                         yy = disp[s, r, c, 1] - d[1]
9240  */
9241                     __pyx_t_23 = __pyx_v_s;
9242                     __pyx_t_24 = __pyx_v_r;
9243                     __pyx_t_25 = __pyx_v_c;
9244                     __pyx_t_22 = 2;
9245                     *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[2]) / __pyx_v_nrm2);
9246                   }
9247                   __pyx_L28:;
9248 
9249                   /* "dipy/align/sumsqdiff.pyx":462
9250  *                         is_singular = _solve_3d_symmetric_positive_definite(
9251  *                                                                 g, y, tau, d)
9252  *                         if is_singular == 1:             # <<<<<<<<<<<<<<
9253  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
9254  *                             if(nrm2 < 1e-9):
9255  */
9256                 }
9257 
9258                 /* "dipy/align/sumsqdiff.pyx":472
9259  *                                 disp[s, r, c, 1] = (b[1]) / nrm2
9260  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
9261  *                         xx = disp[s, r, c, 0] - d[0]             # <<<<<<<<<<<<<<
9262  *                         yy = disp[s, r, c, 1] - d[1]
9263  *                         zz = disp[s, r, c, 2] - d[2]
9264  */
9265                 __pyx_t_22 = __pyx_v_s;
9266                 __pyx_t_25 = __pyx_v_r;
9267                 __pyx_t_24 = __pyx_v_c;
9268                 __pyx_t_23 = 0;
9269                 __pyx_v_xx = ((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) ))) - (__pyx_v_d[0]));
9270 
9271                 /* "dipy/align/sumsqdiff.pyx":473
9272  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
9273  *                         xx = disp[s, r, c, 0] - d[0]
9274  *                         yy = disp[s, r, c, 1] - d[1]             # <<<<<<<<<<<<<<
9275  *                         zz = disp[s, r, c, 2] - d[2]
9276  *                         disp[s, r, c, 0] = d[0]
9277  */
9278                 __pyx_t_23 = __pyx_v_s;
9279                 __pyx_t_24 = __pyx_v_r;
9280                 __pyx_t_25 = __pyx_v_c;
9281                 __pyx_t_22 = 1;
9282                 __pyx_v_yy = ((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) ))) - (__pyx_v_d[1]));
9283 
9284                 /* "dipy/align/sumsqdiff.pyx":474
9285  *                         xx = disp[s, r, c, 0] - d[0]
9286  *                         yy = disp[s, r, c, 1] - d[1]
9287  *                         zz = disp[s, r, c, 2] - d[2]             # <<<<<<<<<<<<<<
9288  *                         disp[s, r, c, 0] = d[0]
9289  *                         disp[s, r, c, 1] = d[1]
9290  */
9291                 __pyx_t_22 = __pyx_v_s;
9292                 __pyx_t_25 = __pyx_v_r;
9293                 __pyx_t_24 = __pyx_v_c;
9294                 __pyx_t_23 = 2;
9295                 __pyx_v_zz = ((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) ))) - (__pyx_v_d[2]));
9296 
9297                 /* "dipy/align/sumsqdiff.pyx":475
9298  *                         yy = disp[s, r, c, 1] - d[1]
9299  *                         zz = disp[s, r, c, 2] - d[2]
9300  *                         disp[s, r, c, 0] = d[0]             # <<<<<<<<<<<<<<
9301  *                         disp[s, r, c, 1] = d[1]
9302  *                         disp[s, r, c, 2] = d[2]
9303  */
9304                 __pyx_t_23 = __pyx_v_s;
9305                 __pyx_t_24 = __pyx_v_r;
9306                 __pyx_t_25 = __pyx_v_c;
9307                 __pyx_t_22 = 0;
9308                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = (__pyx_v_d[0]);
9309 
9310                 /* "dipy/align/sumsqdiff.pyx":476
9311  *                         zz = disp[s, r, c, 2] - d[2]
9312  *                         disp[s, r, c, 0] = d[0]
9313  *                         disp[s, r, c, 1] = d[1]             # <<<<<<<<<<<<<<
9314  *                         disp[s, r, c, 2] = d[2]
9315  *                         opt = xx * xx + yy * yy + zz * zz
9316  */
9317                 __pyx_t_22 = __pyx_v_s;
9318                 __pyx_t_25 = __pyx_v_r;
9319                 __pyx_t_24 = __pyx_v_c;
9320                 __pyx_t_23 = 1;
9321                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = (__pyx_v_d[1]);
9322 
9323                 /* "dipy/align/sumsqdiff.pyx":477
9324  *                         disp[s, r, c, 0] = d[0]
9325  *                         disp[s, r, c, 1] = d[1]
9326  *                         disp[s, r, c, 2] = d[2]             # <<<<<<<<<<<<<<
9327  *                         opt = xx * xx + yy * yy + zz * zz
9328  *                         if(max_displacement < opt):
9329  */
9330                 __pyx_t_23 = __pyx_v_s;
9331                 __pyx_t_24 = __pyx_v_r;
9332                 __pyx_t_25 = __pyx_v_c;
9333                 __pyx_t_22 = 2;
9334                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = (__pyx_v_d[2]);
9335 
9336                 /* "dipy/align/sumsqdiff.pyx":478
9337  *                         disp[s, r, c, 1] = d[1]
9338  *                         disp[s, r, c, 2] = d[2]
9339  *                         opt = xx * xx + yy * yy + zz * zz             # <<<<<<<<<<<<<<
9340  *                         if(max_displacement < opt):
9341  *                             max_displacement = opt
9342  */
9343                 __pyx_v_opt = (((__pyx_v_xx * __pyx_v_xx) + (__pyx_v_yy * __pyx_v_yy)) + (__pyx_v_zz * __pyx_v_zz));
9344 
9345                 /* "dipy/align/sumsqdiff.pyx":479
9346  *                         disp[s, r, c, 2] = d[2]
9347  *                         opt = xx * xx + yy * yy + zz * zz
9348  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
9349  *                             max_displacement = opt
9350  *     return sqrt(max_displacement)
9351  */
9352                 __pyx_t_27 = ((__pyx_v_max_displacement < __pyx_v_opt) != 0);
9353                 if (__pyx_t_27) {
9354 
9355                   /* "dipy/align/sumsqdiff.pyx":480
9356  *                         opt = xx * xx + yy * yy + zz * zz
9357  *                         if(max_displacement < opt):
9358  *                             max_displacement = opt             # <<<<<<<<<<<<<<
9359  *     return sqrt(max_displacement)
9360  *
9361  */
9362                   __pyx_v_max_displacement = __pyx_v_opt;
9363 
9364                   /* "dipy/align/sumsqdiff.pyx":479
9365  *                         disp[s, r, c, 2] = d[2]
9366  *                         opt = xx * xx + yy * yy + zz * zz
9367  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
9368  *                             max_displacement = opt
9369  *     return sqrt(max_displacement)
9370  */
9371                 }
9372               }
9373               __pyx_L24:;
9374             }
9375           }
9376         }
9377       }
9378 
9379       /* "dipy/align/sumsqdiff.pyx":396
9380  *     max_displacement = 0
9381  *
9382  *     with nogil:             # <<<<<<<<<<<<<<
9383  *
9384  *         for s in range(nslices):
9385  */
9386       /*finally:*/ {
9387         /*normal exit:*/{
9388           #ifdef WITH_THREAD
9389           __Pyx_FastGIL_Forget();
9390           Py_BLOCK_THREADS
9391           #endif
9392           goto __pyx_L5;
9393         }
9394         __pyx_L5:;
9395       }
9396   }
9397 
9398   /* "dipy/align/sumsqdiff.pyx":481
9399  *                         if(max_displacement < opt):
9400  *                             max_displacement = opt
9401  *     return sqrt(max_displacement)             # <<<<<<<<<<<<<<
9402  *
9403  *
9404  */
9405   __pyx_r = sqrt(__pyx_v_max_displacement);
9406   goto __pyx_L0;
9407 
9408   /* "dipy/align/sumsqdiff.pyx":336
9409  * @cython.wraparound(False)
9410  * @cython.cdivision(True)
9411  * cpdef double iterate_residual_displacement_field_ssd_3d(             # <<<<<<<<<<<<<<
9412  *                 floating[:, :, :] delta_field, floating[:, :, :] sigmasq_field,
9413  *                 floating[:, :, :, :] grad, floating[:, :, :, :] target,
9414  */
9415 
9416   /* function exit code */
9417   __pyx_L1_error:;
9418   __Pyx_XDECREF(__pyx_t_1);
9419   __Pyx_XDECREF(__pyx_t_2);
9420   __Pyx_XDECREF(__pyx_t_3);
9421   __Pyx_XDECREF(__pyx_t_4);
9422   __Pyx_WriteUnraisable("dipy.align.sumsqdiff.iterate_residual_displacement_field_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
9423   __pyx_r = 0;
9424   __pyx_L0:;
9425   __Pyx_XDECREF(__pyx_v_ftype);
9426   __Pyx_RefNannyFinishContext();
9427   return __pyx_r;
9428 }
9429 
9430 /* Python wrapper */
9431 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_33__pyx_fuse_0iterate_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
9432 static PyMethodDef __pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_33__pyx_fuse_0iterate_residual_displacement_field_ssd_3d = {"__pyx_fuse_0iterate_residual_displacement_field_ssd_3d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_33__pyx_fuse_0iterate_residual_displacement_field_ssd_3d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_8iterate_residual_displacement_field_ssd_3d};
__pyx_pw_4dipy_5align_9sumsqdiff_33__pyx_fuse_0iterate_residual_displacement_field_ssd_3d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)9433 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_33__pyx_fuse_0iterate_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
9434   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
9435   __Pyx_memviewslice __pyx_v_sigmasq_field = { 0, 0, { 0 }, { 0 }, { 0 } };
9436   __Pyx_memviewslice __pyx_v_grad = { 0, 0, { 0 }, { 0 }, { 0 } };
9437   __Pyx_memviewslice __pyx_v_target = { 0, 0, { 0 }, { 0 }, { 0 } };
9438   double __pyx_v_lambda_param;
9439   __Pyx_memviewslice __pyx_v_disp = { 0, 0, { 0 }, { 0 }, { 0 } };
9440   int __pyx_lineno = 0;
9441   const char *__pyx_filename = NULL;
9442   int __pyx_clineno = 0;
9443   PyObject *__pyx_r = 0;
9444   __Pyx_RefNannyDeclarations
9445   __Pyx_RefNannySetupContext("__pyx_fuse_0iterate_residual_displacement_field_ssd_3d (wrapper)", 0);
9446   {
9447     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_sigmasq_field,&__pyx_n_s_grad,&__pyx_n_s_target,&__pyx_n_s_lambda_param,&__pyx_n_s_disp,0};
9448     PyObject* values[6] = {0,0,0,0,0,0};
9449     if (unlikely(__pyx_kwds)) {
9450       Py_ssize_t kw_args;
9451       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
9452       switch (pos_args) {
9453         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
9454         CYTHON_FALLTHROUGH;
9455         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
9456         CYTHON_FALLTHROUGH;
9457         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
9458         CYTHON_FALLTHROUGH;
9459         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
9460         CYTHON_FALLTHROUGH;
9461         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9462         CYTHON_FALLTHROUGH;
9463         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9464         CYTHON_FALLTHROUGH;
9465         case  0: break;
9466         default: goto __pyx_L5_argtuple_error;
9467       }
9468       kw_args = PyDict_Size(__pyx_kwds);
9469       switch (pos_args) {
9470         case  0:
9471         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
9472         else goto __pyx_L5_argtuple_error;
9473         CYTHON_FALLTHROUGH;
9474         case  1:
9475         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigmasq_field)) != 0)) kw_args--;
9476         else {
9477           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_3d", 1, 6, 6, 1); __PYX_ERR(0, 336, __pyx_L3_error)
9478         }
9479         CYTHON_FALLTHROUGH;
9480         case  2:
9481         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_grad)) != 0)) kw_args--;
9482         else {
9483           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_3d", 1, 6, 6, 2); __PYX_ERR(0, 336, __pyx_L3_error)
9484         }
9485         CYTHON_FALLTHROUGH;
9486         case  3:
9487         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--;
9488         else {
9489           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_3d", 1, 6, 6, 3); __PYX_ERR(0, 336, __pyx_L3_error)
9490         }
9491         CYTHON_FALLTHROUGH;
9492         case  4:
9493         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lambda_param)) != 0)) kw_args--;
9494         else {
9495           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_3d", 1, 6, 6, 4); __PYX_ERR(0, 336, __pyx_L3_error)
9496         }
9497         CYTHON_FALLTHROUGH;
9498         case  5:
9499         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_disp)) != 0)) kw_args--;
9500         else {
9501           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_3d", 1, 6, 6, 5); __PYX_ERR(0, 336, __pyx_L3_error)
9502         }
9503       }
9504       if (unlikely(kw_args > 0)) {
9505         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fuse_0iterate_residual_displacement_field_ssd_3d") < 0)) __PYX_ERR(0, 336, __pyx_L3_error)
9506       }
9507     } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
9508       goto __pyx_L5_argtuple_error;
9509     } else {
9510       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9511       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9512       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
9513       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
9514       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
9515       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
9516     }
9517     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 337, __pyx_L3_error)
9518     __pyx_v_sigmasq_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_sigmasq_field.memview)) __PYX_ERR(0, 337, __pyx_L3_error)
9519     __pyx_v_grad = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_grad.memview)) __PYX_ERR(0, 338, __pyx_L3_error)
9520     __pyx_v_target = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_target.memview)) __PYX_ERR(0, 338, __pyx_L3_error)
9521     __pyx_v_lambda_param = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_lambda_param == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 339, __pyx_L3_error)
9522     __pyx_v_disp = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_disp.memview)) __PYX_ERR(0, 339, __pyx_L3_error)
9523   }
9524   goto __pyx_L4_argument_unpacking_done;
9525   __pyx_L5_argtuple_error:;
9526   __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0iterate_residual_displacement_field_ssd_3d", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 336, __pyx_L3_error)
9527   __pyx_L3_error:;
9528   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_0iterate_residual_displacement_field_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
9529   __Pyx_RefNannyFinishContext();
9530   return NULL;
9531   __pyx_L4_argument_unpacking_done:;
9532   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_32__pyx_fuse_0iterate_residual_displacement_field_ssd_3d(__pyx_self, __pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_grad, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_disp);
9533 
9534   /* function exit code */
9535   __Pyx_RefNannyFinishContext();
9536   return __pyx_r;
9537 }
9538 
__pyx_pf_4dipy_5align_9sumsqdiff_32__pyx_fuse_0iterate_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_grad,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_disp)9539 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_32__pyx_fuse_0iterate_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_disp) {
9540   PyObject *__pyx_r = NULL;
9541   __Pyx_RefNannyDeclarations
9542   PyObject *__pyx_t_1 = NULL;
9543   int __pyx_lineno = 0;
9544   const char *__pyx_filename = NULL;
9545   int __pyx_clineno = 0;
9546   __Pyx_RefNannySetupContext("__pyx_fuse_0iterate_residual_displacement_field_ssd_3d", 0);
9547   __Pyx_XDECREF(__pyx_r);
9548   if (unlikely(!__pyx_v_delta_field.memview)) { __Pyx_RaiseUnboundLocalError("delta_field"); __PYX_ERR(0, 336, __pyx_L1_error) }
9549   if (unlikely(!__pyx_v_sigmasq_field.memview)) { __Pyx_RaiseUnboundLocalError("sigmasq_field"); __PYX_ERR(0, 336, __pyx_L1_error) }
9550   if (unlikely(!__pyx_v_grad.memview)) { __Pyx_RaiseUnboundLocalError("grad"); __PYX_ERR(0, 336, __pyx_L1_error) }
9551   if (unlikely(!__pyx_v_target.memview)) { __Pyx_RaiseUnboundLocalError("target"); __PYX_ERR(0, 336, __pyx_L1_error) }
9552   if (unlikely(!__pyx_v_disp.memview)) { __Pyx_RaiseUnboundLocalError("disp"); __PYX_ERR(0, 336, __pyx_L1_error) }
9553   __pyx_t_1 = PyFloat_FromDouble(__pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_3d(__pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_grad, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_disp, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
9554   __Pyx_GOTREF(__pyx_t_1);
9555   __pyx_r = __pyx_t_1;
9556   __pyx_t_1 = 0;
9557   goto __pyx_L0;
9558 
9559   /* function exit code */
9560   __pyx_L1_error:;
9561   __Pyx_XDECREF(__pyx_t_1);
9562   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_0iterate_residual_displacement_field_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
9563   __pyx_r = NULL;
9564   __pyx_L0:;
9565   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
9566   __PYX_XDEC_MEMVIEW(&__pyx_v_sigmasq_field, 1);
9567   __PYX_XDEC_MEMVIEW(&__pyx_v_grad, 1);
9568   __PYX_XDEC_MEMVIEW(&__pyx_v_target, 1);
9569   __PYX_XDEC_MEMVIEW(&__pyx_v_disp, 1);
9570   __Pyx_XGIVEREF(__pyx_r);
9571   __Pyx_RefNannyFinishContext();
9572   return __pyx_r;
9573 }
9574 
9575 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_35__pyx_fuse_1iterate_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
9576 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_9iterate_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_3d(__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_grad,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_disp,CYTHON_UNUSED int __pyx_skip_dispatch)9577 static double __pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_3d(__Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_disp, CYTHON_UNUSED int __pyx_skip_dispatch) {
9578   CYTHON_UNUSED PyObject *__pyx_v_ftype = NULL;
9579   int __pyx_v_NUM_NEIGHBORS;
9580   int *__pyx_v_dSlice;
9581   int *__pyx_v_dRow;
9582   int *__pyx_v_dCol;
9583   npy_intp __pyx_v_nslices;
9584   npy_intp __pyx_v_nrows;
9585   npy_intp __pyx_v_ncols;
9586   int __pyx_v_nn;
9587   double *__pyx_v_g;
9588   double *__pyx_v_b;
9589   double *__pyx_v_d;
9590   double *__pyx_v_y;
9591   CYTHON_UNUSED double *__pyx_v_A;
9592   double __pyx_v_xx;
9593   double __pyx_v_yy;
9594   double __pyx_v_zz;
9595   double __pyx_v_opt;
9596   double __pyx_v_nrm2;
9597   CYTHON_UNUSED double __pyx_v_delta;
9598   double __pyx_v_sigmasq;
9599   double __pyx_v_max_displacement;
9600   npy_intp __pyx_v_dr;
9601   npy_intp __pyx_v_ds;
9602   npy_intp __pyx_v_dc;
9603   npy_intp __pyx_v_s;
9604   npy_intp __pyx_v_r;
9605   npy_intp __pyx_v_c;
9606   int __pyx_v_k;
9607   double __pyx_v_tau;
9608   int __pyx_v_is_singular;
9609   double __pyx_r;
9610   __Pyx_RefNannyDeclarations
9611   PyObject *__pyx_t_1 = NULL;
9612   PyObject *__pyx_t_2 = NULL;
9613   PyObject *__pyx_t_3 = NULL;
9614   PyObject *__pyx_t_4 = NULL;
9615   int __pyx_t_5[6];
9616   int __pyx_t_6[6];
9617   int __pyx_t_7[6];
9618   double __pyx_t_8[3];
9619   double __pyx_t_9[3];
9620   double __pyx_t_10[3];
9621   double __pyx_t_11[3];
9622   double __pyx_t_12[6];
9623   npy_intp __pyx_t_13;
9624   npy_intp __pyx_t_14;
9625   npy_intp __pyx_t_15;
9626   npy_intp __pyx_t_16;
9627   npy_intp __pyx_t_17;
9628   npy_intp __pyx_t_18;
9629   npy_intp __pyx_t_19;
9630   npy_intp __pyx_t_20;
9631   npy_intp __pyx_t_21;
9632   Py_ssize_t __pyx_t_22;
9633   Py_ssize_t __pyx_t_23;
9634   Py_ssize_t __pyx_t_24;
9635   Py_ssize_t __pyx_t_25;
9636   double __pyx_t_26;
9637   int __pyx_t_27;
9638   int __pyx_t_28;
9639   int __pyx_t_29;
9640   int __pyx_t_30;
9641   int __pyx_t_31;
9642   long __pyx_t_32;
9643   int __pyx_lineno = 0;
9644   const char *__pyx_filename = NULL;
9645   int __pyx_clineno = 0;
9646   __Pyx_RefNannySetupContext("__pyx_fuse_1iterate_residual_displacement_field_ssd_3d", 0);
9647 
9648   /* "dipy/align/sumsqdiff.pyx":377
9649  *               Vision, 2005. ICCV 2005.
9650  *     """
9651  *     ftype = np.asarray(delta_field).dtype             # <<<<<<<<<<<<<<
9652  *     cdef:
9653  *         int NUM_NEIGHBORS = 6
9654  */
9655   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 377, __pyx_L1_error)
9656   __Pyx_GOTREF(__pyx_t_2);
9657   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 377, __pyx_L1_error)
9658   __Pyx_GOTREF(__pyx_t_3);
9659   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9660   __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 3, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 377, __pyx_L1_error)
9661   __Pyx_GOTREF(__pyx_t_2);
9662   __pyx_t_4 = NULL;
9663   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
9664     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
9665     if (likely(__pyx_t_4)) {
9666       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
9667       __Pyx_INCREF(__pyx_t_4);
9668       __Pyx_INCREF(function);
9669       __Pyx_DECREF_SET(__pyx_t_3, function);
9670     }
9671   }
9672   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
9673   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
9674   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9675   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error)
9676   __Pyx_GOTREF(__pyx_t_1);
9677   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9678   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 377, __pyx_L1_error)
9679   __Pyx_GOTREF(__pyx_t_3);
9680   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9681   __pyx_v_ftype = __pyx_t_3;
9682   __pyx_t_3 = 0;
9683 
9684   /* "dipy/align/sumsqdiff.pyx":379
9685  *     ftype = np.asarray(delta_field).dtype
9686  *     cdef:
9687  *         int NUM_NEIGHBORS = 6             # <<<<<<<<<<<<<<
9688  *         int* dSlice = [-1, 0, 0, 0,  0, 1]
9689  *         int* dRow = [0, -1, 0, 1,  0, 0]
9690  */
9691   __pyx_v_NUM_NEIGHBORS = 6;
9692 
9693   /* "dipy/align/sumsqdiff.pyx":380
9694  *     cdef:
9695  *         int NUM_NEIGHBORS = 6
9696  *         int* dSlice = [-1, 0, 0, 0,  0, 1]             # <<<<<<<<<<<<<<
9697  *         int* dRow = [0, -1, 0, 1,  0, 0]
9698  *         int* dCol = [0,  0, 1, 0, -1, 0]
9699  */
9700   __pyx_t_5[0] = -1;
9701   __pyx_t_5[1] = 0;
9702   __pyx_t_5[2] = 0;
9703   __pyx_t_5[3] = 0;
9704   __pyx_t_5[4] = 0;
9705   __pyx_t_5[5] = 1;
9706   __pyx_v_dSlice = __pyx_t_5;
9707 
9708   /* "dipy/align/sumsqdiff.pyx":381
9709  *         int NUM_NEIGHBORS = 6
9710  *         int* dSlice = [-1, 0, 0, 0,  0, 1]
9711  *         int* dRow = [0, -1, 0, 1,  0, 0]             # <<<<<<<<<<<<<<
9712  *         int* dCol = [0,  0, 1, 0, -1, 0]
9713  *         cnp.npy_intp nslices = delta_field.shape[0]
9714  */
9715   __pyx_t_6[0] = 0;
9716   __pyx_t_6[1] = -1;
9717   __pyx_t_6[2] = 0;
9718   __pyx_t_6[3] = 1;
9719   __pyx_t_6[4] = 0;
9720   __pyx_t_6[5] = 0;
9721   __pyx_v_dRow = __pyx_t_6;
9722 
9723   /* "dipy/align/sumsqdiff.pyx":382
9724  *         int* dSlice = [-1, 0, 0, 0,  0, 1]
9725  *         int* dRow = [0, -1, 0, 1,  0, 0]
9726  *         int* dCol = [0,  0, 1, 0, -1, 0]             # <<<<<<<<<<<<<<
9727  *         cnp.npy_intp nslices = delta_field.shape[0]
9728  *         cnp.npy_intp nrows = delta_field.shape[1]
9729  */
9730   __pyx_t_7[0] = 0;
9731   __pyx_t_7[1] = 0;
9732   __pyx_t_7[2] = 1;
9733   __pyx_t_7[3] = 0;
9734   __pyx_t_7[4] = -1;
9735   __pyx_t_7[5] = 0;
9736   __pyx_v_dCol = __pyx_t_7;
9737 
9738   /* "dipy/align/sumsqdiff.pyx":383
9739  *         int* dRow = [0, -1, 0, 1,  0, 0]
9740  *         int* dCol = [0,  0, 1, 0, -1, 0]
9741  *         cnp.npy_intp nslices = delta_field.shape[0]             # <<<<<<<<<<<<<<
9742  *         cnp.npy_intp nrows = delta_field.shape[1]
9743  *         cnp.npy_intp ncols = delta_field.shape[2]
9744  */
9745   __pyx_v_nslices = (__pyx_v_delta_field.shape[0]);
9746 
9747   /* "dipy/align/sumsqdiff.pyx":384
9748  *         int* dCol = [0,  0, 1, 0, -1, 0]
9749  *         cnp.npy_intp nslices = delta_field.shape[0]
9750  *         cnp.npy_intp nrows = delta_field.shape[1]             # <<<<<<<<<<<<<<
9751  *         cnp.npy_intp ncols = delta_field.shape[2]
9752  *         int nn
9753  */
9754   __pyx_v_nrows = (__pyx_v_delta_field.shape[1]);
9755 
9756   /* "dipy/align/sumsqdiff.pyx":385
9757  *         cnp.npy_intp nslices = delta_field.shape[0]
9758  *         cnp.npy_intp nrows = delta_field.shape[1]
9759  *         cnp.npy_intp ncols = delta_field.shape[2]             # <<<<<<<<<<<<<<
9760  *         int nn
9761  *         double* g = [0, 0, 0]
9762  */
9763   __pyx_v_ncols = (__pyx_v_delta_field.shape[2]);
9764 
9765   /* "dipy/align/sumsqdiff.pyx":387
9766  *         cnp.npy_intp ncols = delta_field.shape[2]
9767  *         int nn
9768  *         double* g = [0, 0, 0]             # <<<<<<<<<<<<<<
9769  *         double* b = [0, 0, 0]
9770  *         double* d = [0, 0, 0]
9771  */
9772   __pyx_t_8[0] = 0.0;
9773   __pyx_t_8[1] = 0.0;
9774   __pyx_t_8[2] = 0.0;
9775   __pyx_v_g = __pyx_t_8;
9776 
9777   /* "dipy/align/sumsqdiff.pyx":388
9778  *         int nn
9779  *         double* g = [0, 0, 0]
9780  *         double* b = [0, 0, 0]             # <<<<<<<<<<<<<<
9781  *         double* d = [0, 0, 0]
9782  *         double* y = [0, 0, 0]
9783  */
9784   __pyx_t_9[0] = 0.0;
9785   __pyx_t_9[1] = 0.0;
9786   __pyx_t_9[2] = 0.0;
9787   __pyx_v_b = __pyx_t_9;
9788 
9789   /* "dipy/align/sumsqdiff.pyx":389
9790  *         double* g = [0, 0, 0]
9791  *         double* b = [0, 0, 0]
9792  *         double* d = [0, 0, 0]             # <<<<<<<<<<<<<<
9793  *         double* y = [0, 0, 0]
9794  *         double* A = [0, 0, 0, 0, 0, 0]
9795  */
9796   __pyx_t_10[0] = 0.0;
9797   __pyx_t_10[1] = 0.0;
9798   __pyx_t_10[2] = 0.0;
9799   __pyx_v_d = __pyx_t_10;
9800 
9801   /* "dipy/align/sumsqdiff.pyx":390
9802  *         double* b = [0, 0, 0]
9803  *         double* d = [0, 0, 0]
9804  *         double* y = [0, 0, 0]             # <<<<<<<<<<<<<<
9805  *         double* A = [0, 0, 0, 0, 0, 0]
9806  *         double xx, yy, zz, opt, nrm2, delta, sigmasq, max_displacement
9807  */
9808   __pyx_t_11[0] = 0.0;
9809   __pyx_t_11[1] = 0.0;
9810   __pyx_t_11[2] = 0.0;
9811   __pyx_v_y = __pyx_t_11;
9812 
9813   /* "dipy/align/sumsqdiff.pyx":391
9814  *         double* d = [0, 0, 0]
9815  *         double* y = [0, 0, 0]
9816  *         double* A = [0, 0, 0, 0, 0, 0]             # <<<<<<<<<<<<<<
9817  *         double xx, yy, zz, opt, nrm2, delta, sigmasq, max_displacement
9818  *         cnp.npy_intp dr, ds, dc, s, r, c
9819  */
9820   __pyx_t_12[0] = 0.0;
9821   __pyx_t_12[1] = 0.0;
9822   __pyx_t_12[2] = 0.0;
9823   __pyx_t_12[3] = 0.0;
9824   __pyx_t_12[4] = 0.0;
9825   __pyx_t_12[5] = 0.0;
9826   __pyx_v_A = __pyx_t_12;
9827 
9828   /* "dipy/align/sumsqdiff.pyx":394
9829  *         double xx, yy, zz, opt, nrm2, delta, sigmasq, max_displacement
9830  *         cnp.npy_intp dr, ds, dc, s, r, c
9831  *     max_displacement = 0             # <<<<<<<<<<<<<<
9832  *
9833  *     with nogil:
9834  */
9835   __pyx_v_max_displacement = 0.0;
9836 
9837   /* "dipy/align/sumsqdiff.pyx":396
9838  *     max_displacement = 0
9839  *
9840  *     with nogil:             # <<<<<<<<<<<<<<
9841  *
9842  *         for s in range(nslices):
9843  */
9844   {
9845       #ifdef WITH_THREAD
9846       PyThreadState *_save;
9847       Py_UNBLOCK_THREADS
9848       __Pyx_FastGIL_Remember();
9849       #endif
9850       /*try:*/ {
9851 
9852         /* "dipy/align/sumsqdiff.pyx":398
9853  *     with nogil:
9854  *
9855  *         for s in range(nslices):             # <<<<<<<<<<<<<<
9856  *             for r in range(nrows):
9857  *                 for c in range(ncols):
9858  */
9859         __pyx_t_13 = __pyx_v_nslices;
9860         __pyx_t_14 = __pyx_t_13;
9861         for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
9862           __pyx_v_s = __pyx_t_15;
9863 
9864           /* "dipy/align/sumsqdiff.pyx":399
9865  *
9866  *         for s in range(nslices):
9867  *             for r in range(nrows):             # <<<<<<<<<<<<<<
9868  *                 for c in range(ncols):
9869  *                     g[0] = grad[s, r, c, 0]
9870  */
9871           __pyx_t_16 = __pyx_v_nrows;
9872           __pyx_t_17 = __pyx_t_16;
9873           for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
9874             __pyx_v_r = __pyx_t_18;
9875 
9876             /* "dipy/align/sumsqdiff.pyx":400
9877  *         for s in range(nslices):
9878  *             for r in range(nrows):
9879  *                 for c in range(ncols):             # <<<<<<<<<<<<<<
9880  *                     g[0] = grad[s, r, c, 0]
9881  *                     g[1] = grad[s, r, c, 1]
9882  */
9883             __pyx_t_19 = __pyx_v_ncols;
9884             __pyx_t_20 = __pyx_t_19;
9885             for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) {
9886               __pyx_v_c = __pyx_t_21;
9887 
9888               /* "dipy/align/sumsqdiff.pyx":401
9889  *             for r in range(nrows):
9890  *                 for c in range(ncols):
9891  *                     g[0] = grad[s, r, c, 0]             # <<<<<<<<<<<<<<
9892  *                     g[1] = grad[s, r, c, 1]
9893  *                     g[2] = grad[s, r, c, 2]
9894  */
9895               __pyx_t_22 = __pyx_v_s;
9896               __pyx_t_23 = __pyx_v_r;
9897               __pyx_t_24 = __pyx_v_c;
9898               __pyx_t_25 = 0;
9899               (__pyx_v_g[0]) = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_22 * __pyx_v_grad.strides[0]) ) + __pyx_t_23 * __pyx_v_grad.strides[1]) ) + __pyx_t_24 * __pyx_v_grad.strides[2]) ) + __pyx_t_25 * __pyx_v_grad.strides[3]) )));
9900 
9901               /* "dipy/align/sumsqdiff.pyx":402
9902  *                 for c in range(ncols):
9903  *                     g[0] = grad[s, r, c, 0]
9904  *                     g[1] = grad[s, r, c, 1]             # <<<<<<<<<<<<<<
9905  *                     g[2] = grad[s, r, c, 2]
9906  *                     delta = delta_field[s, r, c]
9907  */
9908               __pyx_t_25 = __pyx_v_s;
9909               __pyx_t_24 = __pyx_v_r;
9910               __pyx_t_23 = __pyx_v_c;
9911               __pyx_t_22 = 1;
9912               (__pyx_v_g[1]) = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_25 * __pyx_v_grad.strides[0]) ) + __pyx_t_24 * __pyx_v_grad.strides[1]) ) + __pyx_t_23 * __pyx_v_grad.strides[2]) ) + __pyx_t_22 * __pyx_v_grad.strides[3]) )));
9913 
9914               /* "dipy/align/sumsqdiff.pyx":403
9915  *                     g[0] = grad[s, r, c, 0]
9916  *                     g[1] = grad[s, r, c, 1]
9917  *                     g[2] = grad[s, r, c, 2]             # <<<<<<<<<<<<<<
9918  *                     delta = delta_field[s, r, c]
9919  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
9920  */
9921               __pyx_t_22 = __pyx_v_s;
9922               __pyx_t_23 = __pyx_v_r;
9923               __pyx_t_24 = __pyx_v_c;
9924               __pyx_t_25 = 2;
9925               (__pyx_v_g[2]) = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_grad.data + __pyx_t_22 * __pyx_v_grad.strides[0]) ) + __pyx_t_23 * __pyx_v_grad.strides[1]) ) + __pyx_t_24 * __pyx_v_grad.strides[2]) ) + __pyx_t_25 * __pyx_v_grad.strides[3]) )));
9926 
9927               /* "dipy/align/sumsqdiff.pyx":404
9928  *                     g[1] = grad[s, r, c, 1]
9929  *                     g[2] = grad[s, r, c, 2]
9930  *                     delta = delta_field[s, r, c]             # <<<<<<<<<<<<<<
9931  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
9932  *                     if(target is None):
9933  */
9934               __pyx_t_25 = __pyx_v_s;
9935               __pyx_t_24 = __pyx_v_r;
9936               __pyx_t_23 = __pyx_v_c;
9937               __pyx_v_delta = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_25 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_24 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_23 * __pyx_v_delta_field.strides[2]) )));
9938 
9939               /* "dipy/align/sumsqdiff.pyx":405
9940  *                     g[2] = grad[s, r, c, 2]
9941  *                     delta = delta_field[s, r, c]
9942  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1             # <<<<<<<<<<<<<<
9943  *                     if(target is None):
9944  *                         b[0] = delta_field[s, r, c] * g[0]
9945  */
9946               if (((((PyObject *) __pyx_v_sigmasq_field.memview) != Py_None) != 0)) {
9947                 __pyx_t_23 = __pyx_v_s;
9948                 __pyx_t_24 = __pyx_v_r;
9949                 __pyx_t_25 = __pyx_v_c;
9950                 __pyx_t_26 = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_sigmasq_field.data + __pyx_t_23 * __pyx_v_sigmasq_field.strides[0]) ) + __pyx_t_24 * __pyx_v_sigmasq_field.strides[1]) ) + __pyx_t_25 * __pyx_v_sigmasq_field.strides[2]) )));
9951               } else {
9952                 __pyx_t_26 = 1.0;
9953               }
9954               __pyx_v_sigmasq = __pyx_t_26;
9955 
9956               /* "dipy/align/sumsqdiff.pyx":406
9957  *                     delta = delta_field[s, r, c]
9958  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
9959  *                     if(target is None):             # <<<<<<<<<<<<<<
9960  *                         b[0] = delta_field[s, r, c] * g[0]
9961  *                         b[1] = delta_field[s, r, c] * g[1]
9962  */
9963               __pyx_t_27 = ((((PyObject *) __pyx_v_target.memview) == Py_None) != 0);
9964               if (__pyx_t_27) {
9965 
9966                 /* "dipy/align/sumsqdiff.pyx":407
9967  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
9968  *                     if(target is None):
9969  *                         b[0] = delta_field[s, r, c] * g[0]             # <<<<<<<<<<<<<<
9970  *                         b[1] = delta_field[s, r, c] * g[1]
9971  *                         b[2] = delta_field[s, r, c] * g[2]
9972  */
9973                 __pyx_t_25 = __pyx_v_s;
9974                 __pyx_t_24 = __pyx_v_r;
9975                 __pyx_t_23 = __pyx_v_c;
9976                 (__pyx_v_b[0]) = ((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_25 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_24 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_23 * __pyx_v_delta_field.strides[2]) ))) * (__pyx_v_g[0]));
9977 
9978                 /* "dipy/align/sumsqdiff.pyx":408
9979  *                     if(target is None):
9980  *                         b[0] = delta_field[s, r, c] * g[0]
9981  *                         b[1] = delta_field[s, r, c] * g[1]             # <<<<<<<<<<<<<<
9982  *                         b[2] = delta_field[s, r, c] * g[2]
9983  *                     else:
9984  */
9985                 __pyx_t_23 = __pyx_v_s;
9986                 __pyx_t_24 = __pyx_v_r;
9987                 __pyx_t_25 = __pyx_v_c;
9988                 (__pyx_v_b[1]) = ((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_23 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_24 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_25 * __pyx_v_delta_field.strides[2]) ))) * (__pyx_v_g[1]));
9989 
9990                 /* "dipy/align/sumsqdiff.pyx":409
9991  *                         b[0] = delta_field[s, r, c] * g[0]
9992  *                         b[1] = delta_field[s, r, c] * g[1]
9993  *                         b[2] = delta_field[s, r, c] * g[2]             # <<<<<<<<<<<<<<
9994  *                     else:
9995  *                         b[0] = target[s, r, c, 0]
9996  */
9997                 __pyx_t_25 = __pyx_v_s;
9998                 __pyx_t_24 = __pyx_v_r;
9999                 __pyx_t_23 = __pyx_v_c;
10000                 (__pyx_v_b[2]) = ((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_25 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_24 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_23 * __pyx_v_delta_field.strides[2]) ))) * (__pyx_v_g[2]));
10001 
10002                 /* "dipy/align/sumsqdiff.pyx":406
10003  *                     delta = delta_field[s, r, c]
10004  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
10005  *                     if(target is None):             # <<<<<<<<<<<<<<
10006  *                         b[0] = delta_field[s, r, c] * g[0]
10007  *                         b[1] = delta_field[s, r, c] * g[1]
10008  */
10009                 goto __pyx_L12;
10010               }
10011 
10012               /* "dipy/align/sumsqdiff.pyx":411
10013  *                         b[2] = delta_field[s, r, c] * g[2]
10014  *                     else:
10015  *                         b[0] = target[s, r, c, 0]             # <<<<<<<<<<<<<<
10016  *                         b[1] = target[s, r, c, 1]
10017  *                         b[2] = target[s, r, c, 2]
10018  */
10019               /*else*/ {
10020                 __pyx_t_23 = __pyx_v_s;
10021                 __pyx_t_24 = __pyx_v_r;
10022                 __pyx_t_25 = __pyx_v_c;
10023                 __pyx_t_22 = 0;
10024                 (__pyx_v_b[0]) = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_23 * __pyx_v_target.strides[0]) ) + __pyx_t_24 * __pyx_v_target.strides[1]) ) + __pyx_t_25 * __pyx_v_target.strides[2]) ) + __pyx_t_22 * __pyx_v_target.strides[3]) )));
10025 
10026                 /* "dipy/align/sumsqdiff.pyx":412
10027  *                     else:
10028  *                         b[0] = target[s, r, c, 0]
10029  *                         b[1] = target[s, r, c, 1]             # <<<<<<<<<<<<<<
10030  *                         b[2] = target[s, r, c, 2]
10031  *                     nn = 0
10032  */
10033                 __pyx_t_22 = __pyx_v_s;
10034                 __pyx_t_25 = __pyx_v_r;
10035                 __pyx_t_24 = __pyx_v_c;
10036                 __pyx_t_23 = 1;
10037                 (__pyx_v_b[1]) = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_22 * __pyx_v_target.strides[0]) ) + __pyx_t_25 * __pyx_v_target.strides[1]) ) + __pyx_t_24 * __pyx_v_target.strides[2]) ) + __pyx_t_23 * __pyx_v_target.strides[3]) )));
10038 
10039                 /* "dipy/align/sumsqdiff.pyx":413
10040  *                         b[0] = target[s, r, c, 0]
10041  *                         b[1] = target[s, r, c, 1]
10042  *                         b[2] = target[s, r, c, 2]             # <<<<<<<<<<<<<<
10043  *                     nn = 0
10044  *                     y[0] = 0
10045  */
10046                 __pyx_t_23 = __pyx_v_s;
10047                 __pyx_t_24 = __pyx_v_r;
10048                 __pyx_t_25 = __pyx_v_c;
10049                 __pyx_t_22 = 2;
10050                 (__pyx_v_b[2]) = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_23 * __pyx_v_target.strides[0]) ) + __pyx_t_24 * __pyx_v_target.strides[1]) ) + __pyx_t_25 * __pyx_v_target.strides[2]) ) + __pyx_t_22 * __pyx_v_target.strides[3]) )));
10051               }
10052               __pyx_L12:;
10053 
10054               /* "dipy/align/sumsqdiff.pyx":414
10055  *                         b[1] = target[s, r, c, 1]
10056  *                         b[2] = target[s, r, c, 2]
10057  *                     nn = 0             # <<<<<<<<<<<<<<
10058  *                     y[0] = 0
10059  *                     y[1] = 0
10060  */
10061               __pyx_v_nn = 0;
10062 
10063               /* "dipy/align/sumsqdiff.pyx":415
10064  *                         b[2] = target[s, r, c, 2]
10065  *                     nn = 0
10066  *                     y[0] = 0             # <<<<<<<<<<<<<<
10067  *                     y[1] = 0
10068  *                     y[2] = 0
10069  */
10070               (__pyx_v_y[0]) = 0.0;
10071 
10072               /* "dipy/align/sumsqdiff.pyx":416
10073  *                     nn = 0
10074  *                     y[0] = 0
10075  *                     y[1] = 0             # <<<<<<<<<<<<<<
10076  *                     y[2] = 0
10077  *                     for k in range(NUM_NEIGHBORS):
10078  */
10079               (__pyx_v_y[1]) = 0.0;
10080 
10081               /* "dipy/align/sumsqdiff.pyx":417
10082  *                     y[0] = 0
10083  *                     y[1] = 0
10084  *                     y[2] = 0             # <<<<<<<<<<<<<<
10085  *                     for k in range(NUM_NEIGHBORS):
10086  *                         ds = s + dSlice[k]
10087  */
10088               (__pyx_v_y[2]) = 0.0;
10089 
10090               /* "dipy/align/sumsqdiff.pyx":418
10091  *                     y[1] = 0
10092  *                     y[2] = 0
10093  *                     for k in range(NUM_NEIGHBORS):             # <<<<<<<<<<<<<<
10094  *                         ds = s + dSlice[k]
10095  *                         if((ds < 0) or (ds >= nslices)):
10096  */
10097               __pyx_t_28 = __pyx_v_NUM_NEIGHBORS;
10098               __pyx_t_29 = __pyx_t_28;
10099               for (__pyx_t_30 = 0; __pyx_t_30 < __pyx_t_29; __pyx_t_30+=1) {
10100                 __pyx_v_k = __pyx_t_30;
10101 
10102                 /* "dipy/align/sumsqdiff.pyx":419
10103  *                     y[2] = 0
10104  *                     for k in range(NUM_NEIGHBORS):
10105  *                         ds = s + dSlice[k]             # <<<<<<<<<<<<<<
10106  *                         if((ds < 0) or (ds >= nslices)):
10107  *                             continue
10108  */
10109                 __pyx_v_ds = (__pyx_v_s + (__pyx_v_dSlice[__pyx_v_k]));
10110 
10111                 /* "dipy/align/sumsqdiff.pyx":420
10112  *                     for k in range(NUM_NEIGHBORS):
10113  *                         ds = s + dSlice[k]
10114  *                         if((ds < 0) or (ds >= nslices)):             # <<<<<<<<<<<<<<
10115  *                             continue
10116  *                         dr = r + dRow[k]
10117  */
10118                 __pyx_t_31 = ((__pyx_v_ds < 0) != 0);
10119                 if (!__pyx_t_31) {
10120                 } else {
10121                   __pyx_t_27 = __pyx_t_31;
10122                   goto __pyx_L16_bool_binop_done;
10123                 }
10124                 __pyx_t_31 = ((__pyx_v_ds >= __pyx_v_nslices) != 0);
10125                 __pyx_t_27 = __pyx_t_31;
10126                 __pyx_L16_bool_binop_done:;
10127                 if (__pyx_t_27) {
10128 
10129                   /* "dipy/align/sumsqdiff.pyx":421
10130  *                         ds = s + dSlice[k]
10131  *                         if((ds < 0) or (ds >= nslices)):
10132  *                             continue             # <<<<<<<<<<<<<<
10133  *                         dr = r + dRow[k]
10134  *                         if((dr < 0) or (dr >= nrows)):
10135  */
10136                   goto __pyx_L13_continue;
10137 
10138                   /* "dipy/align/sumsqdiff.pyx":420
10139  *                     for k in range(NUM_NEIGHBORS):
10140  *                         ds = s + dSlice[k]
10141  *                         if((ds < 0) or (ds >= nslices)):             # <<<<<<<<<<<<<<
10142  *                             continue
10143  *                         dr = r + dRow[k]
10144  */
10145                 }
10146 
10147                 /* "dipy/align/sumsqdiff.pyx":422
10148  *                         if((ds < 0) or (ds >= nslices)):
10149  *                             continue
10150  *                         dr = r + dRow[k]             # <<<<<<<<<<<<<<
10151  *                         if((dr < 0) or (dr >= nrows)):
10152  *                             continue
10153  */
10154                 __pyx_v_dr = (__pyx_v_r + (__pyx_v_dRow[__pyx_v_k]));
10155 
10156                 /* "dipy/align/sumsqdiff.pyx":423
10157  *                             continue
10158  *                         dr = r + dRow[k]
10159  *                         if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
10160  *                             continue
10161  *                         dc = c + dCol[k]
10162  */
10163                 __pyx_t_31 = ((__pyx_v_dr < 0) != 0);
10164                 if (!__pyx_t_31) {
10165                 } else {
10166                   __pyx_t_27 = __pyx_t_31;
10167                   goto __pyx_L19_bool_binop_done;
10168                 }
10169                 __pyx_t_31 = ((__pyx_v_dr >= __pyx_v_nrows) != 0);
10170                 __pyx_t_27 = __pyx_t_31;
10171                 __pyx_L19_bool_binop_done:;
10172                 if (__pyx_t_27) {
10173 
10174                   /* "dipy/align/sumsqdiff.pyx":424
10175  *                         dr = r + dRow[k]
10176  *                         if((dr < 0) or (dr >= nrows)):
10177  *                             continue             # <<<<<<<<<<<<<<
10178  *                         dc = c + dCol[k]
10179  *                         if((dc < 0) or (dc >= ncols)):
10180  */
10181                   goto __pyx_L13_continue;
10182 
10183                   /* "dipy/align/sumsqdiff.pyx":423
10184  *                             continue
10185  *                         dr = r + dRow[k]
10186  *                         if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
10187  *                             continue
10188  *                         dc = c + dCol[k]
10189  */
10190                 }
10191 
10192                 /* "dipy/align/sumsqdiff.pyx":425
10193  *                         if((dr < 0) or (dr >= nrows)):
10194  *                             continue
10195  *                         dc = c + dCol[k]             # <<<<<<<<<<<<<<
10196  *                         if((dc < 0) or (dc >= ncols)):
10197  *                             continue
10198  */
10199                 __pyx_v_dc = (__pyx_v_c + (__pyx_v_dCol[__pyx_v_k]));
10200 
10201                 /* "dipy/align/sumsqdiff.pyx":426
10202  *                             continue
10203  *                         dc = c + dCol[k]
10204  *                         if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
10205  *                             continue
10206  *                         nn += 1
10207  */
10208                 __pyx_t_31 = ((__pyx_v_dc < 0) != 0);
10209                 if (!__pyx_t_31) {
10210                 } else {
10211                   __pyx_t_27 = __pyx_t_31;
10212                   goto __pyx_L22_bool_binop_done;
10213                 }
10214                 __pyx_t_31 = ((__pyx_v_dc >= __pyx_v_ncols) != 0);
10215                 __pyx_t_27 = __pyx_t_31;
10216                 __pyx_L22_bool_binop_done:;
10217                 if (__pyx_t_27) {
10218 
10219                   /* "dipy/align/sumsqdiff.pyx":427
10220  *                         dc = c + dCol[k]
10221  *                         if((dc < 0) or (dc >= ncols)):
10222  *                             continue             # <<<<<<<<<<<<<<
10223  *                         nn += 1
10224  *                         y[0] += disp[ds, dr, dc, 0]
10225  */
10226                   goto __pyx_L13_continue;
10227 
10228                   /* "dipy/align/sumsqdiff.pyx":426
10229  *                             continue
10230  *                         dc = c + dCol[k]
10231  *                         if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
10232  *                             continue
10233  *                         nn += 1
10234  */
10235                 }
10236 
10237                 /* "dipy/align/sumsqdiff.pyx":428
10238  *                         if((dc < 0) or (dc >= ncols)):
10239  *                             continue
10240  *                         nn += 1             # <<<<<<<<<<<<<<
10241  *                         y[0] += disp[ds, dr, dc, 0]
10242  *                         y[1] += disp[ds, dr, dc, 1]
10243  */
10244                 __pyx_v_nn = (__pyx_v_nn + 1);
10245 
10246                 /* "dipy/align/sumsqdiff.pyx":429
10247  *                             continue
10248  *                         nn += 1
10249  *                         y[0] += disp[ds, dr, dc, 0]             # <<<<<<<<<<<<<<
10250  *                         y[1] += disp[ds, dr, dc, 1]
10251  *                         y[2] += disp[ds, dr, dc, 2]
10252  */
10253                 __pyx_t_32 = 0;
10254                 __pyx_t_22 = __pyx_v_ds;
10255                 __pyx_t_25 = __pyx_v_dr;
10256                 __pyx_t_24 = __pyx_v_dc;
10257                 __pyx_t_23 = 0;
10258                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) ))));
10259 
10260                 /* "dipy/align/sumsqdiff.pyx":430
10261  *                         nn += 1
10262  *                         y[0] += disp[ds, dr, dc, 0]
10263  *                         y[1] += disp[ds, dr, dc, 1]             # <<<<<<<<<<<<<<
10264  *                         y[2] += disp[ds, dr, dc, 2]
10265  *                     if dpy_isinf(sigmasq) != 0:
10266  */
10267                 __pyx_t_32 = 1;
10268                 __pyx_t_23 = __pyx_v_ds;
10269                 __pyx_t_24 = __pyx_v_dr;
10270                 __pyx_t_25 = __pyx_v_dc;
10271                 __pyx_t_22 = 1;
10272                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) ))));
10273 
10274                 /* "dipy/align/sumsqdiff.pyx":431
10275  *                         y[0] += disp[ds, dr, dc, 0]
10276  *                         y[1] += disp[ds, dr, dc, 1]
10277  *                         y[2] += disp[ds, dr, dc, 2]             # <<<<<<<<<<<<<<
10278  *                     if dpy_isinf(sigmasq) != 0:
10279  *                         xx = disp[s, r, c, 0]
10280  */
10281                 __pyx_t_32 = 2;
10282                 __pyx_t_22 = __pyx_v_ds;
10283                 __pyx_t_25 = __pyx_v_dr;
10284                 __pyx_t_24 = __pyx_v_dc;
10285                 __pyx_t_23 = 2;
10286                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) ))));
10287                 __pyx_L13_continue:;
10288               }
10289 
10290               /* "dipy/align/sumsqdiff.pyx":432
10291  *                         y[1] += disp[ds, dr, dc, 1]
10292  *                         y[2] += disp[ds, dr, dc, 2]
10293  *                     if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
10294  *                         xx = disp[s, r, c, 0]
10295  *                         yy = disp[s, r, c, 1]
10296  */
10297               __pyx_t_27 = ((dpy_isinf(__pyx_v_sigmasq) != 0) != 0);
10298               if (__pyx_t_27) {
10299 
10300                 /* "dipy/align/sumsqdiff.pyx":433
10301  *                         y[2] += disp[ds, dr, dc, 2]
10302  *                     if dpy_isinf(sigmasq) != 0:
10303  *                         xx = disp[s, r, c, 0]             # <<<<<<<<<<<<<<
10304  *                         yy = disp[s, r, c, 1]
10305  *                         zz = disp[s, r, c, 2]
10306  */
10307                 __pyx_t_23 = __pyx_v_s;
10308                 __pyx_t_24 = __pyx_v_r;
10309                 __pyx_t_25 = __pyx_v_c;
10310                 __pyx_t_22 = 0;
10311                 __pyx_v_xx = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )));
10312 
10313                 /* "dipy/align/sumsqdiff.pyx":434
10314  *                     if dpy_isinf(sigmasq) != 0:
10315  *                         xx = disp[s, r, c, 0]
10316  *                         yy = disp[s, r, c, 1]             # <<<<<<<<<<<<<<
10317  *                         zz = disp[s, r, c, 2]
10318  *                         disp[s, r, c, 0] = y[0] / nn
10319  */
10320                 __pyx_t_22 = __pyx_v_s;
10321                 __pyx_t_25 = __pyx_v_r;
10322                 __pyx_t_24 = __pyx_v_c;
10323                 __pyx_t_23 = 1;
10324                 __pyx_v_yy = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )));
10325 
10326                 /* "dipy/align/sumsqdiff.pyx":435
10327  *                         xx = disp[s, r, c, 0]
10328  *                         yy = disp[s, r, c, 1]
10329  *                         zz = disp[s, r, c, 2]             # <<<<<<<<<<<<<<
10330  *                         disp[s, r, c, 0] = y[0] / nn
10331  *                         disp[s, r, c, 1] = y[1] / nn
10332  */
10333                 __pyx_t_23 = __pyx_v_s;
10334                 __pyx_t_24 = __pyx_v_r;
10335                 __pyx_t_25 = __pyx_v_c;
10336                 __pyx_t_22 = 2;
10337                 __pyx_v_zz = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )));
10338 
10339                 /* "dipy/align/sumsqdiff.pyx":436
10340  *                         yy = disp[s, r, c, 1]
10341  *                         zz = disp[s, r, c, 2]
10342  *                         disp[s, r, c, 0] = y[0] / nn             # <<<<<<<<<<<<<<
10343  *                         disp[s, r, c, 1] = y[1] / nn
10344  *                         disp[s, r, c, 2] = y[2] / nn
10345  */
10346                 __pyx_t_22 = __pyx_v_s;
10347                 __pyx_t_25 = __pyx_v_r;
10348                 __pyx_t_24 = __pyx_v_c;
10349                 __pyx_t_23 = 0;
10350                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_y[0]) / ((double)__pyx_v_nn));
10351 
10352                 /* "dipy/align/sumsqdiff.pyx":437
10353  *                         zz = disp[s, r, c, 2]
10354  *                         disp[s, r, c, 0] = y[0] / nn
10355  *                         disp[s, r, c, 1] = y[1] / nn             # <<<<<<<<<<<<<<
10356  *                         disp[s, r, c, 2] = y[2] / nn
10357  *                         xx -= disp[s, r, c, 0]
10358  */
10359                 __pyx_t_23 = __pyx_v_s;
10360                 __pyx_t_24 = __pyx_v_r;
10361                 __pyx_t_25 = __pyx_v_c;
10362                 __pyx_t_22 = 1;
10363                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_y[1]) / ((double)__pyx_v_nn));
10364 
10365                 /* "dipy/align/sumsqdiff.pyx":438
10366  *                         disp[s, r, c, 0] = y[0] / nn
10367  *                         disp[s, r, c, 1] = y[1] / nn
10368  *                         disp[s, r, c, 2] = y[2] / nn             # <<<<<<<<<<<<<<
10369  *                         xx -= disp[s, r, c, 0]
10370  *                         yy -= disp[s, r, c, 1]
10371  */
10372                 __pyx_t_22 = __pyx_v_s;
10373                 __pyx_t_25 = __pyx_v_r;
10374                 __pyx_t_24 = __pyx_v_c;
10375                 __pyx_t_23 = 2;
10376                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_y[2]) / ((double)__pyx_v_nn));
10377 
10378                 /* "dipy/align/sumsqdiff.pyx":439
10379  *                         disp[s, r, c, 1] = y[1] / nn
10380  *                         disp[s, r, c, 2] = y[2] / nn
10381  *                         xx -= disp[s, r, c, 0]             # <<<<<<<<<<<<<<
10382  *                         yy -= disp[s, r, c, 1]
10383  *                         zz -= disp[s, r, c, 2]
10384  */
10385                 __pyx_t_23 = __pyx_v_s;
10386                 __pyx_t_24 = __pyx_v_r;
10387                 __pyx_t_25 = __pyx_v_c;
10388                 __pyx_t_22 = 0;
10389                 __pyx_v_xx = (__pyx_v_xx - (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) ))));
10390 
10391                 /* "dipy/align/sumsqdiff.pyx":440
10392  *                         disp[s, r, c, 2] = y[2] / nn
10393  *                         xx -= disp[s, r, c, 0]
10394  *                         yy -= disp[s, r, c, 1]             # <<<<<<<<<<<<<<
10395  *                         zz -= disp[s, r, c, 2]
10396  *                         opt = xx * xx + yy * yy + zz * zz
10397  */
10398                 __pyx_t_22 = __pyx_v_s;
10399                 __pyx_t_25 = __pyx_v_r;
10400                 __pyx_t_24 = __pyx_v_c;
10401                 __pyx_t_23 = 1;
10402                 __pyx_v_yy = (__pyx_v_yy - (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) ))));
10403 
10404                 /* "dipy/align/sumsqdiff.pyx":441
10405  *                         xx -= disp[s, r, c, 0]
10406  *                         yy -= disp[s, r, c, 1]
10407  *                         zz -= disp[s, r, c, 2]             # <<<<<<<<<<<<<<
10408  *                         opt = xx * xx + yy * yy + zz * zz
10409  *                         if(max_displacement < opt):
10410  */
10411                 __pyx_t_23 = __pyx_v_s;
10412                 __pyx_t_24 = __pyx_v_r;
10413                 __pyx_t_25 = __pyx_v_c;
10414                 __pyx_t_22 = 2;
10415                 __pyx_v_zz = (__pyx_v_zz - (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) ))));
10416 
10417                 /* "dipy/align/sumsqdiff.pyx":442
10418  *                         yy -= disp[s, r, c, 1]
10419  *                         zz -= disp[s, r, c, 2]
10420  *                         opt = xx * xx + yy * yy + zz * zz             # <<<<<<<<<<<<<<
10421  *                         if(max_displacement < opt):
10422  *                             max_displacement = opt
10423  */
10424                 __pyx_v_opt = (((__pyx_v_xx * __pyx_v_xx) + (__pyx_v_yy * __pyx_v_yy)) + (__pyx_v_zz * __pyx_v_zz));
10425 
10426                 /* "dipy/align/sumsqdiff.pyx":443
10427  *                         zz -= disp[s, r, c, 2]
10428  *                         opt = xx * xx + yy * yy + zz * zz
10429  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
10430  *                             max_displacement = opt
10431  *                     elif(sigmasq < 1e-9):
10432  */
10433                 __pyx_t_27 = ((__pyx_v_max_displacement < __pyx_v_opt) != 0);
10434                 if (__pyx_t_27) {
10435 
10436                   /* "dipy/align/sumsqdiff.pyx":444
10437  *                         opt = xx * xx + yy * yy + zz * zz
10438  *                         if(max_displacement < opt):
10439  *                             max_displacement = opt             # <<<<<<<<<<<<<<
10440  *                     elif(sigmasq < 1e-9):
10441  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
10442  */
10443                   __pyx_v_max_displacement = __pyx_v_opt;
10444 
10445                   /* "dipy/align/sumsqdiff.pyx":443
10446  *                         zz -= disp[s, r, c, 2]
10447  *                         opt = xx * xx + yy * yy + zz * zz
10448  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
10449  *                             max_displacement = opt
10450  *                     elif(sigmasq < 1e-9):
10451  */
10452                 }
10453 
10454                 /* "dipy/align/sumsqdiff.pyx":432
10455  *                         y[1] += disp[ds, dr, dc, 1]
10456  *                         y[2] += disp[ds, dr, dc, 2]
10457  *                     if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
10458  *                         xx = disp[s, r, c, 0]
10459  *                         yy = disp[s, r, c, 1]
10460  */
10461                 goto __pyx_L24;
10462               }
10463 
10464               /* "dipy/align/sumsqdiff.pyx":445
10465  *                         if(max_displacement < opt):
10466  *                             max_displacement = opt
10467  *                     elif(sigmasq < 1e-9):             # <<<<<<<<<<<<<<
10468  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
10469  *                             if(nrm2 < 1e-9):
10470  */
10471               __pyx_t_27 = ((__pyx_v_sigmasq < 1e-9) != 0);
10472               if (__pyx_t_27) {
10473 
10474                 /* "dipy/align/sumsqdiff.pyx":446
10475  *                             max_displacement = opt
10476  *                     elif(sigmasq < 1e-9):
10477  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2             # <<<<<<<<<<<<<<
10478  *                             if(nrm2 < 1e-9):
10479  *                                 disp[s, r, c, 0] = 0
10480  */
10481                 __pyx_v_nrm2 = ((pow((__pyx_v_g[0]), 2.0) + pow((__pyx_v_g[1]), 2.0)) + pow((__pyx_v_g[2]), 2.0));
10482 
10483                 /* "dipy/align/sumsqdiff.pyx":447
10484  *                     elif(sigmasq < 1e-9):
10485  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
10486  *                             if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
10487  *                                 disp[s, r, c, 0] = 0
10488  *                                 disp[s, r, c, 1] = 0
10489  */
10490                 __pyx_t_27 = ((__pyx_v_nrm2 < 1e-9) != 0);
10491                 if (__pyx_t_27) {
10492 
10493                   /* "dipy/align/sumsqdiff.pyx":448
10494  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
10495  *                             if(nrm2 < 1e-9):
10496  *                                 disp[s, r, c, 0] = 0             # <<<<<<<<<<<<<<
10497  *                                 disp[s, r, c, 1] = 0
10498  *                                 disp[s, r, c, 2] = 0
10499  */
10500                   __pyx_t_22 = __pyx_v_s;
10501                   __pyx_t_25 = __pyx_v_r;
10502                   __pyx_t_24 = __pyx_v_c;
10503                   __pyx_t_23 = 0;
10504                   *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = 0.0;
10505 
10506                   /* "dipy/align/sumsqdiff.pyx":449
10507  *                             if(nrm2 < 1e-9):
10508  *                                 disp[s, r, c, 0] = 0
10509  *                                 disp[s, r, c, 1] = 0             # <<<<<<<<<<<<<<
10510  *                                 disp[s, r, c, 2] = 0
10511  *                             else:
10512  */
10513                   __pyx_t_23 = __pyx_v_s;
10514                   __pyx_t_24 = __pyx_v_r;
10515                   __pyx_t_25 = __pyx_v_c;
10516                   __pyx_t_22 = 1;
10517                   *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = 0.0;
10518 
10519                   /* "dipy/align/sumsqdiff.pyx":450
10520  *                                 disp[s, r, c, 0] = 0
10521  *                                 disp[s, r, c, 1] = 0
10522  *                                 disp[s, r, c, 2] = 0             # <<<<<<<<<<<<<<
10523  *                             else:
10524  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
10525  */
10526                   __pyx_t_22 = __pyx_v_s;
10527                   __pyx_t_25 = __pyx_v_r;
10528                   __pyx_t_24 = __pyx_v_c;
10529                   __pyx_t_23 = 2;
10530                   *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = 0.0;
10531 
10532                   /* "dipy/align/sumsqdiff.pyx":447
10533  *                     elif(sigmasq < 1e-9):
10534  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
10535  *                             if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
10536  *                                 disp[s, r, c, 0] = 0
10537  *                                 disp[s, r, c, 1] = 0
10538  */
10539                   goto __pyx_L26;
10540                 }
10541 
10542                 /* "dipy/align/sumsqdiff.pyx":452
10543  *                                 disp[s, r, c, 2] = 0
10544  *                             else:
10545  *                                 disp[s, r, c, 0] = (b[0]) / nrm2             # <<<<<<<<<<<<<<
10546  *                                 disp[s, r, c, 1] = (b[1]) / nrm2
10547  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
10548  */
10549                 /*else*/ {
10550                   __pyx_t_23 = __pyx_v_s;
10551                   __pyx_t_24 = __pyx_v_r;
10552                   __pyx_t_25 = __pyx_v_c;
10553                   __pyx_t_22 = 0;
10554                   *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[0]) / __pyx_v_nrm2);
10555 
10556                   /* "dipy/align/sumsqdiff.pyx":453
10557  *                             else:
10558  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
10559  *                                 disp[s, r, c, 1] = (b[1]) / nrm2             # <<<<<<<<<<<<<<
10560  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
10561  *                     else:
10562  */
10563                   __pyx_t_22 = __pyx_v_s;
10564                   __pyx_t_25 = __pyx_v_r;
10565                   __pyx_t_24 = __pyx_v_c;
10566                   __pyx_t_23 = 1;
10567                   *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[1]) / __pyx_v_nrm2);
10568 
10569                   /* "dipy/align/sumsqdiff.pyx":454
10570  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
10571  *                                 disp[s, r, c, 1] = (b[1]) / nrm2
10572  *                                 disp[s, r, c, 2] = (b[2]) / nrm2             # <<<<<<<<<<<<<<
10573  *                     else:
10574  *                         tau = sigmasq * lambda_param * nn
10575  */
10576                   __pyx_t_23 = __pyx_v_s;
10577                   __pyx_t_24 = __pyx_v_r;
10578                   __pyx_t_25 = __pyx_v_c;
10579                   __pyx_t_22 = 2;
10580                   *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[2]) / __pyx_v_nrm2);
10581                 }
10582                 __pyx_L26:;
10583 
10584                 /* "dipy/align/sumsqdiff.pyx":445
10585  *                         if(max_displacement < opt):
10586  *                             max_displacement = opt
10587  *                     elif(sigmasq < 1e-9):             # <<<<<<<<<<<<<<
10588  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
10589  *                             if(nrm2 < 1e-9):
10590  */
10591                 goto __pyx_L24;
10592               }
10593 
10594               /* "dipy/align/sumsqdiff.pyx":456
10595  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
10596  *                     else:
10597  *                         tau = sigmasq * lambda_param * nn             # <<<<<<<<<<<<<<
10598  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
10599  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
10600  */
10601               /*else*/ {
10602                 __pyx_v_tau = ((__pyx_v_sigmasq * __pyx_v_lambda_param) * __pyx_v_nn);
10603 
10604                 /* "dipy/align/sumsqdiff.pyx":457
10605  *                     else:
10606  *                         tau = sigmasq * lambda_param * nn
10607  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]             # <<<<<<<<<<<<<<
10608  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
10609  *                         y[2] = b[2] + sigmasq * lambda_param * y[2]
10610  */
10611                 (__pyx_v_y[0]) = ((__pyx_v_b[0]) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[0])));
10612 
10613                 /* "dipy/align/sumsqdiff.pyx":458
10614  *                         tau = sigmasq * lambda_param * nn
10615  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
10616  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]             # <<<<<<<<<<<<<<
10617  *                         y[2] = b[2] + sigmasq * lambda_param * y[2]
10618  *                         is_singular = _solve_3d_symmetric_positive_definite(
10619  */
10620                 (__pyx_v_y[1]) = ((__pyx_v_b[1]) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[1])));
10621 
10622                 /* "dipy/align/sumsqdiff.pyx":459
10623  *                         y[0] = b[0] + sigmasq * lambda_param * y[0]
10624  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
10625  *                         y[2] = b[2] + sigmasq * lambda_param * y[2]             # <<<<<<<<<<<<<<
10626  *                         is_singular = _solve_3d_symmetric_positive_definite(
10627  *                                                                 g, y, tau, d)
10628  */
10629                 (__pyx_v_y[2]) = ((__pyx_v_b[2]) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[2])));
10630 
10631                 /* "dipy/align/sumsqdiff.pyx":460
10632  *                         y[1] = b[1] + sigmasq * lambda_param * y[1]
10633  *                         y[2] = b[2] + sigmasq * lambda_param * y[2]
10634  *                         is_singular = _solve_3d_symmetric_positive_definite(             # <<<<<<<<<<<<<<
10635  *                                                                 g, y, tau, d)
10636  *                         if is_singular == 1:
10637  */
10638                 __pyx_v_is_singular = __pyx_f_4dipy_5align_9sumsqdiff__solve_3d_symmetric_positive_definite(__pyx_v_g, __pyx_v_y, __pyx_v_tau, __pyx_v_d);
10639 
10640                 /* "dipy/align/sumsqdiff.pyx":462
10641  *                         is_singular = _solve_3d_symmetric_positive_definite(
10642  *                                                                 g, y, tau, d)
10643  *                         if is_singular == 1:             # <<<<<<<<<<<<<<
10644  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
10645  *                             if(nrm2 < 1e-9):
10646  */
10647                 __pyx_t_27 = ((__pyx_v_is_singular == 1) != 0);
10648                 if (__pyx_t_27) {
10649 
10650                   /* "dipy/align/sumsqdiff.pyx":463
10651  *                                                                 g, y, tau, d)
10652  *                         if is_singular == 1:
10653  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2             # <<<<<<<<<<<<<<
10654  *                             if(nrm2 < 1e-9):
10655  *                                 disp[s, r, c, 0] = 0
10656  */
10657                   __pyx_v_nrm2 = ((pow((__pyx_v_g[0]), 2.0) + pow((__pyx_v_g[1]), 2.0)) + pow((__pyx_v_g[2]), 2.0));
10658 
10659                   /* "dipy/align/sumsqdiff.pyx":464
10660  *                         if is_singular == 1:
10661  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
10662  *                             if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
10663  *                                 disp[s, r, c, 0] = 0
10664  *                                 disp[s, r, c, 1] = 0
10665  */
10666                   __pyx_t_27 = ((__pyx_v_nrm2 < 1e-9) != 0);
10667                   if (__pyx_t_27) {
10668 
10669                     /* "dipy/align/sumsqdiff.pyx":465
10670  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
10671  *                             if(nrm2 < 1e-9):
10672  *                                 disp[s, r, c, 0] = 0             # <<<<<<<<<<<<<<
10673  *                                 disp[s, r, c, 1] = 0
10674  *                                 disp[s, r, c, 2] = 0
10675  */
10676                     __pyx_t_22 = __pyx_v_s;
10677                     __pyx_t_25 = __pyx_v_r;
10678                     __pyx_t_24 = __pyx_v_c;
10679                     __pyx_t_23 = 0;
10680                     *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = 0.0;
10681 
10682                     /* "dipy/align/sumsqdiff.pyx":466
10683  *                             if(nrm2 < 1e-9):
10684  *                                 disp[s, r, c, 0] = 0
10685  *                                 disp[s, r, c, 1] = 0             # <<<<<<<<<<<<<<
10686  *                                 disp[s, r, c, 2] = 0
10687  *                             else:
10688  */
10689                     __pyx_t_23 = __pyx_v_s;
10690                     __pyx_t_24 = __pyx_v_r;
10691                     __pyx_t_25 = __pyx_v_c;
10692                     __pyx_t_22 = 1;
10693                     *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = 0.0;
10694 
10695                     /* "dipy/align/sumsqdiff.pyx":467
10696  *                                 disp[s, r, c, 0] = 0
10697  *                                 disp[s, r, c, 1] = 0
10698  *                                 disp[s, r, c, 2] = 0             # <<<<<<<<<<<<<<
10699  *                             else:
10700  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
10701  */
10702                     __pyx_t_22 = __pyx_v_s;
10703                     __pyx_t_25 = __pyx_v_r;
10704                     __pyx_t_24 = __pyx_v_c;
10705                     __pyx_t_23 = 2;
10706                     *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = 0.0;
10707 
10708                     /* "dipy/align/sumsqdiff.pyx":464
10709  *                         if is_singular == 1:
10710  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
10711  *                             if(nrm2 < 1e-9):             # <<<<<<<<<<<<<<
10712  *                                 disp[s, r, c, 0] = 0
10713  *                                 disp[s, r, c, 1] = 0
10714  */
10715                     goto __pyx_L28;
10716                   }
10717 
10718                   /* "dipy/align/sumsqdiff.pyx":469
10719  *                                 disp[s, r, c, 2] = 0
10720  *                             else:
10721  *                                 disp[s, r, c, 0] = (b[0]) / nrm2             # <<<<<<<<<<<<<<
10722  *                                 disp[s, r, c, 1] = (b[1]) / nrm2
10723  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
10724  */
10725                   /*else*/ {
10726                     __pyx_t_23 = __pyx_v_s;
10727                     __pyx_t_24 = __pyx_v_r;
10728                     __pyx_t_25 = __pyx_v_c;
10729                     __pyx_t_22 = 0;
10730                     *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[0]) / __pyx_v_nrm2);
10731 
10732                     /* "dipy/align/sumsqdiff.pyx":470
10733  *                             else:
10734  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
10735  *                                 disp[s, r, c, 1] = (b[1]) / nrm2             # <<<<<<<<<<<<<<
10736  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
10737  *                         xx = disp[s, r, c, 0] - d[0]
10738  */
10739                     __pyx_t_22 = __pyx_v_s;
10740                     __pyx_t_25 = __pyx_v_r;
10741                     __pyx_t_24 = __pyx_v_c;
10742                     __pyx_t_23 = 1;
10743                     *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[1]) / __pyx_v_nrm2);
10744 
10745                     /* "dipy/align/sumsqdiff.pyx":471
10746  *                                 disp[s, r, c, 0] = (b[0]) / nrm2
10747  *                                 disp[s, r, c, 1] = (b[1]) / nrm2
10748  *                                 disp[s, r, c, 2] = (b[2]) / nrm2             # <<<<<<<<<<<<<<
10749  *                         xx = disp[s, r, c, 0] - d[0]
10750  *                         yy = disp[s, r, c, 1] - d[1]
10751  */
10752                     __pyx_t_23 = __pyx_v_s;
10753                     __pyx_t_24 = __pyx_v_r;
10754                     __pyx_t_25 = __pyx_v_c;
10755                     __pyx_t_22 = 2;
10756                     *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = ((__pyx_v_b[2]) / __pyx_v_nrm2);
10757                   }
10758                   __pyx_L28:;
10759 
10760                   /* "dipy/align/sumsqdiff.pyx":462
10761  *                         is_singular = _solve_3d_symmetric_positive_definite(
10762  *                                                                 g, y, tau, d)
10763  *                         if is_singular == 1:             # <<<<<<<<<<<<<<
10764  *                             nrm2 = g[0] ** 2 + g[1] ** 2 + g[2] ** 2
10765  *                             if(nrm2 < 1e-9):
10766  */
10767                 }
10768 
10769                 /* "dipy/align/sumsqdiff.pyx":472
10770  *                                 disp[s, r, c, 1] = (b[1]) / nrm2
10771  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
10772  *                         xx = disp[s, r, c, 0] - d[0]             # <<<<<<<<<<<<<<
10773  *                         yy = disp[s, r, c, 1] - d[1]
10774  *                         zz = disp[s, r, c, 2] - d[2]
10775  */
10776                 __pyx_t_22 = __pyx_v_s;
10777                 __pyx_t_25 = __pyx_v_r;
10778                 __pyx_t_24 = __pyx_v_c;
10779                 __pyx_t_23 = 0;
10780                 __pyx_v_xx = ((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) ))) - (__pyx_v_d[0]));
10781 
10782                 /* "dipy/align/sumsqdiff.pyx":473
10783  *                                 disp[s, r, c, 2] = (b[2]) / nrm2
10784  *                         xx = disp[s, r, c, 0] - d[0]
10785  *                         yy = disp[s, r, c, 1] - d[1]             # <<<<<<<<<<<<<<
10786  *                         zz = disp[s, r, c, 2] - d[2]
10787  *                         disp[s, r, c, 0] = d[0]
10788  */
10789                 __pyx_t_23 = __pyx_v_s;
10790                 __pyx_t_24 = __pyx_v_r;
10791                 __pyx_t_25 = __pyx_v_c;
10792                 __pyx_t_22 = 1;
10793                 __pyx_v_yy = ((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) ))) - (__pyx_v_d[1]));
10794 
10795                 /* "dipy/align/sumsqdiff.pyx":474
10796  *                         xx = disp[s, r, c, 0] - d[0]
10797  *                         yy = disp[s, r, c, 1] - d[1]
10798  *                         zz = disp[s, r, c, 2] - d[2]             # <<<<<<<<<<<<<<
10799  *                         disp[s, r, c, 0] = d[0]
10800  *                         disp[s, r, c, 1] = d[1]
10801  */
10802                 __pyx_t_22 = __pyx_v_s;
10803                 __pyx_t_25 = __pyx_v_r;
10804                 __pyx_t_24 = __pyx_v_c;
10805                 __pyx_t_23 = 2;
10806                 __pyx_v_zz = ((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) ))) - (__pyx_v_d[2]));
10807 
10808                 /* "dipy/align/sumsqdiff.pyx":475
10809  *                         yy = disp[s, r, c, 1] - d[1]
10810  *                         zz = disp[s, r, c, 2] - d[2]
10811  *                         disp[s, r, c, 0] = d[0]             # <<<<<<<<<<<<<<
10812  *                         disp[s, r, c, 1] = d[1]
10813  *                         disp[s, r, c, 2] = d[2]
10814  */
10815                 __pyx_t_23 = __pyx_v_s;
10816                 __pyx_t_24 = __pyx_v_r;
10817                 __pyx_t_25 = __pyx_v_c;
10818                 __pyx_t_22 = 0;
10819                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = (__pyx_v_d[0]);
10820 
10821                 /* "dipy/align/sumsqdiff.pyx":476
10822  *                         zz = disp[s, r, c, 2] - d[2]
10823  *                         disp[s, r, c, 0] = d[0]
10824  *                         disp[s, r, c, 1] = d[1]             # <<<<<<<<<<<<<<
10825  *                         disp[s, r, c, 2] = d[2]
10826  *                         opt = xx * xx + yy * yy + zz * zz
10827  */
10828                 __pyx_t_22 = __pyx_v_s;
10829                 __pyx_t_25 = __pyx_v_r;
10830                 __pyx_t_24 = __pyx_v_c;
10831                 __pyx_t_23 = 1;
10832                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_22 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )) = (__pyx_v_d[1]);
10833 
10834                 /* "dipy/align/sumsqdiff.pyx":477
10835  *                         disp[s, r, c, 0] = d[0]
10836  *                         disp[s, r, c, 1] = d[1]
10837  *                         disp[s, r, c, 2] = d[2]             # <<<<<<<<<<<<<<
10838  *                         opt = xx * xx + yy * yy + zz * zz
10839  *                         if(max_displacement < opt):
10840  */
10841                 __pyx_t_23 = __pyx_v_s;
10842                 __pyx_t_24 = __pyx_v_r;
10843                 __pyx_t_25 = __pyx_v_c;
10844                 __pyx_t_22 = 2;
10845                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_22 * __pyx_v_disp.strides[3]) )) = (__pyx_v_d[2]);
10846 
10847                 /* "dipy/align/sumsqdiff.pyx":478
10848  *                         disp[s, r, c, 1] = d[1]
10849  *                         disp[s, r, c, 2] = d[2]
10850  *                         opt = xx * xx + yy * yy + zz * zz             # <<<<<<<<<<<<<<
10851  *                         if(max_displacement < opt):
10852  *                             max_displacement = opt
10853  */
10854                 __pyx_v_opt = (((__pyx_v_xx * __pyx_v_xx) + (__pyx_v_yy * __pyx_v_yy)) + (__pyx_v_zz * __pyx_v_zz));
10855 
10856                 /* "dipy/align/sumsqdiff.pyx":479
10857  *                         disp[s, r, c, 2] = d[2]
10858  *                         opt = xx * xx + yy * yy + zz * zz
10859  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
10860  *                             max_displacement = opt
10861  *     return sqrt(max_displacement)
10862  */
10863                 __pyx_t_27 = ((__pyx_v_max_displacement < __pyx_v_opt) != 0);
10864                 if (__pyx_t_27) {
10865 
10866                   /* "dipy/align/sumsqdiff.pyx":480
10867  *                         opt = xx * xx + yy * yy + zz * zz
10868  *                         if(max_displacement < opt):
10869  *                             max_displacement = opt             # <<<<<<<<<<<<<<
10870  *     return sqrt(max_displacement)
10871  *
10872  */
10873                   __pyx_v_max_displacement = __pyx_v_opt;
10874 
10875                   /* "dipy/align/sumsqdiff.pyx":479
10876  *                         disp[s, r, c, 2] = d[2]
10877  *                         opt = xx * xx + yy * yy + zz * zz
10878  *                         if(max_displacement < opt):             # <<<<<<<<<<<<<<
10879  *                             max_displacement = opt
10880  *     return sqrt(max_displacement)
10881  */
10882                 }
10883               }
10884               __pyx_L24:;
10885             }
10886           }
10887         }
10888       }
10889 
10890       /* "dipy/align/sumsqdiff.pyx":396
10891  *     max_displacement = 0
10892  *
10893  *     with nogil:             # <<<<<<<<<<<<<<
10894  *
10895  *         for s in range(nslices):
10896  */
10897       /*finally:*/ {
10898         /*normal exit:*/{
10899           #ifdef WITH_THREAD
10900           __Pyx_FastGIL_Forget();
10901           Py_BLOCK_THREADS
10902           #endif
10903           goto __pyx_L5;
10904         }
10905         __pyx_L5:;
10906       }
10907   }
10908 
10909   /* "dipy/align/sumsqdiff.pyx":481
10910  *                         if(max_displacement < opt):
10911  *                             max_displacement = opt
10912  *     return sqrt(max_displacement)             # <<<<<<<<<<<<<<
10913  *
10914  *
10915  */
10916   __pyx_r = sqrt(__pyx_v_max_displacement);
10917   goto __pyx_L0;
10918 
10919   /* "dipy/align/sumsqdiff.pyx":336
10920  * @cython.wraparound(False)
10921  * @cython.cdivision(True)
10922  * cpdef double iterate_residual_displacement_field_ssd_3d(             # <<<<<<<<<<<<<<
10923  *                 floating[:, :, :] delta_field, floating[:, :, :] sigmasq_field,
10924  *                 floating[:, :, :, :] grad, floating[:, :, :, :] target,
10925  */
10926 
10927   /* function exit code */
10928   __pyx_L1_error:;
10929   __Pyx_XDECREF(__pyx_t_1);
10930   __Pyx_XDECREF(__pyx_t_2);
10931   __Pyx_XDECREF(__pyx_t_3);
10932   __Pyx_XDECREF(__pyx_t_4);
10933   __Pyx_WriteUnraisable("dipy.align.sumsqdiff.iterate_residual_displacement_field_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
10934   __pyx_r = 0;
10935   __pyx_L0:;
10936   __Pyx_XDECREF(__pyx_v_ftype);
10937   __Pyx_RefNannyFinishContext();
10938   return __pyx_r;
10939 }
10940 
10941 /* Python wrapper */
10942 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_35__pyx_fuse_1iterate_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
10943 static PyMethodDef __pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_35__pyx_fuse_1iterate_residual_displacement_field_ssd_3d = {"__pyx_fuse_1iterate_residual_displacement_field_ssd_3d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_35__pyx_fuse_1iterate_residual_displacement_field_ssd_3d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_8iterate_residual_displacement_field_ssd_3d};
__pyx_pw_4dipy_5align_9sumsqdiff_35__pyx_fuse_1iterate_residual_displacement_field_ssd_3d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)10944 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_35__pyx_fuse_1iterate_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
10945   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
10946   __Pyx_memviewslice __pyx_v_sigmasq_field = { 0, 0, { 0 }, { 0 }, { 0 } };
10947   __Pyx_memviewslice __pyx_v_grad = { 0, 0, { 0 }, { 0 }, { 0 } };
10948   __Pyx_memviewslice __pyx_v_target = { 0, 0, { 0 }, { 0 }, { 0 } };
10949   double __pyx_v_lambda_param;
10950   __Pyx_memviewslice __pyx_v_disp = { 0, 0, { 0 }, { 0 }, { 0 } };
10951   int __pyx_lineno = 0;
10952   const char *__pyx_filename = NULL;
10953   int __pyx_clineno = 0;
10954   PyObject *__pyx_r = 0;
10955   __Pyx_RefNannyDeclarations
10956   __Pyx_RefNannySetupContext("__pyx_fuse_1iterate_residual_displacement_field_ssd_3d (wrapper)", 0);
10957   {
10958     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_sigmasq_field,&__pyx_n_s_grad,&__pyx_n_s_target,&__pyx_n_s_lambda_param,&__pyx_n_s_disp,0};
10959     PyObject* values[6] = {0,0,0,0,0,0};
10960     if (unlikely(__pyx_kwds)) {
10961       Py_ssize_t kw_args;
10962       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
10963       switch (pos_args) {
10964         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
10965         CYTHON_FALLTHROUGH;
10966         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
10967         CYTHON_FALLTHROUGH;
10968         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
10969         CYTHON_FALLTHROUGH;
10970         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10971         CYTHON_FALLTHROUGH;
10972         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10973         CYTHON_FALLTHROUGH;
10974         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10975         CYTHON_FALLTHROUGH;
10976         case  0: break;
10977         default: goto __pyx_L5_argtuple_error;
10978       }
10979       kw_args = PyDict_Size(__pyx_kwds);
10980       switch (pos_args) {
10981         case  0:
10982         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
10983         else goto __pyx_L5_argtuple_error;
10984         CYTHON_FALLTHROUGH;
10985         case  1:
10986         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigmasq_field)) != 0)) kw_args--;
10987         else {
10988           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_3d", 1, 6, 6, 1); __PYX_ERR(0, 336, __pyx_L3_error)
10989         }
10990         CYTHON_FALLTHROUGH;
10991         case  2:
10992         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_grad)) != 0)) kw_args--;
10993         else {
10994           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_3d", 1, 6, 6, 2); __PYX_ERR(0, 336, __pyx_L3_error)
10995         }
10996         CYTHON_FALLTHROUGH;
10997         case  3:
10998         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--;
10999         else {
11000           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_3d", 1, 6, 6, 3); __PYX_ERR(0, 336, __pyx_L3_error)
11001         }
11002         CYTHON_FALLTHROUGH;
11003         case  4:
11004         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lambda_param)) != 0)) kw_args--;
11005         else {
11006           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_3d", 1, 6, 6, 4); __PYX_ERR(0, 336, __pyx_L3_error)
11007         }
11008         CYTHON_FALLTHROUGH;
11009         case  5:
11010         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_disp)) != 0)) kw_args--;
11011         else {
11012           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_3d", 1, 6, 6, 5); __PYX_ERR(0, 336, __pyx_L3_error)
11013         }
11014       }
11015       if (unlikely(kw_args > 0)) {
11016         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fuse_1iterate_residual_displacement_field_ssd_3d") < 0)) __PYX_ERR(0, 336, __pyx_L3_error)
11017       }
11018     } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
11019       goto __pyx_L5_argtuple_error;
11020     } else {
11021       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11022       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
11023       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
11024       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
11025       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
11026       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
11027     }
11028     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 337, __pyx_L3_error)
11029     __pyx_v_sigmasq_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_sigmasq_field.memview)) __PYX_ERR(0, 337, __pyx_L3_error)
11030     __pyx_v_grad = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_grad.memview)) __PYX_ERR(0, 338, __pyx_L3_error)
11031     __pyx_v_target = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_target.memview)) __PYX_ERR(0, 338, __pyx_L3_error)
11032     __pyx_v_lambda_param = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_lambda_param == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 339, __pyx_L3_error)
11033     __pyx_v_disp = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_disp.memview)) __PYX_ERR(0, 339, __pyx_L3_error)
11034   }
11035   goto __pyx_L4_argument_unpacking_done;
11036   __pyx_L5_argtuple_error:;
11037   __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1iterate_residual_displacement_field_ssd_3d", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 336, __pyx_L3_error)
11038   __pyx_L3_error:;
11039   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_1iterate_residual_displacement_field_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
11040   __Pyx_RefNannyFinishContext();
11041   return NULL;
11042   __pyx_L4_argument_unpacking_done:;
11043   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_34__pyx_fuse_1iterate_residual_displacement_field_ssd_3d(__pyx_self, __pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_grad, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_disp);
11044 
11045   /* function exit code */
11046   __Pyx_RefNannyFinishContext();
11047   return __pyx_r;
11048 }
11049 
__pyx_pf_4dipy_5align_9sumsqdiff_34__pyx_fuse_1iterate_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_grad,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_disp)11050 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_34__pyx_fuse_1iterate_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_grad, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_disp) {
11051   PyObject *__pyx_r = NULL;
11052   __Pyx_RefNannyDeclarations
11053   PyObject *__pyx_t_1 = NULL;
11054   int __pyx_lineno = 0;
11055   const char *__pyx_filename = NULL;
11056   int __pyx_clineno = 0;
11057   __Pyx_RefNannySetupContext("__pyx_fuse_1iterate_residual_displacement_field_ssd_3d", 0);
11058   __Pyx_XDECREF(__pyx_r);
11059   if (unlikely(!__pyx_v_delta_field.memview)) { __Pyx_RaiseUnboundLocalError("delta_field"); __PYX_ERR(0, 336, __pyx_L1_error) }
11060   if (unlikely(!__pyx_v_sigmasq_field.memview)) { __Pyx_RaiseUnboundLocalError("sigmasq_field"); __PYX_ERR(0, 336, __pyx_L1_error) }
11061   if (unlikely(!__pyx_v_grad.memview)) { __Pyx_RaiseUnboundLocalError("grad"); __PYX_ERR(0, 336, __pyx_L1_error) }
11062   if (unlikely(!__pyx_v_target.memview)) { __Pyx_RaiseUnboundLocalError("target"); __PYX_ERR(0, 336, __pyx_L1_error) }
11063   if (unlikely(!__pyx_v_disp.memview)) { __Pyx_RaiseUnboundLocalError("disp"); __PYX_ERR(0, 336, __pyx_L1_error) }
11064   __pyx_t_1 = PyFloat_FromDouble(__pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_iterate_residual_displacement_field_ssd_3d(__pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_grad, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_disp, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
11065   __Pyx_GOTREF(__pyx_t_1);
11066   __pyx_r = __pyx_t_1;
11067   __pyx_t_1 = 0;
11068   goto __pyx_L0;
11069 
11070   /* function exit code */
11071   __pyx_L1_error:;
11072   __Pyx_XDECREF(__pyx_t_1);
11073   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_1iterate_residual_displacement_field_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
11074   __pyx_r = NULL;
11075   __pyx_L0:;
11076   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
11077   __PYX_XDEC_MEMVIEW(&__pyx_v_sigmasq_field, 1);
11078   __PYX_XDEC_MEMVIEW(&__pyx_v_grad, 1);
11079   __PYX_XDEC_MEMVIEW(&__pyx_v_target, 1);
11080   __PYX_XDEC_MEMVIEW(&__pyx_v_disp, 1);
11081   __Pyx_XGIVEREF(__pyx_r);
11082   __Pyx_RefNannyFinishContext();
11083   return __pyx_r;
11084 }
11085 
11086 /* "dipy/align/sumsqdiff.pyx":486
11087  * @cython.boundscheck(False)
11088  * @cython.wraparound(False)
11089  * cpdef double compute_energy_ssd_3d(floating[:, :, :] delta_field):             # <<<<<<<<<<<<<<
11090  *     r"""Sum of squared differences between two 3D volumes
11091  *
11092  */
11093 
11094 /* Python wrapper */
11095 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_11compute_energy_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
11096 static char __pyx_doc_4dipy_5align_9sumsqdiff_10compute_energy_ssd_3d[] = "Sum of squared differences between two 3D volumes\n\n    Computes the Sum of Squared Differences between the static and moving volume\n    Those differences are given by delta_field\n\n    Parameters\n    ----------\n    delta_field : array, shape (R, C)\n        the difference between the static and moving image (the 'derivative\n        w.r.t. time' in the optical flow model)\n\n    Returns\n    -------\n    energy : float\n        the SSD energy at this iteration\n\n    Notes\n    -----\n    The numeric value of the energy is used only to detect convergence.\n    This function returns only the energy corresponding to the data term\n    (excluding the energy corresponding to the regularization term) because\n    the Greedy-SyN algorithm is an unconstrained gradient descent algorithm\n    in the space of diffeomorphisms: in each iteration it makes a step\n    along the negative smoothed gradient --of the data term-- and then makes\n    sure the resulting diffeomorphisms are invertible using an explicit\n    inversion algorithm. Since it is not clear how to reflect the energy\n    corresponding to this re-projection to the space of diffeomorphisms,\n    a more precise energy computation including the regularization term\n    is useless. Instead, convergence is checked considering the data-term\n    energy only and detecting oscilations in the energy profile.\n    ";
11097 static PyMethodDef __pyx_mdef_4dipy_5align_9sumsqdiff_11compute_energy_ssd_3d = {"compute_energy_ssd_3d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_11compute_energy_ssd_3d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_10compute_energy_ssd_3d};
__pyx_pw_4dipy_5align_9sumsqdiff_11compute_energy_ssd_3d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)11098 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_11compute_energy_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
11099   PyObject *__pyx_v_signatures = 0;
11100   PyObject *__pyx_v_args = 0;
11101   PyObject *__pyx_v_kwargs = 0;
11102   CYTHON_UNUSED PyObject *__pyx_v_defaults = 0;
11103   int __pyx_lineno = 0;
11104   const char *__pyx_filename = NULL;
11105   int __pyx_clineno = 0;
11106   PyObject *__pyx_r = 0;
11107   __Pyx_RefNannyDeclarations
11108   __Pyx_RefNannySetupContext("__pyx_fused_cpdef (wrapper)", 0);
11109   {
11110     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signatures,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_defaults,0};
11111     PyObject* values[4] = {0,0,0,0};
11112     if (unlikely(__pyx_kwds)) {
11113       Py_ssize_t kw_args;
11114       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
11115       switch (pos_args) {
11116         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
11117         CYTHON_FALLTHROUGH;
11118         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
11119         CYTHON_FALLTHROUGH;
11120         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
11121         CYTHON_FALLTHROUGH;
11122         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11123         CYTHON_FALLTHROUGH;
11124         case  0: break;
11125         default: goto __pyx_L5_argtuple_error;
11126       }
11127       kw_args = PyDict_Size(__pyx_kwds);
11128       switch (pos_args) {
11129         case  0:
11130         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signatures)) != 0)) kw_args--;
11131         else goto __pyx_L5_argtuple_error;
11132         CYTHON_FALLTHROUGH;
11133         case  1:
11134         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
11135         else {
11136           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 1); __PYX_ERR(0, 486, __pyx_L3_error)
11137         }
11138         CYTHON_FALLTHROUGH;
11139         case  2:
11140         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
11141         else {
11142           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); __PYX_ERR(0, 486, __pyx_L3_error)
11143         }
11144         CYTHON_FALLTHROUGH;
11145         case  3:
11146         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--;
11147         else {
11148           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); __PYX_ERR(0, 486, __pyx_L3_error)
11149         }
11150       }
11151       if (unlikely(kw_args > 0)) {
11152         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) __PYX_ERR(0, 486, __pyx_L3_error)
11153       }
11154     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
11155       goto __pyx_L5_argtuple_error;
11156     } else {
11157       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11158       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
11159       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
11160       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
11161     }
11162     __pyx_v_signatures = values[0];
11163     __pyx_v_args = values[1];
11164     __pyx_v_kwargs = values[2];
11165     __pyx_v_defaults = values[3];
11166   }
11167   goto __pyx_L4_argument_unpacking_done;
11168   __pyx_L5_argtuple_error:;
11169   __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 486, __pyx_L3_error)
11170   __pyx_L3_error:;
11171   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
11172   __Pyx_RefNannyFinishContext();
11173   return NULL;
11174   __pyx_L4_argument_unpacking_done:;
11175   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_10compute_energy_ssd_3d(__pyx_self, __pyx_v_signatures, __pyx_v_args, __pyx_v_kwargs, __pyx_v_defaults);
11176 
11177   /* function exit code */
11178   __Pyx_RefNannyFinishContext();
11179   return __pyx_r;
11180 }
11181 
__pyx_pf_4dipy_5align_9sumsqdiff_10compute_energy_ssd_3d(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_signatures,PyObject * __pyx_v_args,PyObject * __pyx_v_kwargs,CYTHON_UNUSED PyObject * __pyx_v_defaults)11182 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_10compute_energy_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults) {
11183   PyObject *__pyx_v_dest_sig = NULL;
11184   Py_ssize_t __pyx_v_i;
11185   PyTypeObject *__pyx_v_ndarray = 0;
11186   __Pyx_memviewslice __pyx_v_memslice;
11187   Py_ssize_t __pyx_v_itemsize;
11188   CYTHON_UNUSED int __pyx_v_dtype_signed;
11189   char __pyx_v_kind;
11190   PyObject *__pyx_v_arg = NULL;
11191   PyObject *__pyx_v_dtype = NULL;
11192   PyObject *__pyx_v_arg_base = NULL;
11193   PyObject *__pyx_v_candidates = NULL;
11194   PyObject *__pyx_v_sig = NULL;
11195   int __pyx_v_match_found;
11196   PyObject *__pyx_v_src_sig = NULL;
11197   PyObject *__pyx_v_dst_type = NULL;
11198   PyObject *__pyx_r = NULL;
11199   __Pyx_RefNannyDeclarations
11200   PyObject *__pyx_t_1 = NULL;
11201   int __pyx_t_2;
11202   int __pyx_t_3;
11203   int __pyx_t_4;
11204   Py_ssize_t __pyx_t_5;
11205   PyObject *__pyx_t_6 = NULL;
11206   long __pyx_t_7;
11207   __Pyx_memviewslice __pyx_t_8;
11208   Py_ssize_t __pyx_t_9;
11209   int __pyx_t_10;
11210   int __pyx_t_11;
11211   PyObject *__pyx_t_12 = NULL;
11212   PyObject *__pyx_t_13 = NULL;
11213   PyObject *__pyx_t_14 = NULL;
11214   Py_ssize_t __pyx_t_15;
11215   Py_ssize_t __pyx_t_16;
11216   Py_ssize_t __pyx_t_17;
11217   int __pyx_t_18;
11218   int __pyx_lineno = 0;
11219   const char *__pyx_filename = NULL;
11220   int __pyx_clineno = 0;
11221   __Pyx_RefNannySetupContext("compute_energy_ssd_3d", 0);
11222   __Pyx_INCREF(__pyx_v_kwargs);
11223   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
11224   __Pyx_GOTREF(__pyx_t_1);
11225   __Pyx_INCREF(Py_None);
11226   __Pyx_GIVEREF(Py_None);
11227   PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
11228   __pyx_v_dest_sig = ((PyObject*)__pyx_t_1);
11229   __pyx_t_1 = 0;
11230   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
11231   __pyx_t_4 = (__pyx_t_3 != 0);
11232   if (__pyx_t_4) {
11233   } else {
11234     __pyx_t_2 = __pyx_t_4;
11235     goto __pyx_L4_bool_binop_done;
11236   }
11237   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
11238   __pyx_t_3 = ((!__pyx_t_4) != 0);
11239   __pyx_t_2 = __pyx_t_3;
11240   __pyx_L4_bool_binop_done:;
11241   if (__pyx_t_2) {
11242     __Pyx_INCREF(Py_None);
11243     __Pyx_DECREF_SET(__pyx_v_kwargs, Py_None);
11244   }
11245   __pyx_t_1 = ((PyObject *)__Pyx_ImportNumPyArrayTypeIfAvailable()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
11246   __Pyx_GOTREF(__pyx_t_1);
11247   __pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1);
11248   __pyx_t_1 = 0;
11249   __pyx_v_itemsize = -1L;
11250   if (unlikely(__pyx_v_args == Py_None)) {
11251     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
11252     __PYX_ERR(0, 486, __pyx_L1_error)
11253   }
11254   __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 486, __pyx_L1_error)
11255   __pyx_t_2 = ((0 < __pyx_t_5) != 0);
11256   if (__pyx_t_2) {
11257     if (unlikely(__pyx_v_args == Py_None)) {
11258       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
11259       __PYX_ERR(0, 486, __pyx_L1_error)
11260     }
11261     __pyx_t_1 = PyTuple_GET_ITEM(((PyObject*)__pyx_v_args), 0);
11262     __Pyx_INCREF(__pyx_t_1);
11263     __pyx_v_arg = __pyx_t_1;
11264     __pyx_t_1 = 0;
11265     goto __pyx_L6;
11266   }
11267   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
11268   __pyx_t_4 = (__pyx_t_3 != 0);
11269   if (__pyx_t_4) {
11270   } else {
11271     __pyx_t_2 = __pyx_t_4;
11272     goto __pyx_L7_bool_binop_done;
11273   }
11274   if (unlikely(__pyx_v_kwargs == Py_None)) {
11275     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
11276     __PYX_ERR(0, 486, __pyx_L1_error)
11277   }
11278   __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_delta_field, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
11279   __pyx_t_3 = (__pyx_t_4 != 0);
11280   __pyx_t_2 = __pyx_t_3;
11281   __pyx_L7_bool_binop_done:;
11282   if (__pyx_t_2) {
11283     if (unlikely(__pyx_v_kwargs == Py_None)) {
11284       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
11285       __PYX_ERR(0, 486, __pyx_L1_error)
11286     }
11287     __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_delta_field); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
11288     __Pyx_GOTREF(__pyx_t_1);
11289     __pyx_v_arg = __pyx_t_1;
11290     __pyx_t_1 = 0;
11291     goto __pyx_L6;
11292   }
11293   /*else*/ {
11294     if (unlikely(__pyx_v_args == Py_None)) {
11295       PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
11296       __PYX_ERR(0, 486, __pyx_L1_error)
11297     }
11298     __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 486, __pyx_L1_error)
11299     __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
11300     __Pyx_GOTREF(__pyx_t_1);
11301     __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11302     __Pyx_GOTREF(__pyx_t_6);
11303     __Pyx_INCREF(__pyx_int_1);
11304     __Pyx_GIVEREF(__pyx_int_1);
11305     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
11306     __Pyx_INCREF(__pyx_kp_s__7);
11307     __Pyx_GIVEREF(__pyx_kp_s__7);
11308     PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_kp_s__7);
11309     __Pyx_GIVEREF(__pyx_t_1);
11310     PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
11311     __pyx_t_1 = 0;
11312     __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
11313     __Pyx_GOTREF(__pyx_t_1);
11314     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11315     __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11316     __Pyx_GOTREF(__pyx_t_6);
11317     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11318     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
11319     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11320     __PYX_ERR(0, 486, __pyx_L1_error)
11321   }
11322   __pyx_L6:;
11323   while (1) {
11324     __pyx_t_2 = (__pyx_v_ndarray != ((PyTypeObject*)Py_None));
11325     __pyx_t_3 = (__pyx_t_2 != 0);
11326     if (__pyx_t_3) {
11327       __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray);
11328       __pyx_t_2 = (__pyx_t_3 != 0);
11329       if (__pyx_t_2) {
11330         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11331         __Pyx_GOTREF(__pyx_t_6);
11332         __pyx_v_dtype = __pyx_t_6;
11333         __pyx_t_6 = 0;
11334         goto __pyx_L12;
11335       }
11336       __pyx_t_2 = __pyx_memoryview_check(__pyx_v_arg);
11337       __pyx_t_3 = (__pyx_t_2 != 0);
11338       if (__pyx_t_3) {
11339         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11340         __Pyx_GOTREF(__pyx_t_6);
11341         __pyx_v_arg_base = __pyx_t_6;
11342         __pyx_t_6 = 0;
11343         __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray);
11344         __pyx_t_2 = (__pyx_t_3 != 0);
11345         if (__pyx_t_2) {
11346           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11347           __Pyx_GOTREF(__pyx_t_6);
11348           __pyx_v_dtype = __pyx_t_6;
11349           __pyx_t_6 = 0;
11350           goto __pyx_L13;
11351         }
11352         /*else*/ {
11353           __Pyx_INCREF(Py_None);
11354           __pyx_v_dtype = Py_None;
11355         }
11356         __pyx_L13:;
11357         goto __pyx_L12;
11358       }
11359       /*else*/ {
11360         __Pyx_INCREF(Py_None);
11361         __pyx_v_dtype = Py_None;
11362       }
11363       __pyx_L12:;
11364       __pyx_v_itemsize = -1L;
11365       __pyx_t_2 = (__pyx_v_dtype != Py_None);
11366       __pyx_t_3 = (__pyx_t_2 != 0);
11367       if (__pyx_t_3) {
11368         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11369         __Pyx_GOTREF(__pyx_t_6);
11370         __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L1_error)
11371         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11372         __pyx_v_itemsize = __pyx_t_5;
11373         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11374         __Pyx_GOTREF(__pyx_t_6);
11375         __pyx_t_7 = __Pyx_PyObject_Ord(__pyx_t_6); if (unlikely(__pyx_t_7 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 486, __pyx_L1_error)
11376         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11377         __pyx_v_kind = __pyx_t_7;
11378         __pyx_v_dtype_signed = (__pyx_v_kind == 'i');
11379         switch (__pyx_v_kind) {
11380           case 'i':
11381           case 'u':
11382           break;
11383           case 'f':
11384           __pyx_t_2 = (((sizeof(float)) == __pyx_v_itemsize) != 0);
11385           if (__pyx_t_2) {
11386           } else {
11387             __pyx_t_3 = __pyx_t_2;
11388             goto __pyx_L16_bool_binop_done;
11389           }
11390           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11391           __Pyx_GOTREF(__pyx_t_6);
11392           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L1_error)
11393           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11394           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0);
11395           __pyx_t_3 = __pyx_t_2;
11396           __pyx_L16_bool_binop_done:;
11397           if (__pyx_t_3) {
11398             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
11399             goto __pyx_L10_break;
11400           }
11401           __pyx_t_2 = (((sizeof(double)) == __pyx_v_itemsize) != 0);
11402           if (__pyx_t_2) {
11403           } else {
11404             __pyx_t_3 = __pyx_t_2;
11405             goto __pyx_L19_bool_binop_done;
11406           }
11407           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11408           __Pyx_GOTREF(__pyx_t_6);
11409           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L1_error)
11410           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11411           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0);
11412           __pyx_t_3 = __pyx_t_2;
11413           __pyx_L19_bool_binop_done:;
11414           if (__pyx_t_3) {
11415             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
11416             goto __pyx_L10_break;
11417           }
11418           break;
11419           case 'c':
11420           break;
11421           case 'O':
11422           break;
11423           default: break;
11424         }
11425       }
11426     }
11427     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
11428     if (!__pyx_t_2) {
11429     } else {
11430       __pyx_t_3 = __pyx_t_2;
11431       goto __pyx_L22_bool_binop_done;
11432     }
11433     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(float))) != 0);
11434     __pyx_t_3 = __pyx_t_2;
11435     __pyx_L22_bool_binop_done:;
11436     if (__pyx_t_3) {
11437       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(__pyx_v_arg, 0);
11438       __pyx_v_memslice = __pyx_t_8;
11439       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
11440       if (__pyx_t_3) {
11441         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
11442         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
11443         goto __pyx_L10_break;
11444       }
11445       /*else*/ {
11446         PyErr_Clear();
11447       }
11448     }
11449     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
11450     if (!__pyx_t_2) {
11451     } else {
11452       __pyx_t_3 = __pyx_t_2;
11453       goto __pyx_L26_bool_binop_done;
11454     }
11455     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(double))) != 0);
11456     __pyx_t_3 = __pyx_t_2;
11457     __pyx_L26_bool_binop_done:;
11458     if (__pyx_t_3) {
11459       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(__pyx_v_arg, 0);
11460       __pyx_v_memslice = __pyx_t_8;
11461       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
11462       if (__pyx_t_3) {
11463         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
11464         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
11465         goto __pyx_L10_break;
11466       }
11467       /*else*/ {
11468         PyErr_Clear();
11469       }
11470     }
11471     if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
11472     goto __pyx_L10_break;
11473   }
11474   __pyx_L10_break:;
11475   __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11476   __Pyx_GOTREF(__pyx_t_6);
11477   __pyx_v_candidates = ((PyObject*)__pyx_t_6);
11478   __pyx_t_6 = 0;
11479   __pyx_t_5 = 0;
11480   if (unlikely(__pyx_v_signatures == Py_None)) {
11481     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
11482     __PYX_ERR(0, 486, __pyx_L1_error)
11483   }
11484   __pyx_t_1 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
11485   __Pyx_GOTREF(__pyx_t_1);
11486   __Pyx_XDECREF(__pyx_t_6);
11487   __pyx_t_6 = __pyx_t_1;
11488   __pyx_t_1 = 0;
11489   while (1) {
11490     __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_5, &__pyx_t_1, NULL, NULL, __pyx_t_10);
11491     if (unlikely(__pyx_t_11 == 0)) break;
11492     if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 486, __pyx_L1_error)
11493     __Pyx_GOTREF(__pyx_t_1);
11494     __Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_1);
11495     __pyx_t_1 = 0;
11496     __pyx_v_match_found = 0;
11497     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 486, __pyx_L1_error)
11498     __Pyx_GOTREF(__pyx_t_13);
11499     __pyx_t_14 = NULL;
11500     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
11501       __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
11502       if (likely(__pyx_t_14)) {
11503         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
11504         __Pyx_INCREF(__pyx_t_14);
11505         __Pyx_INCREF(function);
11506         __Pyx_DECREF_SET(__pyx_t_13, function);
11507       }
11508     }
11509     __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_kp_s__3) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__3);
11510     __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
11511     if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 486, __pyx_L1_error)
11512     __Pyx_GOTREF(__pyx_t_12);
11513     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
11514     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_split); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 486, __pyx_L1_error)
11515     __Pyx_GOTREF(__pyx_t_13);
11516     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
11517     __pyx_t_12 = NULL;
11518     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
11519       __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
11520       if (likely(__pyx_t_12)) {
11521         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
11522         __Pyx_INCREF(__pyx_t_12);
11523         __Pyx_INCREF(function);
11524         __Pyx_DECREF_SET(__pyx_t_13, function);
11525       }
11526     }
11527     __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_kp_s__4) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__4);
11528     __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
11529     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
11530     __Pyx_GOTREF(__pyx_t_1);
11531     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
11532     __Pyx_XDECREF_SET(__pyx_v_src_sig, __pyx_t_1);
11533     __pyx_t_1 = 0;
11534     __pyx_t_15 = PyList_GET_SIZE(__pyx_v_dest_sig); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 486, __pyx_L1_error)
11535     __pyx_t_16 = __pyx_t_15;
11536     for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
11537       __pyx_v_i = __pyx_t_17;
11538       __pyx_t_1 = PyList_GET_ITEM(__pyx_v_dest_sig, __pyx_v_i);
11539       __Pyx_INCREF(__pyx_t_1);
11540       __Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_1);
11541       __pyx_t_1 = 0;
11542       __pyx_t_3 = (__pyx_v_dst_type != Py_None);
11543       __pyx_t_2 = (__pyx_t_3 != 0);
11544       if (__pyx_t_2) {
11545         __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
11546         __Pyx_GOTREF(__pyx_t_1);
11547         __pyx_t_13 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 486, __pyx_L1_error)
11548         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11549         __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
11550         __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
11551         if (__pyx_t_2) {
11552           __pyx_v_match_found = 1;
11553           goto __pyx_L34;
11554         }
11555         /*else*/ {
11556           __pyx_v_match_found = 0;
11557           goto __pyx_L32_break;
11558         }
11559         __pyx_L34:;
11560       }
11561     }
11562     __pyx_L32_break:;
11563     __pyx_t_2 = (__pyx_v_match_found != 0);
11564     if (__pyx_t_2) {
11565       __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 486, __pyx_L1_error)
11566     }
11567   }
11568   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11569   __pyx_t_2 = (PyList_GET_SIZE(__pyx_v_candidates) != 0);
11570   __pyx_t_3 = ((!__pyx_t_2) != 0);
11571   if (__pyx_t_3) {
11572     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11573     __Pyx_GOTREF(__pyx_t_6);
11574     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
11575     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11576     __PYX_ERR(0, 486, __pyx_L1_error)
11577   }
11578   __pyx_t_9 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 486, __pyx_L1_error)
11579   __pyx_t_3 = ((__pyx_t_9 > 1) != 0);
11580   if (__pyx_t_3) {
11581     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11582     __Pyx_GOTREF(__pyx_t_6);
11583     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
11584     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11585     __PYX_ERR(0, 486, __pyx_L1_error)
11586   }
11587   /*else*/ {
11588     __Pyx_XDECREF(__pyx_r);
11589     if (unlikely(__pyx_v_signatures == Py_None)) {
11590       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
11591       __PYX_ERR(0, 486, __pyx_L1_error)
11592     }
11593     __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), PyList_GET_ITEM(__pyx_v_candidates, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 486, __pyx_L1_error)
11594     __Pyx_GOTREF(__pyx_t_6);
11595     __pyx_r = __pyx_t_6;
11596     __pyx_t_6 = 0;
11597     goto __pyx_L0;
11598   }
11599 
11600   /* function exit code */
11601   __pyx_L1_error:;
11602   __Pyx_XDECREF(__pyx_t_1);
11603   __Pyx_XDECREF(__pyx_t_6);
11604   __Pyx_XDECREF(__pyx_t_12);
11605   __Pyx_XDECREF(__pyx_t_13);
11606   __Pyx_XDECREF(__pyx_t_14);
11607   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
11608   __pyx_r = NULL;
11609   __pyx_L0:;
11610   __Pyx_XDECREF(__pyx_v_dest_sig);
11611   __Pyx_XDECREF(__pyx_v_ndarray);
11612   __Pyx_XDECREF(__pyx_v_arg);
11613   __Pyx_XDECREF(__pyx_v_dtype);
11614   __Pyx_XDECREF(__pyx_v_arg_base);
11615   __Pyx_XDECREF(__pyx_v_candidates);
11616   __Pyx_XDECREF(__pyx_v_sig);
11617   __Pyx_XDECREF(__pyx_v_src_sig);
11618   __Pyx_XDECREF(__pyx_v_dst_type);
11619   __Pyx_XDECREF(__pyx_v_kwargs);
11620   __Pyx_XGIVEREF(__pyx_r);
11621   __Pyx_RefNannyFinishContext();
11622   return __pyx_r;
11623 }
11624 
11625 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_39__pyx_fuse_0compute_energy_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field); /*proto*/
11626 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_11compute_energy_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_3d(__Pyx_memviewslice __pyx_v_delta_field,CYTHON_UNUSED int __pyx_skip_dispatch)11627 static double __pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_3d(__Pyx_memviewslice __pyx_v_delta_field, CYTHON_UNUSED int __pyx_skip_dispatch) {
11628   npy_intp __pyx_v_nslices;
11629   npy_intp __pyx_v_nrows;
11630   npy_intp __pyx_v_ncols;
11631   npy_intp __pyx_v_s;
11632   npy_intp __pyx_v_r;
11633   npy_intp __pyx_v_c;
11634   double __pyx_v_energy;
11635   double __pyx_r;
11636   __Pyx_RefNannyDeclarations
11637   npy_intp __pyx_t_1;
11638   npy_intp __pyx_t_2;
11639   npy_intp __pyx_t_3;
11640   npy_intp __pyx_t_4;
11641   npy_intp __pyx_t_5;
11642   npy_intp __pyx_t_6;
11643   npy_intp __pyx_t_7;
11644   npy_intp __pyx_t_8;
11645   npy_intp __pyx_t_9;
11646   Py_ssize_t __pyx_t_10;
11647   Py_ssize_t __pyx_t_11;
11648   Py_ssize_t __pyx_t_12;
11649   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_energy_ssd_3d", 0);
11650 
11651   /* "dipy/align/sumsqdiff.pyx":519
11652  *     """
11653  *     cdef:
11654  *         cnp.npy_intp nslices = delta_field.shape[0]             # <<<<<<<<<<<<<<
11655  *         cnp.npy_intp nrows = delta_field.shape[1]
11656  *         cnp.npy_intp ncols = delta_field.shape[2]
11657  */
11658   __pyx_v_nslices = (__pyx_v_delta_field.shape[0]);
11659 
11660   /* "dipy/align/sumsqdiff.pyx":520
11661  *     cdef:
11662  *         cnp.npy_intp nslices = delta_field.shape[0]
11663  *         cnp.npy_intp nrows = delta_field.shape[1]             # <<<<<<<<<<<<<<
11664  *         cnp.npy_intp ncols = delta_field.shape[2]
11665  *         cnp.npy_intp s, r, c
11666  */
11667   __pyx_v_nrows = (__pyx_v_delta_field.shape[1]);
11668 
11669   /* "dipy/align/sumsqdiff.pyx":521
11670  *         cnp.npy_intp nslices = delta_field.shape[0]
11671  *         cnp.npy_intp nrows = delta_field.shape[1]
11672  *         cnp.npy_intp ncols = delta_field.shape[2]             # <<<<<<<<<<<<<<
11673  *         cnp.npy_intp s, r, c
11674  *         double energy = 0
11675  */
11676   __pyx_v_ncols = (__pyx_v_delta_field.shape[2]);
11677 
11678   /* "dipy/align/sumsqdiff.pyx":523
11679  *         cnp.npy_intp ncols = delta_field.shape[2]
11680  *         cnp.npy_intp s, r, c
11681  *         double energy = 0             # <<<<<<<<<<<<<<
11682  *     with nogil:
11683  *         for s in range(nslices):
11684  */
11685   __pyx_v_energy = 0.0;
11686 
11687   /* "dipy/align/sumsqdiff.pyx":524
11688  *         cnp.npy_intp s, r, c
11689  *         double energy = 0
11690  *     with nogil:             # <<<<<<<<<<<<<<
11691  *         for s in range(nslices):
11692  *             for r in range(nrows):
11693  */
11694   {
11695       #ifdef WITH_THREAD
11696       PyThreadState *_save;
11697       Py_UNBLOCK_THREADS
11698       __Pyx_FastGIL_Remember();
11699       #endif
11700       /*try:*/ {
11701 
11702         /* "dipy/align/sumsqdiff.pyx":525
11703  *         double energy = 0
11704  *     with nogil:
11705  *         for s in range(nslices):             # <<<<<<<<<<<<<<
11706  *             for r in range(nrows):
11707  *                 for c in range(ncols):
11708  */
11709         __pyx_t_1 = __pyx_v_nslices;
11710         __pyx_t_2 = __pyx_t_1;
11711         for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
11712           __pyx_v_s = __pyx_t_3;
11713 
11714           /* "dipy/align/sumsqdiff.pyx":526
11715  *     with nogil:
11716  *         for s in range(nslices):
11717  *             for r in range(nrows):             # <<<<<<<<<<<<<<
11718  *                 for c in range(ncols):
11719  *                     energy += delta_field[s, r, c] ** 2
11720  */
11721           __pyx_t_4 = __pyx_v_nrows;
11722           __pyx_t_5 = __pyx_t_4;
11723           for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
11724             __pyx_v_r = __pyx_t_6;
11725 
11726             /* "dipy/align/sumsqdiff.pyx":527
11727  *         for s in range(nslices):
11728  *             for r in range(nrows):
11729  *                 for c in range(ncols):             # <<<<<<<<<<<<<<
11730  *                     energy += delta_field[s, r, c] ** 2
11731  *     return energy
11732  */
11733             __pyx_t_7 = __pyx_v_ncols;
11734             __pyx_t_8 = __pyx_t_7;
11735             for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
11736               __pyx_v_c = __pyx_t_9;
11737 
11738               /* "dipy/align/sumsqdiff.pyx":528
11739  *             for r in range(nrows):
11740  *                 for c in range(ncols):
11741  *                     energy += delta_field[s, r, c] ** 2             # <<<<<<<<<<<<<<
11742  *     return energy
11743  *
11744  */
11745               __pyx_t_10 = __pyx_v_s;
11746               __pyx_t_11 = __pyx_v_r;
11747               __pyx_t_12 = __pyx_v_c;
11748               __pyx_v_energy = (__pyx_v_energy + powf((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_10 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_11 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_12 * __pyx_v_delta_field.strides[2]) ))), 2.0));
11749             }
11750           }
11751         }
11752       }
11753 
11754       /* "dipy/align/sumsqdiff.pyx":524
11755  *         cnp.npy_intp s, r, c
11756  *         double energy = 0
11757  *     with nogil:             # <<<<<<<<<<<<<<
11758  *         for s in range(nslices):
11759  *             for r in range(nrows):
11760  */
11761       /*finally:*/ {
11762         /*normal exit:*/{
11763           #ifdef WITH_THREAD
11764           __Pyx_FastGIL_Forget();
11765           Py_BLOCK_THREADS
11766           #endif
11767           goto __pyx_L5;
11768         }
11769         __pyx_L5:;
11770       }
11771   }
11772 
11773   /* "dipy/align/sumsqdiff.pyx":529
11774  *                 for c in range(ncols):
11775  *                     energy += delta_field[s, r, c] ** 2
11776  *     return energy             # <<<<<<<<<<<<<<
11777  *
11778  *
11779  */
11780   __pyx_r = __pyx_v_energy;
11781   goto __pyx_L0;
11782 
11783   /* "dipy/align/sumsqdiff.pyx":486
11784  * @cython.boundscheck(False)
11785  * @cython.wraparound(False)
11786  * cpdef double compute_energy_ssd_3d(floating[:, :, :] delta_field):             # <<<<<<<<<<<<<<
11787  *     r"""Sum of squared differences between two 3D volumes
11788  *
11789  */
11790 
11791   /* function exit code */
11792   __pyx_L0:;
11793   __Pyx_RefNannyFinishContext();
11794   return __pyx_r;
11795 }
11796 
11797 /* Python wrapper */
11798 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_39__pyx_fuse_0compute_energy_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field); /*proto*/
11799 static PyMethodDef __pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_39__pyx_fuse_0compute_energy_ssd_3d = {"__pyx_fuse_0compute_energy_ssd_3d", (PyCFunction)__pyx_pw_4dipy_5align_9sumsqdiff_39__pyx_fuse_0compute_energy_ssd_3d, METH_O, __pyx_doc_4dipy_5align_9sumsqdiff_10compute_energy_ssd_3d};
__pyx_pw_4dipy_5align_9sumsqdiff_39__pyx_fuse_0compute_energy_ssd_3d(PyObject * __pyx_self,PyObject * __pyx_arg_delta_field)11800 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_39__pyx_fuse_0compute_energy_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field) {
11801   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
11802   int __pyx_lineno = 0;
11803   const char *__pyx_filename = NULL;
11804   int __pyx_clineno = 0;
11805   PyObject *__pyx_r = 0;
11806   __Pyx_RefNannyDeclarations
11807   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_energy_ssd_3d (wrapper)", 0);
11808   assert(__pyx_arg_delta_field); {
11809     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(__pyx_arg_delta_field, PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 486, __pyx_L3_error)
11810   }
11811   goto __pyx_L4_argument_unpacking_done;
11812   __pyx_L3_error:;
11813   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_0compute_energy_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
11814   __Pyx_RefNannyFinishContext();
11815   return NULL;
11816   __pyx_L4_argument_unpacking_done:;
11817   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_38__pyx_fuse_0compute_energy_ssd_3d(__pyx_self, __pyx_v_delta_field);
11818 
11819   /* function exit code */
11820   __Pyx_RefNannyFinishContext();
11821   return __pyx_r;
11822 }
11823 
__pyx_pf_4dipy_5align_9sumsqdiff_38__pyx_fuse_0compute_energy_ssd_3d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field)11824 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_38__pyx_fuse_0compute_energy_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field) {
11825   PyObject *__pyx_r = NULL;
11826   __Pyx_RefNannyDeclarations
11827   PyObject *__pyx_t_1 = NULL;
11828   int __pyx_lineno = 0;
11829   const char *__pyx_filename = NULL;
11830   int __pyx_clineno = 0;
11831   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_energy_ssd_3d", 0);
11832   __Pyx_XDECREF(__pyx_r);
11833   if (unlikely(!__pyx_v_delta_field.memview)) { __Pyx_RaiseUnboundLocalError("delta_field"); __PYX_ERR(0, 486, __pyx_L1_error) }
11834   __pyx_t_1 = PyFloat_FromDouble(__pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_3d(__pyx_v_delta_field, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
11835   __Pyx_GOTREF(__pyx_t_1);
11836   __pyx_r = __pyx_t_1;
11837   __pyx_t_1 = 0;
11838   goto __pyx_L0;
11839 
11840   /* function exit code */
11841   __pyx_L1_error:;
11842   __Pyx_XDECREF(__pyx_t_1);
11843   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_0compute_energy_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
11844   __pyx_r = NULL;
11845   __pyx_L0:;
11846   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
11847   __Pyx_XGIVEREF(__pyx_r);
11848   __Pyx_RefNannyFinishContext();
11849   return __pyx_r;
11850 }
11851 
11852 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_41__pyx_fuse_1compute_energy_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field); /*proto*/
11853 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_11compute_energy_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_3d(__Pyx_memviewslice __pyx_v_delta_field,CYTHON_UNUSED int __pyx_skip_dispatch)11854 static double __pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_3d(__Pyx_memviewslice __pyx_v_delta_field, CYTHON_UNUSED int __pyx_skip_dispatch) {
11855   npy_intp __pyx_v_nslices;
11856   npy_intp __pyx_v_nrows;
11857   npy_intp __pyx_v_ncols;
11858   npy_intp __pyx_v_s;
11859   npy_intp __pyx_v_r;
11860   npy_intp __pyx_v_c;
11861   double __pyx_v_energy;
11862   double __pyx_r;
11863   __Pyx_RefNannyDeclarations
11864   npy_intp __pyx_t_1;
11865   npy_intp __pyx_t_2;
11866   npy_intp __pyx_t_3;
11867   npy_intp __pyx_t_4;
11868   npy_intp __pyx_t_5;
11869   npy_intp __pyx_t_6;
11870   npy_intp __pyx_t_7;
11871   npy_intp __pyx_t_8;
11872   npy_intp __pyx_t_9;
11873   Py_ssize_t __pyx_t_10;
11874   Py_ssize_t __pyx_t_11;
11875   Py_ssize_t __pyx_t_12;
11876   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_energy_ssd_3d", 0);
11877 
11878   /* "dipy/align/sumsqdiff.pyx":519
11879  *     """
11880  *     cdef:
11881  *         cnp.npy_intp nslices = delta_field.shape[0]             # <<<<<<<<<<<<<<
11882  *         cnp.npy_intp nrows = delta_field.shape[1]
11883  *         cnp.npy_intp ncols = delta_field.shape[2]
11884  */
11885   __pyx_v_nslices = (__pyx_v_delta_field.shape[0]);
11886 
11887   /* "dipy/align/sumsqdiff.pyx":520
11888  *     cdef:
11889  *         cnp.npy_intp nslices = delta_field.shape[0]
11890  *         cnp.npy_intp nrows = delta_field.shape[1]             # <<<<<<<<<<<<<<
11891  *         cnp.npy_intp ncols = delta_field.shape[2]
11892  *         cnp.npy_intp s, r, c
11893  */
11894   __pyx_v_nrows = (__pyx_v_delta_field.shape[1]);
11895 
11896   /* "dipy/align/sumsqdiff.pyx":521
11897  *         cnp.npy_intp nslices = delta_field.shape[0]
11898  *         cnp.npy_intp nrows = delta_field.shape[1]
11899  *         cnp.npy_intp ncols = delta_field.shape[2]             # <<<<<<<<<<<<<<
11900  *         cnp.npy_intp s, r, c
11901  *         double energy = 0
11902  */
11903   __pyx_v_ncols = (__pyx_v_delta_field.shape[2]);
11904 
11905   /* "dipy/align/sumsqdiff.pyx":523
11906  *         cnp.npy_intp ncols = delta_field.shape[2]
11907  *         cnp.npy_intp s, r, c
11908  *         double energy = 0             # <<<<<<<<<<<<<<
11909  *     with nogil:
11910  *         for s in range(nslices):
11911  */
11912   __pyx_v_energy = 0.0;
11913 
11914   /* "dipy/align/sumsqdiff.pyx":524
11915  *         cnp.npy_intp s, r, c
11916  *         double energy = 0
11917  *     with nogil:             # <<<<<<<<<<<<<<
11918  *         for s in range(nslices):
11919  *             for r in range(nrows):
11920  */
11921   {
11922       #ifdef WITH_THREAD
11923       PyThreadState *_save;
11924       Py_UNBLOCK_THREADS
11925       __Pyx_FastGIL_Remember();
11926       #endif
11927       /*try:*/ {
11928 
11929         /* "dipy/align/sumsqdiff.pyx":525
11930  *         double energy = 0
11931  *     with nogil:
11932  *         for s in range(nslices):             # <<<<<<<<<<<<<<
11933  *             for r in range(nrows):
11934  *                 for c in range(ncols):
11935  */
11936         __pyx_t_1 = __pyx_v_nslices;
11937         __pyx_t_2 = __pyx_t_1;
11938         for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
11939           __pyx_v_s = __pyx_t_3;
11940 
11941           /* "dipy/align/sumsqdiff.pyx":526
11942  *     with nogil:
11943  *         for s in range(nslices):
11944  *             for r in range(nrows):             # <<<<<<<<<<<<<<
11945  *                 for c in range(ncols):
11946  *                     energy += delta_field[s, r, c] ** 2
11947  */
11948           __pyx_t_4 = __pyx_v_nrows;
11949           __pyx_t_5 = __pyx_t_4;
11950           for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
11951             __pyx_v_r = __pyx_t_6;
11952 
11953             /* "dipy/align/sumsqdiff.pyx":527
11954  *         for s in range(nslices):
11955  *             for r in range(nrows):
11956  *                 for c in range(ncols):             # <<<<<<<<<<<<<<
11957  *                     energy += delta_field[s, r, c] ** 2
11958  *     return energy
11959  */
11960             __pyx_t_7 = __pyx_v_ncols;
11961             __pyx_t_8 = __pyx_t_7;
11962             for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
11963               __pyx_v_c = __pyx_t_9;
11964 
11965               /* "dipy/align/sumsqdiff.pyx":528
11966  *             for r in range(nrows):
11967  *                 for c in range(ncols):
11968  *                     energy += delta_field[s, r, c] ** 2             # <<<<<<<<<<<<<<
11969  *     return energy
11970  *
11971  */
11972               __pyx_t_10 = __pyx_v_s;
11973               __pyx_t_11 = __pyx_v_r;
11974               __pyx_t_12 = __pyx_v_c;
11975               __pyx_v_energy = (__pyx_v_energy + pow((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_10 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_11 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_12 * __pyx_v_delta_field.strides[2]) ))), 2.0));
11976             }
11977           }
11978         }
11979       }
11980 
11981       /* "dipy/align/sumsqdiff.pyx":524
11982  *         cnp.npy_intp s, r, c
11983  *         double energy = 0
11984  *     with nogil:             # <<<<<<<<<<<<<<
11985  *         for s in range(nslices):
11986  *             for r in range(nrows):
11987  */
11988       /*finally:*/ {
11989         /*normal exit:*/{
11990           #ifdef WITH_THREAD
11991           __Pyx_FastGIL_Forget();
11992           Py_BLOCK_THREADS
11993           #endif
11994           goto __pyx_L5;
11995         }
11996         __pyx_L5:;
11997       }
11998   }
11999 
12000   /* "dipy/align/sumsqdiff.pyx":529
12001  *                 for c in range(ncols):
12002  *                     energy += delta_field[s, r, c] ** 2
12003  *     return energy             # <<<<<<<<<<<<<<
12004  *
12005  *
12006  */
12007   __pyx_r = __pyx_v_energy;
12008   goto __pyx_L0;
12009 
12010   /* "dipy/align/sumsqdiff.pyx":486
12011  * @cython.boundscheck(False)
12012  * @cython.wraparound(False)
12013  * cpdef double compute_energy_ssd_3d(floating[:, :, :] delta_field):             # <<<<<<<<<<<<<<
12014  *     r"""Sum of squared differences between two 3D volumes
12015  *
12016  */
12017 
12018   /* function exit code */
12019   __pyx_L0:;
12020   __Pyx_RefNannyFinishContext();
12021   return __pyx_r;
12022 }
12023 
12024 /* Python wrapper */
12025 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_41__pyx_fuse_1compute_energy_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field); /*proto*/
12026 static PyMethodDef __pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_41__pyx_fuse_1compute_energy_ssd_3d = {"__pyx_fuse_1compute_energy_ssd_3d", (PyCFunction)__pyx_pw_4dipy_5align_9sumsqdiff_41__pyx_fuse_1compute_energy_ssd_3d, METH_O, __pyx_doc_4dipy_5align_9sumsqdiff_10compute_energy_ssd_3d};
__pyx_pw_4dipy_5align_9sumsqdiff_41__pyx_fuse_1compute_energy_ssd_3d(PyObject * __pyx_self,PyObject * __pyx_arg_delta_field)12027 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_41__pyx_fuse_1compute_energy_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_arg_delta_field) {
12028   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
12029   int __pyx_lineno = 0;
12030   const char *__pyx_filename = NULL;
12031   int __pyx_clineno = 0;
12032   PyObject *__pyx_r = 0;
12033   __Pyx_RefNannyDeclarations
12034   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_energy_ssd_3d (wrapper)", 0);
12035   assert(__pyx_arg_delta_field); {
12036     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(__pyx_arg_delta_field, PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 486, __pyx_L3_error)
12037   }
12038   goto __pyx_L4_argument_unpacking_done;
12039   __pyx_L3_error:;
12040   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_1compute_energy_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
12041   __Pyx_RefNannyFinishContext();
12042   return NULL;
12043   __pyx_L4_argument_unpacking_done:;
12044   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_40__pyx_fuse_1compute_energy_ssd_3d(__pyx_self, __pyx_v_delta_field);
12045 
12046   /* function exit code */
12047   __Pyx_RefNannyFinishContext();
12048   return __pyx_r;
12049 }
12050 
__pyx_pf_4dipy_5align_9sumsqdiff_40__pyx_fuse_1compute_energy_ssd_3d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field)12051 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_40__pyx_fuse_1compute_energy_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field) {
12052   PyObject *__pyx_r = NULL;
12053   __Pyx_RefNannyDeclarations
12054   PyObject *__pyx_t_1 = NULL;
12055   int __pyx_lineno = 0;
12056   const char *__pyx_filename = NULL;
12057   int __pyx_clineno = 0;
12058   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_energy_ssd_3d", 0);
12059   __Pyx_XDECREF(__pyx_r);
12060   if (unlikely(!__pyx_v_delta_field.memview)) { __Pyx_RaiseUnboundLocalError("delta_field"); __PYX_ERR(0, 486, __pyx_L1_error) }
12061   __pyx_t_1 = PyFloat_FromDouble(__pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_energy_ssd_3d(__pyx_v_delta_field, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
12062   __Pyx_GOTREF(__pyx_t_1);
12063   __pyx_r = __pyx_t_1;
12064   __pyx_t_1 = 0;
12065   goto __pyx_L0;
12066 
12067   /* function exit code */
12068   __pyx_L1_error:;
12069   __Pyx_XDECREF(__pyx_t_1);
12070   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_1compute_energy_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
12071   __pyx_r = NULL;
12072   __pyx_L0:;
12073   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
12074   __Pyx_XGIVEREF(__pyx_r);
12075   __Pyx_RefNannyFinishContext();
12076   return __pyx_r;
12077 }
12078 
12079 /* "dipy/align/sumsqdiff.pyx":534
12080  * @cython.boundscheck(False)
12081  * @cython.wraparound(False)
12082  * def compute_residual_displacement_field_ssd_3d(             # <<<<<<<<<<<<<<
12083  *         floating[:, :, :] delta_field, floating[:, :, :] sigmasq_field,
12084  *         floating[:, :, :, :] gradient_field, floating[:, :, :, :] target,
12085  */
12086 
12087 /* Python wrapper */
12088 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_13compute_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
12089 static char __pyx_doc_4dipy_5align_9sumsqdiff_12compute_residual_displacement_field_ssd_3d[] = "The residual displacement field to be fit on the next iteration\n\n    Computes the residual displacement field corresponding to the current\n    displacement field (given by 'disp') in the Multi-resolution\n    Gauss-Seidel solver proposed by Bruhn and Weickert [Bruhn].\n\n    Parameters\n    ----------\n    delta_field : array, shape (S, R, C)\n        the difference between the static and moving image (the 'derivative\n        w.r.t. time' in the optical flow model)\n    sigmasq_field : array, shape (S, R, C)\n        the variance of the gray level value at each voxel, according to the\n        EM model (for SSD, it is 1 for all voxels). Inf and 0 values\n        are processed specially to support infinite and zero variance.\n    gradient_field : array, shape (S, R, C, 3)\n        the gradient of the moving image\n    target : array, shape (S, R, C, 3)\n        right-hand side of the linear system to be solved in the Weickert's\n        multi-resolution algorithm\n    lambda_param : float\n        smoothness parameter in the objective function\n    disp : array, shape (S, R, C, 3)\n        the current displacement field to compute the residual from\n    residual : array, shape (S, R, C, 3)\n        the displacement field to put the residual to\n\n    Returns\n    -------\n    residual : array, shape (S, R, C, 3)\n        the residual displacement field. If residual was None a input, then\n        a new field is returned, otherwise the same array is returned\n\n    References\n    ----------\n    [Bruhn05] Andres Bruhn and Joachim Weickert, \"Towards ultimate motion\n              estimation: combining highest accuracy with real-time\n              performance\", 10th IEEE International Conference on Computer\n              Vision, 2005. ICCV 2005.\n    ";
12090 static PyMethodDef __pyx_mdef_4dipy_5align_9sumsqdiff_13compute_residual_displacement_field_ssd_3d = {"compute_residual_displacement_field_ssd_3d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_13compute_residual_displacement_field_ssd_3d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_12compute_residual_displacement_field_ssd_3d};
__pyx_pw_4dipy_5align_9sumsqdiff_13compute_residual_displacement_field_ssd_3d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)12091 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_13compute_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
12092   PyObject *__pyx_v_signatures = 0;
12093   PyObject *__pyx_v_args = 0;
12094   PyObject *__pyx_v_kwargs = 0;
12095   CYTHON_UNUSED PyObject *__pyx_v_defaults = 0;
12096   int __pyx_lineno = 0;
12097   const char *__pyx_filename = NULL;
12098   int __pyx_clineno = 0;
12099   PyObject *__pyx_r = 0;
12100   __Pyx_RefNannyDeclarations
12101   __Pyx_RefNannySetupContext("__pyx_fused_cpdef (wrapper)", 0);
12102   {
12103     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signatures,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_defaults,0};
12104     PyObject* values[4] = {0,0,0,0};
12105     if (unlikely(__pyx_kwds)) {
12106       Py_ssize_t kw_args;
12107       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
12108       switch (pos_args) {
12109         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
12110         CYTHON_FALLTHROUGH;
12111         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
12112         CYTHON_FALLTHROUGH;
12113         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
12114         CYTHON_FALLTHROUGH;
12115         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12116         CYTHON_FALLTHROUGH;
12117         case  0: break;
12118         default: goto __pyx_L5_argtuple_error;
12119       }
12120       kw_args = PyDict_Size(__pyx_kwds);
12121       switch (pos_args) {
12122         case  0:
12123         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signatures)) != 0)) kw_args--;
12124         else goto __pyx_L5_argtuple_error;
12125         CYTHON_FALLTHROUGH;
12126         case  1:
12127         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
12128         else {
12129           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 1); __PYX_ERR(0, 534, __pyx_L3_error)
12130         }
12131         CYTHON_FALLTHROUGH;
12132         case  2:
12133         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
12134         else {
12135           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); __PYX_ERR(0, 534, __pyx_L3_error)
12136         }
12137         CYTHON_FALLTHROUGH;
12138         case  3:
12139         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--;
12140         else {
12141           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); __PYX_ERR(0, 534, __pyx_L3_error)
12142         }
12143       }
12144       if (unlikely(kw_args > 0)) {
12145         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) __PYX_ERR(0, 534, __pyx_L3_error)
12146       }
12147     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
12148       goto __pyx_L5_argtuple_error;
12149     } else {
12150       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12151       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
12152       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
12153       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
12154     }
12155     __pyx_v_signatures = values[0];
12156     __pyx_v_args = values[1];
12157     __pyx_v_kwargs = values[2];
12158     __pyx_v_defaults = values[3];
12159   }
12160   goto __pyx_L4_argument_unpacking_done;
12161   __pyx_L5_argtuple_error:;
12162   __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 534, __pyx_L3_error)
12163   __pyx_L3_error:;
12164   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
12165   __Pyx_RefNannyFinishContext();
12166   return NULL;
12167   __pyx_L4_argument_unpacking_done:;
12168   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_12compute_residual_displacement_field_ssd_3d(__pyx_self, __pyx_v_signatures, __pyx_v_args, __pyx_v_kwargs, __pyx_v_defaults);
12169 
12170   /* function exit code */
12171   __Pyx_RefNannyFinishContext();
12172   return __pyx_r;
12173 }
12174 
__pyx_pf_4dipy_5align_9sumsqdiff_12compute_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_signatures,PyObject * __pyx_v_args,PyObject * __pyx_v_kwargs,CYTHON_UNUSED PyObject * __pyx_v_defaults)12175 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_12compute_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults) {
12176   PyObject *__pyx_v_dest_sig = NULL;
12177   Py_ssize_t __pyx_v_i;
12178   PyTypeObject *__pyx_v_ndarray = 0;
12179   __Pyx_memviewslice __pyx_v_memslice;
12180   Py_ssize_t __pyx_v_itemsize;
12181   CYTHON_UNUSED int __pyx_v_dtype_signed;
12182   char __pyx_v_kind;
12183   PyObject *__pyx_v_arg = NULL;
12184   PyObject *__pyx_v_dtype = NULL;
12185   PyObject *__pyx_v_arg_base = NULL;
12186   PyObject *__pyx_v_candidates = NULL;
12187   PyObject *__pyx_v_sig = NULL;
12188   int __pyx_v_match_found;
12189   PyObject *__pyx_v_src_sig = NULL;
12190   PyObject *__pyx_v_dst_type = NULL;
12191   PyObject *__pyx_r = NULL;
12192   __Pyx_RefNannyDeclarations
12193   PyObject *__pyx_t_1 = NULL;
12194   int __pyx_t_2;
12195   int __pyx_t_3;
12196   int __pyx_t_4;
12197   Py_ssize_t __pyx_t_5;
12198   PyObject *__pyx_t_6 = NULL;
12199   long __pyx_t_7;
12200   __Pyx_memviewslice __pyx_t_8;
12201   Py_ssize_t __pyx_t_9;
12202   int __pyx_t_10;
12203   int __pyx_t_11;
12204   PyObject *__pyx_t_12 = NULL;
12205   PyObject *__pyx_t_13 = NULL;
12206   PyObject *__pyx_t_14 = NULL;
12207   Py_ssize_t __pyx_t_15;
12208   Py_ssize_t __pyx_t_16;
12209   Py_ssize_t __pyx_t_17;
12210   int __pyx_t_18;
12211   int __pyx_lineno = 0;
12212   const char *__pyx_filename = NULL;
12213   int __pyx_clineno = 0;
12214   __Pyx_RefNannySetupContext("compute_residual_displacement_field_ssd_3d", 0);
12215   __Pyx_INCREF(__pyx_v_kwargs);
12216   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
12217   __Pyx_GOTREF(__pyx_t_1);
12218   __Pyx_INCREF(Py_None);
12219   __Pyx_GIVEREF(Py_None);
12220   PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
12221   __pyx_v_dest_sig = ((PyObject*)__pyx_t_1);
12222   __pyx_t_1 = 0;
12223   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
12224   __pyx_t_4 = (__pyx_t_3 != 0);
12225   if (__pyx_t_4) {
12226   } else {
12227     __pyx_t_2 = __pyx_t_4;
12228     goto __pyx_L4_bool_binop_done;
12229   }
12230   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
12231   __pyx_t_3 = ((!__pyx_t_4) != 0);
12232   __pyx_t_2 = __pyx_t_3;
12233   __pyx_L4_bool_binop_done:;
12234   if (__pyx_t_2) {
12235     __Pyx_INCREF(Py_None);
12236     __Pyx_DECREF_SET(__pyx_v_kwargs, Py_None);
12237   }
12238   __pyx_t_1 = ((PyObject *)__Pyx_ImportNumPyArrayTypeIfAvailable()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
12239   __Pyx_GOTREF(__pyx_t_1);
12240   __pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1);
12241   __pyx_t_1 = 0;
12242   __pyx_v_itemsize = -1L;
12243   if (unlikely(__pyx_v_args == Py_None)) {
12244     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
12245     __PYX_ERR(0, 534, __pyx_L1_error)
12246   }
12247   __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 534, __pyx_L1_error)
12248   __pyx_t_2 = ((0 < __pyx_t_5) != 0);
12249   if (__pyx_t_2) {
12250     if (unlikely(__pyx_v_args == Py_None)) {
12251       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
12252       __PYX_ERR(0, 534, __pyx_L1_error)
12253     }
12254     __pyx_t_1 = PyTuple_GET_ITEM(((PyObject*)__pyx_v_args), 0);
12255     __Pyx_INCREF(__pyx_t_1);
12256     __pyx_v_arg = __pyx_t_1;
12257     __pyx_t_1 = 0;
12258     goto __pyx_L6;
12259   }
12260   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
12261   __pyx_t_4 = (__pyx_t_3 != 0);
12262   if (__pyx_t_4) {
12263   } else {
12264     __pyx_t_2 = __pyx_t_4;
12265     goto __pyx_L7_bool_binop_done;
12266   }
12267   if (unlikely(__pyx_v_kwargs == Py_None)) {
12268     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
12269     __PYX_ERR(0, 534, __pyx_L1_error)
12270   }
12271   __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_delta_field, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
12272   __pyx_t_3 = (__pyx_t_4 != 0);
12273   __pyx_t_2 = __pyx_t_3;
12274   __pyx_L7_bool_binop_done:;
12275   if (__pyx_t_2) {
12276     if (unlikely(__pyx_v_kwargs == Py_None)) {
12277       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
12278       __PYX_ERR(0, 534, __pyx_L1_error)
12279     }
12280     __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_delta_field); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
12281     __Pyx_GOTREF(__pyx_t_1);
12282     __pyx_v_arg = __pyx_t_1;
12283     __pyx_t_1 = 0;
12284     goto __pyx_L6;
12285   }
12286   /*else*/ {
12287     if (unlikely(__pyx_v_args == Py_None)) {
12288       PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
12289       __PYX_ERR(0, 534, __pyx_L1_error)
12290     }
12291     __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 534, __pyx_L1_error)
12292     __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
12293     __Pyx_GOTREF(__pyx_t_1);
12294     __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12295     __Pyx_GOTREF(__pyx_t_6);
12296     __Pyx_INCREF(__pyx_int_7);
12297     __Pyx_GIVEREF(__pyx_int_7);
12298     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_7);
12299     __Pyx_INCREF(__pyx_n_s_s);
12300     __Pyx_GIVEREF(__pyx_n_s_s);
12301     PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_s);
12302     __Pyx_GIVEREF(__pyx_t_1);
12303     PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
12304     __pyx_t_1 = 0;
12305     __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
12306     __Pyx_GOTREF(__pyx_t_1);
12307     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12308     __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12309     __Pyx_GOTREF(__pyx_t_6);
12310     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12311     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
12312     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12313     __PYX_ERR(0, 534, __pyx_L1_error)
12314   }
12315   __pyx_L6:;
12316   while (1) {
12317     __pyx_t_2 = (__pyx_v_ndarray != ((PyTypeObject*)Py_None));
12318     __pyx_t_3 = (__pyx_t_2 != 0);
12319     if (__pyx_t_3) {
12320       __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray);
12321       __pyx_t_2 = (__pyx_t_3 != 0);
12322       if (__pyx_t_2) {
12323         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12324         __Pyx_GOTREF(__pyx_t_6);
12325         __pyx_v_dtype = __pyx_t_6;
12326         __pyx_t_6 = 0;
12327         goto __pyx_L12;
12328       }
12329       __pyx_t_2 = __pyx_memoryview_check(__pyx_v_arg);
12330       __pyx_t_3 = (__pyx_t_2 != 0);
12331       if (__pyx_t_3) {
12332         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12333         __Pyx_GOTREF(__pyx_t_6);
12334         __pyx_v_arg_base = __pyx_t_6;
12335         __pyx_t_6 = 0;
12336         __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray);
12337         __pyx_t_2 = (__pyx_t_3 != 0);
12338         if (__pyx_t_2) {
12339           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12340           __Pyx_GOTREF(__pyx_t_6);
12341           __pyx_v_dtype = __pyx_t_6;
12342           __pyx_t_6 = 0;
12343           goto __pyx_L13;
12344         }
12345         /*else*/ {
12346           __Pyx_INCREF(Py_None);
12347           __pyx_v_dtype = Py_None;
12348         }
12349         __pyx_L13:;
12350         goto __pyx_L12;
12351       }
12352       /*else*/ {
12353         __Pyx_INCREF(Py_None);
12354         __pyx_v_dtype = Py_None;
12355       }
12356       __pyx_L12:;
12357       __pyx_v_itemsize = -1L;
12358       __pyx_t_2 = (__pyx_v_dtype != Py_None);
12359       __pyx_t_3 = (__pyx_t_2 != 0);
12360       if (__pyx_t_3) {
12361         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12362         __Pyx_GOTREF(__pyx_t_6);
12363         __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 534, __pyx_L1_error)
12364         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12365         __pyx_v_itemsize = __pyx_t_5;
12366         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12367         __Pyx_GOTREF(__pyx_t_6);
12368         __pyx_t_7 = __Pyx_PyObject_Ord(__pyx_t_6); if (unlikely(__pyx_t_7 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 534, __pyx_L1_error)
12369         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12370         __pyx_v_kind = __pyx_t_7;
12371         __pyx_v_dtype_signed = (__pyx_v_kind == 'i');
12372         switch (__pyx_v_kind) {
12373           case 'i':
12374           case 'u':
12375           break;
12376           case 'f':
12377           __pyx_t_2 = (((sizeof(float)) == __pyx_v_itemsize) != 0);
12378           if (__pyx_t_2) {
12379           } else {
12380             __pyx_t_3 = __pyx_t_2;
12381             goto __pyx_L16_bool_binop_done;
12382           }
12383           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12384           __Pyx_GOTREF(__pyx_t_6);
12385           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 534, __pyx_L1_error)
12386           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12387           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0);
12388           __pyx_t_3 = __pyx_t_2;
12389           __pyx_L16_bool_binop_done:;
12390           if (__pyx_t_3) {
12391             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
12392             goto __pyx_L10_break;
12393           }
12394           __pyx_t_2 = (((sizeof(double)) == __pyx_v_itemsize) != 0);
12395           if (__pyx_t_2) {
12396           } else {
12397             __pyx_t_3 = __pyx_t_2;
12398             goto __pyx_L19_bool_binop_done;
12399           }
12400           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12401           __Pyx_GOTREF(__pyx_t_6);
12402           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 534, __pyx_L1_error)
12403           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12404           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0);
12405           __pyx_t_3 = __pyx_t_2;
12406           __pyx_L19_bool_binop_done:;
12407           if (__pyx_t_3) {
12408             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
12409             goto __pyx_L10_break;
12410           }
12411           break;
12412           case 'c':
12413           break;
12414           case 'O':
12415           break;
12416           default: break;
12417         }
12418       }
12419     }
12420     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
12421     if (!__pyx_t_2) {
12422     } else {
12423       __pyx_t_3 = __pyx_t_2;
12424       goto __pyx_L22_bool_binop_done;
12425     }
12426     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(float))) != 0);
12427     __pyx_t_3 = __pyx_t_2;
12428     __pyx_L22_bool_binop_done:;
12429     if (__pyx_t_3) {
12430       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(__pyx_v_arg, 0);
12431       __pyx_v_memslice = __pyx_t_8;
12432       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
12433       if (__pyx_t_3) {
12434         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
12435         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
12436         goto __pyx_L10_break;
12437       }
12438       /*else*/ {
12439         PyErr_Clear();
12440       }
12441     }
12442     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
12443     if (!__pyx_t_2) {
12444     } else {
12445       __pyx_t_3 = __pyx_t_2;
12446       goto __pyx_L26_bool_binop_done;
12447     }
12448     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(double))) != 0);
12449     __pyx_t_3 = __pyx_t_2;
12450     __pyx_L26_bool_binop_done:;
12451     if (__pyx_t_3) {
12452       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(__pyx_v_arg, 0);
12453       __pyx_v_memslice = __pyx_t_8;
12454       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
12455       if (__pyx_t_3) {
12456         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
12457         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
12458         goto __pyx_L10_break;
12459       }
12460       /*else*/ {
12461         PyErr_Clear();
12462       }
12463     }
12464     if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
12465     goto __pyx_L10_break;
12466   }
12467   __pyx_L10_break:;
12468   __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12469   __Pyx_GOTREF(__pyx_t_6);
12470   __pyx_v_candidates = ((PyObject*)__pyx_t_6);
12471   __pyx_t_6 = 0;
12472   __pyx_t_5 = 0;
12473   if (unlikely(__pyx_v_signatures == Py_None)) {
12474     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
12475     __PYX_ERR(0, 534, __pyx_L1_error)
12476   }
12477   __pyx_t_1 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
12478   __Pyx_GOTREF(__pyx_t_1);
12479   __Pyx_XDECREF(__pyx_t_6);
12480   __pyx_t_6 = __pyx_t_1;
12481   __pyx_t_1 = 0;
12482   while (1) {
12483     __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_5, &__pyx_t_1, NULL, NULL, __pyx_t_10);
12484     if (unlikely(__pyx_t_11 == 0)) break;
12485     if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 534, __pyx_L1_error)
12486     __Pyx_GOTREF(__pyx_t_1);
12487     __Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_1);
12488     __pyx_t_1 = 0;
12489     __pyx_v_match_found = 0;
12490     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 534, __pyx_L1_error)
12491     __Pyx_GOTREF(__pyx_t_13);
12492     __pyx_t_14 = NULL;
12493     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
12494       __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
12495       if (likely(__pyx_t_14)) {
12496         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
12497         __Pyx_INCREF(__pyx_t_14);
12498         __Pyx_INCREF(function);
12499         __Pyx_DECREF_SET(__pyx_t_13, function);
12500       }
12501     }
12502     __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_kp_s__3) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__3);
12503     __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
12504     if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 534, __pyx_L1_error)
12505     __Pyx_GOTREF(__pyx_t_12);
12506     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
12507     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_split); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 534, __pyx_L1_error)
12508     __Pyx_GOTREF(__pyx_t_13);
12509     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
12510     __pyx_t_12 = NULL;
12511     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
12512       __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
12513       if (likely(__pyx_t_12)) {
12514         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
12515         __Pyx_INCREF(__pyx_t_12);
12516         __Pyx_INCREF(function);
12517         __Pyx_DECREF_SET(__pyx_t_13, function);
12518       }
12519     }
12520     __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_kp_s__4) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__4);
12521     __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
12522     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
12523     __Pyx_GOTREF(__pyx_t_1);
12524     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
12525     __Pyx_XDECREF_SET(__pyx_v_src_sig, __pyx_t_1);
12526     __pyx_t_1 = 0;
12527     __pyx_t_15 = PyList_GET_SIZE(__pyx_v_dest_sig); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 534, __pyx_L1_error)
12528     __pyx_t_16 = __pyx_t_15;
12529     for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
12530       __pyx_v_i = __pyx_t_17;
12531       __pyx_t_1 = PyList_GET_ITEM(__pyx_v_dest_sig, __pyx_v_i);
12532       __Pyx_INCREF(__pyx_t_1);
12533       __Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_1);
12534       __pyx_t_1 = 0;
12535       __pyx_t_3 = (__pyx_v_dst_type != Py_None);
12536       __pyx_t_2 = (__pyx_t_3 != 0);
12537       if (__pyx_t_2) {
12538         __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
12539         __Pyx_GOTREF(__pyx_t_1);
12540         __pyx_t_13 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 534, __pyx_L1_error)
12541         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12542         __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
12543         __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
12544         if (__pyx_t_2) {
12545           __pyx_v_match_found = 1;
12546           goto __pyx_L34;
12547         }
12548         /*else*/ {
12549           __pyx_v_match_found = 0;
12550           goto __pyx_L32_break;
12551         }
12552         __pyx_L34:;
12553       }
12554     }
12555     __pyx_L32_break:;
12556     __pyx_t_2 = (__pyx_v_match_found != 0);
12557     if (__pyx_t_2) {
12558       __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 534, __pyx_L1_error)
12559     }
12560   }
12561   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12562   __pyx_t_2 = (PyList_GET_SIZE(__pyx_v_candidates) != 0);
12563   __pyx_t_3 = ((!__pyx_t_2) != 0);
12564   if (__pyx_t_3) {
12565     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12566     __Pyx_GOTREF(__pyx_t_6);
12567     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
12568     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12569     __PYX_ERR(0, 534, __pyx_L1_error)
12570   }
12571   __pyx_t_9 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 534, __pyx_L1_error)
12572   __pyx_t_3 = ((__pyx_t_9 > 1) != 0);
12573   if (__pyx_t_3) {
12574     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12575     __Pyx_GOTREF(__pyx_t_6);
12576     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
12577     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12578     __PYX_ERR(0, 534, __pyx_L1_error)
12579   }
12580   /*else*/ {
12581     __Pyx_XDECREF(__pyx_r);
12582     if (unlikely(__pyx_v_signatures == Py_None)) {
12583       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
12584       __PYX_ERR(0, 534, __pyx_L1_error)
12585     }
12586     __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), PyList_GET_ITEM(__pyx_v_candidates, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
12587     __Pyx_GOTREF(__pyx_t_6);
12588     __pyx_r = __pyx_t_6;
12589     __pyx_t_6 = 0;
12590     goto __pyx_L0;
12591   }
12592 
12593   /* function exit code */
12594   __pyx_L1_error:;
12595   __Pyx_XDECREF(__pyx_t_1);
12596   __Pyx_XDECREF(__pyx_t_6);
12597   __Pyx_XDECREF(__pyx_t_12);
12598   __Pyx_XDECREF(__pyx_t_13);
12599   __Pyx_XDECREF(__pyx_t_14);
12600   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
12601   __pyx_r = NULL;
12602   __pyx_L0:;
12603   __Pyx_XDECREF(__pyx_v_dest_sig);
12604   __Pyx_XDECREF(__pyx_v_ndarray);
12605   __Pyx_XDECREF(__pyx_v_arg);
12606   __Pyx_XDECREF(__pyx_v_dtype);
12607   __Pyx_XDECREF(__pyx_v_arg_base);
12608   __Pyx_XDECREF(__pyx_v_candidates);
12609   __Pyx_XDECREF(__pyx_v_sig);
12610   __Pyx_XDECREF(__pyx_v_src_sig);
12611   __Pyx_XDECREF(__pyx_v_dst_type);
12612   __Pyx_XDECREF(__pyx_v_kwargs);
12613   __Pyx_XGIVEREF(__pyx_r);
12614   __Pyx_RefNannyFinishContext();
12615   return __pyx_r;
12616 }
12617 
12618 /* Python wrapper */
12619 static PyObject *__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_45compute_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
12620 static PyMethodDef __pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_45compute_residual_displacement_field_ssd_3d = {"__pyx_fuse_0compute_residual_displacement_field_ssd_3d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_45compute_residual_displacement_field_ssd_3d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_12compute_residual_displacement_field_ssd_3d};
__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_45compute_residual_displacement_field_ssd_3d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)12621 static PyObject *__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_45compute_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
12622   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
12623   __Pyx_memviewslice __pyx_v_sigmasq_field = { 0, 0, { 0 }, { 0 }, { 0 } };
12624   __Pyx_memviewslice __pyx_v_gradient_field = { 0, 0, { 0 }, { 0 }, { 0 } };
12625   __Pyx_memviewslice __pyx_v_target = { 0, 0, { 0 }, { 0 }, { 0 } };
12626   double __pyx_v_lambda_param;
12627   __Pyx_memviewslice __pyx_v_disp = { 0, 0, { 0 }, { 0 }, { 0 } };
12628   __Pyx_memviewslice __pyx_v_residual = { 0, 0, { 0 }, { 0 }, { 0 } };
12629   int __pyx_lineno = 0;
12630   const char *__pyx_filename = NULL;
12631   int __pyx_clineno = 0;
12632   PyObject *__pyx_r = 0;
12633   __Pyx_RefNannyDeclarations
12634   __Pyx_RefNannySetupContext("compute_residual_displacement_field_ssd_3d (wrapper)", 0);
12635   {
12636     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_sigmasq_field,&__pyx_n_s_gradient_field,&__pyx_n_s_target,&__pyx_n_s_lambda_param,&__pyx_n_s_disp,&__pyx_n_s_residual,0};
12637     PyObject* values[7] = {0,0,0,0,0,0,0};
12638     if (unlikely(__pyx_kwds)) {
12639       Py_ssize_t kw_args;
12640       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
12641       switch (pos_args) {
12642         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
12643         CYTHON_FALLTHROUGH;
12644         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
12645         CYTHON_FALLTHROUGH;
12646         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
12647         CYTHON_FALLTHROUGH;
12648         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
12649         CYTHON_FALLTHROUGH;
12650         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
12651         CYTHON_FALLTHROUGH;
12652         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
12653         CYTHON_FALLTHROUGH;
12654         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12655         CYTHON_FALLTHROUGH;
12656         case  0: break;
12657         default: goto __pyx_L5_argtuple_error;
12658       }
12659       kw_args = PyDict_Size(__pyx_kwds);
12660       switch (pos_args) {
12661         case  0:
12662         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
12663         else goto __pyx_L5_argtuple_error;
12664         CYTHON_FALLTHROUGH;
12665         case  1:
12666         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigmasq_field)) != 0)) kw_args--;
12667         else {
12668           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 1); __PYX_ERR(0, 534, __pyx_L3_error)
12669         }
12670         CYTHON_FALLTHROUGH;
12671         case  2:
12672         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gradient_field)) != 0)) kw_args--;
12673         else {
12674           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 2); __PYX_ERR(0, 534, __pyx_L3_error)
12675         }
12676         CYTHON_FALLTHROUGH;
12677         case  3:
12678         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--;
12679         else {
12680           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 3); __PYX_ERR(0, 534, __pyx_L3_error)
12681         }
12682         CYTHON_FALLTHROUGH;
12683         case  4:
12684         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lambda_param)) != 0)) kw_args--;
12685         else {
12686           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 4); __PYX_ERR(0, 534, __pyx_L3_error)
12687         }
12688         CYTHON_FALLTHROUGH;
12689         case  5:
12690         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_disp)) != 0)) kw_args--;
12691         else {
12692           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 5); __PYX_ERR(0, 534, __pyx_L3_error)
12693         }
12694         CYTHON_FALLTHROUGH;
12695         case  6:
12696         if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_residual)) != 0)) kw_args--;
12697         else {
12698           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 6); __PYX_ERR(0, 534, __pyx_L3_error)
12699         }
12700       }
12701       if (unlikely(kw_args > 0)) {
12702         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compute_residual_displacement_field_ssd_3d") < 0)) __PYX_ERR(0, 534, __pyx_L3_error)
12703       }
12704     } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
12705       goto __pyx_L5_argtuple_error;
12706     } else {
12707       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12708       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
12709       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
12710       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
12711       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
12712       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
12713       values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
12714     }
12715     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 535, __pyx_L3_error)
12716     __pyx_v_sigmasq_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_sigmasq_field.memview)) __PYX_ERR(0, 535, __pyx_L3_error)
12717     __pyx_v_gradient_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_gradient_field.memview)) __PYX_ERR(0, 536, __pyx_L3_error)
12718     __pyx_v_target = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_target.memview)) __PYX_ERR(0, 536, __pyx_L3_error)
12719     __pyx_v_lambda_param = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_lambda_param == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 537, __pyx_L3_error)
12720     __pyx_v_disp = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_disp.memview)) __PYX_ERR(0, 537, __pyx_L3_error)
12721     __pyx_v_residual = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(values[6], PyBUF_WRITABLE); if (unlikely(!__pyx_v_residual.memview)) __PYX_ERR(0, 538, __pyx_L3_error)
12722   }
12723   goto __pyx_L4_argument_unpacking_done;
12724   __pyx_L5_argtuple_error:;
12725   __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 534, __pyx_L3_error)
12726   __pyx_L3_error:;
12727   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_residual_displacement_field_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
12728   __Pyx_RefNannyFinishContext();
12729   return NULL;
12730   __pyx_L4_argument_unpacking_done:;
12731   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_44compute_residual_displacement_field_ssd_3d(__pyx_self, __pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_gradient_field, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_disp, __pyx_v_residual);
12732 
12733   /* function exit code */
12734   __Pyx_RefNannyFinishContext();
12735   return __pyx_r;
12736 }
12737 
__pyx_pf_4dipy_5align_9sumsqdiff_44compute_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_gradient_field,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_disp,__Pyx_memviewslice __pyx_v_residual)12738 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_44compute_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_gradient_field, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_disp, __Pyx_memviewslice __pyx_v_residual) {
12739   PyObject *__pyx_v_ftype = NULL;
12740   int __pyx_v_NUM_NEIGHBORS;
12741   int *__pyx_v_dSlice;
12742   int *__pyx_v_dRow;
12743   int *__pyx_v_dCol;
12744   double *__pyx_v_b;
12745   double *__pyx_v_y;
12746   npy_intp __pyx_v_nslices;
12747   npy_intp __pyx_v_nrows;
12748   npy_intp __pyx_v_ncols;
12749   double __pyx_v_delta;
12750   double __pyx_v_sigmasq;
12751   double __pyx_v_dotP;
12752   npy_intp __pyx_v_s;
12753   npy_intp __pyx_v_r;
12754   npy_intp __pyx_v_c;
12755   npy_intp __pyx_v_ds;
12756   npy_intp __pyx_v_dr;
12757   npy_intp __pyx_v_dc;
12758   int __pyx_v_k;
12759   PyObject *__pyx_r = NULL;
12760   __Pyx_RefNannyDeclarations
12761   PyObject *__pyx_t_1 = NULL;
12762   PyObject *__pyx_t_2 = NULL;
12763   PyObject *__pyx_t_3 = NULL;
12764   PyObject *__pyx_t_4 = NULL;
12765   int __pyx_t_5[6];
12766   int __pyx_t_6[6];
12767   int __pyx_t_7[6];
12768   double __pyx_t_8[3];
12769   double __pyx_t_9[3];
12770   int __pyx_t_10;
12771   PyObject *__pyx_t_11 = NULL;
12772   PyObject *__pyx_t_12 = NULL;
12773   __Pyx_memviewslice __pyx_t_13 = { 0, 0, { 0 }, { 0 }, { 0 } };
12774   npy_intp __pyx_t_14;
12775   npy_intp __pyx_t_15;
12776   npy_intp __pyx_t_16;
12777   npy_intp __pyx_t_17;
12778   npy_intp __pyx_t_18;
12779   npy_intp __pyx_t_19;
12780   npy_intp __pyx_t_20;
12781   npy_intp __pyx_t_21;
12782   npy_intp __pyx_t_22;
12783   Py_ssize_t __pyx_t_23;
12784   Py_ssize_t __pyx_t_24;
12785   Py_ssize_t __pyx_t_25;
12786   double __pyx_t_26;
12787   Py_ssize_t __pyx_t_27;
12788   int __pyx_t_28;
12789   int __pyx_t_29;
12790   int __pyx_t_30;
12791   int __pyx_t_31;
12792   long __pyx_t_32;
12793   Py_ssize_t __pyx_t_33;
12794   Py_ssize_t __pyx_t_34;
12795   Py_ssize_t __pyx_t_35;
12796   Py_ssize_t __pyx_t_36;
12797   Py_ssize_t __pyx_t_37;
12798   Py_ssize_t __pyx_t_38;
12799   Py_ssize_t __pyx_t_39;
12800   Py_ssize_t __pyx_t_40;
12801   Py_ssize_t __pyx_t_41;
12802   Py_ssize_t __pyx_t_42;
12803   Py_ssize_t __pyx_t_43;
12804   Py_ssize_t __pyx_t_44;
12805   Py_ssize_t __pyx_t_45;
12806   Py_ssize_t __pyx_t_46;
12807   Py_ssize_t __pyx_t_47;
12808   Py_ssize_t __pyx_t_48;
12809   Py_ssize_t __pyx_t_49;
12810   Py_ssize_t __pyx_t_50;
12811   Py_ssize_t __pyx_t_51;
12812   Py_ssize_t __pyx_t_52;
12813   int __pyx_lineno = 0;
12814   const char *__pyx_filename = NULL;
12815   int __pyx_clineno = 0;
12816   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_residual_displacement_field_ssd_3d", 0);
12817 
12818   /* "dipy/align/sumsqdiff.pyx":579
12819  *               Vision, 2005. ICCV 2005.
12820  *     """
12821  *     ftype = np.asarray(delta_field).dtype             # <<<<<<<<<<<<<<
12822  *     cdef:
12823  *         int NUM_NEIGHBORS = 6
12824  */
12825   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 579, __pyx_L1_error)
12826   __Pyx_GOTREF(__pyx_t_2);
12827   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 579, __pyx_L1_error)
12828   __Pyx_GOTREF(__pyx_t_3);
12829   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12830   __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 3, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 579, __pyx_L1_error)
12831   __Pyx_GOTREF(__pyx_t_2);
12832   __pyx_t_4 = NULL;
12833   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
12834     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
12835     if (likely(__pyx_t_4)) {
12836       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
12837       __Pyx_INCREF(__pyx_t_4);
12838       __Pyx_INCREF(function);
12839       __Pyx_DECREF_SET(__pyx_t_3, function);
12840     }
12841   }
12842   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
12843   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
12844   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12845   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 579, __pyx_L1_error)
12846   __Pyx_GOTREF(__pyx_t_1);
12847   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12848   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 579, __pyx_L1_error)
12849   __Pyx_GOTREF(__pyx_t_3);
12850   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12851   __pyx_v_ftype = __pyx_t_3;
12852   __pyx_t_3 = 0;
12853 
12854   /* "dipy/align/sumsqdiff.pyx":581
12855  *     ftype = np.asarray(delta_field).dtype
12856  *     cdef:
12857  *         int NUM_NEIGHBORS = 6             # <<<<<<<<<<<<<<
12858  *         int* dSlice = [-1,  0, 0, 0,  0, 1]
12859  *         int* dRow = [0, -1, 0, 1,  0, 0]
12860  */
12861   __pyx_v_NUM_NEIGHBORS = 6;
12862 
12863   /* "dipy/align/sumsqdiff.pyx":582
12864  *     cdef:
12865  *         int NUM_NEIGHBORS = 6
12866  *         int* dSlice = [-1,  0, 0, 0,  0, 1]             # <<<<<<<<<<<<<<
12867  *         int* dRow = [0, -1, 0, 1,  0, 0]
12868  *         int* dCol = [0,  0, 1, 0, -1, 0]
12869  */
12870   __pyx_t_5[0] = -1;
12871   __pyx_t_5[1] = 0;
12872   __pyx_t_5[2] = 0;
12873   __pyx_t_5[3] = 0;
12874   __pyx_t_5[4] = 0;
12875   __pyx_t_5[5] = 1;
12876   __pyx_v_dSlice = __pyx_t_5;
12877 
12878   /* "dipy/align/sumsqdiff.pyx":583
12879  *         int NUM_NEIGHBORS = 6
12880  *         int* dSlice = [-1,  0, 0, 0,  0, 1]
12881  *         int* dRow = [0, -1, 0, 1,  0, 0]             # <<<<<<<<<<<<<<
12882  *         int* dCol = [0,  0, 1, 0, -1, 0]
12883  *         double* b = [0, 0, 0]
12884  */
12885   __pyx_t_6[0] = 0;
12886   __pyx_t_6[1] = -1;
12887   __pyx_t_6[2] = 0;
12888   __pyx_t_6[3] = 1;
12889   __pyx_t_6[4] = 0;
12890   __pyx_t_6[5] = 0;
12891   __pyx_v_dRow = __pyx_t_6;
12892 
12893   /* "dipy/align/sumsqdiff.pyx":584
12894  *         int* dSlice = [-1,  0, 0, 0,  0, 1]
12895  *         int* dRow = [0, -1, 0, 1,  0, 0]
12896  *         int* dCol = [0,  0, 1, 0, -1, 0]             # <<<<<<<<<<<<<<
12897  *         double* b = [0, 0, 0]
12898  *         double* y = [0, 0, 0]
12899  */
12900   __pyx_t_7[0] = 0;
12901   __pyx_t_7[1] = 0;
12902   __pyx_t_7[2] = 1;
12903   __pyx_t_7[3] = 0;
12904   __pyx_t_7[4] = -1;
12905   __pyx_t_7[5] = 0;
12906   __pyx_v_dCol = __pyx_t_7;
12907 
12908   /* "dipy/align/sumsqdiff.pyx":585
12909  *         int* dRow = [0, -1, 0, 1,  0, 0]
12910  *         int* dCol = [0,  0, 1, 0, -1, 0]
12911  *         double* b = [0, 0, 0]             # <<<<<<<<<<<<<<
12912  *         double* y = [0, 0, 0]
12913  *
12914  */
12915   __pyx_t_8[0] = 0.0;
12916   __pyx_t_8[1] = 0.0;
12917   __pyx_t_8[2] = 0.0;
12918   __pyx_v_b = __pyx_t_8;
12919 
12920   /* "dipy/align/sumsqdiff.pyx":586
12921  *         int* dCol = [0,  0, 1, 0, -1, 0]
12922  *         double* b = [0, 0, 0]
12923  *         double* y = [0, 0, 0]             # <<<<<<<<<<<<<<
12924  *
12925  *         cnp.npy_intp nslices = delta_field.shape[0]
12926  */
12927   __pyx_t_9[0] = 0.0;
12928   __pyx_t_9[1] = 0.0;
12929   __pyx_t_9[2] = 0.0;
12930   __pyx_v_y = __pyx_t_9;
12931 
12932   /* "dipy/align/sumsqdiff.pyx":588
12933  *         double* y = [0, 0, 0]
12934  *
12935  *         cnp.npy_intp nslices = delta_field.shape[0]             # <<<<<<<<<<<<<<
12936  *         cnp.npy_intp nrows = delta_field.shape[1]
12937  *         cnp.npy_intp ncols = delta_field.shape[2]
12938  */
12939   __pyx_v_nslices = (__pyx_v_delta_field.shape[0]);
12940 
12941   /* "dipy/align/sumsqdiff.pyx":589
12942  *
12943  *         cnp.npy_intp nslices = delta_field.shape[0]
12944  *         cnp.npy_intp nrows = delta_field.shape[1]             # <<<<<<<<<<<<<<
12945  *         cnp.npy_intp ncols = delta_field.shape[2]
12946  *         double delta, sigmasq, dotP
12947  */
12948   __pyx_v_nrows = (__pyx_v_delta_field.shape[1]);
12949 
12950   /* "dipy/align/sumsqdiff.pyx":590
12951  *         cnp.npy_intp nslices = delta_field.shape[0]
12952  *         cnp.npy_intp nrows = delta_field.shape[1]
12953  *         cnp.npy_intp ncols = delta_field.shape[2]             # <<<<<<<<<<<<<<
12954  *         double delta, sigmasq, dotP
12955  *         cnp.npy_intp s, r, c, ds, dr, dc
12956  */
12957   __pyx_v_ncols = (__pyx_v_delta_field.shape[2]);
12958 
12959   /* "dipy/align/sumsqdiff.pyx":593
12960  *         double delta, sigmasq, dotP
12961  *         cnp.npy_intp s, r, c, ds, dr, dc
12962  *     if residual is None:             # <<<<<<<<<<<<<<
12963  *         residual = np.empty(shape=(nslices, nrows, ncols, 3), dtype=ftype)
12964  *
12965  */
12966   __pyx_t_10 = ((((PyObject *) __pyx_v_residual.memview) == Py_None) != 0);
12967   if (__pyx_t_10) {
12968 
12969     /* "dipy/align/sumsqdiff.pyx":594
12970  *         cnp.npy_intp s, r, c, ds, dr, dc
12971  *     if residual is None:
12972  *         residual = np.empty(shape=(nslices, nrows, ncols, 3), dtype=ftype)             # <<<<<<<<<<<<<<
12973  *
12974  *     with nogil:
12975  */
12976     __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
12977     __Pyx_GOTREF(__pyx_t_3);
12978     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 594, __pyx_L1_error)
12979     __Pyx_GOTREF(__pyx_t_1);
12980     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12981     __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
12982     __Pyx_GOTREF(__pyx_t_3);
12983     __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nslices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 594, __pyx_L1_error)
12984     __Pyx_GOTREF(__pyx_t_2);
12985     __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nrows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 594, __pyx_L1_error)
12986     __Pyx_GOTREF(__pyx_t_4);
12987     __pyx_t_11 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_ncols); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 594, __pyx_L1_error)
12988     __Pyx_GOTREF(__pyx_t_11);
12989     __pyx_t_12 = PyTuple_New(4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 594, __pyx_L1_error)
12990     __Pyx_GOTREF(__pyx_t_12);
12991     __Pyx_GIVEREF(__pyx_t_2);
12992     PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
12993     __Pyx_GIVEREF(__pyx_t_4);
12994     PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_4);
12995     __Pyx_GIVEREF(__pyx_t_11);
12996     PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_11);
12997     __Pyx_INCREF(__pyx_int_3);
12998     __Pyx_GIVEREF(__pyx_int_3);
12999     PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_int_3);
13000     __pyx_t_2 = 0;
13001     __pyx_t_4 = 0;
13002     __pyx_t_11 = 0;
13003     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_shape, __pyx_t_12) < 0) __PYX_ERR(0, 594, __pyx_L1_error)
13004     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
13005     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_ftype) < 0) __PYX_ERR(0, 594, __pyx_L1_error)
13006     __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 594, __pyx_L1_error)
13007     __Pyx_GOTREF(__pyx_t_12);
13008     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13009     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13010     __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(__pyx_t_12, PyBUF_WRITABLE); if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 594, __pyx_L1_error)
13011     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
13012     __PYX_XDEC_MEMVIEW(&__pyx_v_residual, 1);
13013     __pyx_v_residual = __pyx_t_13;
13014     __pyx_t_13.memview = NULL;
13015     __pyx_t_13.data = NULL;
13016 
13017     /* "dipy/align/sumsqdiff.pyx":593
13018  *         double delta, sigmasq, dotP
13019  *         cnp.npy_intp s, r, c, ds, dr, dc
13020  *     if residual is None:             # <<<<<<<<<<<<<<
13021  *         residual = np.empty(shape=(nslices, nrows, ncols, 3), dtype=ftype)
13022  *
13023  */
13024   }
13025 
13026   /* "dipy/align/sumsqdiff.pyx":596
13027  *         residual = np.empty(shape=(nslices, nrows, ncols, 3), dtype=ftype)
13028  *
13029  *     with nogil:             # <<<<<<<<<<<<<<
13030  *
13031  *         for s in range(nslices):
13032  */
13033   {
13034       #ifdef WITH_THREAD
13035       PyThreadState *_save;
13036       Py_UNBLOCK_THREADS
13037       __Pyx_FastGIL_Remember();
13038       #endif
13039       /*try:*/ {
13040 
13041         /* "dipy/align/sumsqdiff.pyx":598
13042  *     with nogil:
13043  *
13044  *         for s in range(nslices):             # <<<<<<<<<<<<<<
13045  *             for r in range(nrows):
13046  *                 for c in range(ncols):
13047  */
13048         __pyx_t_14 = __pyx_v_nslices;
13049         __pyx_t_15 = __pyx_t_14;
13050         for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
13051           __pyx_v_s = __pyx_t_16;
13052 
13053           /* "dipy/align/sumsqdiff.pyx":599
13054  *
13055  *         for s in range(nslices):
13056  *             for r in range(nrows):             # <<<<<<<<<<<<<<
13057  *                 for c in range(ncols):
13058  *                     delta = delta_field[s, r, c]
13059  */
13060           __pyx_t_17 = __pyx_v_nrows;
13061           __pyx_t_18 = __pyx_t_17;
13062           for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {
13063             __pyx_v_r = __pyx_t_19;
13064 
13065             /* "dipy/align/sumsqdiff.pyx":600
13066  *         for s in range(nslices):
13067  *             for r in range(nrows):
13068  *                 for c in range(ncols):             # <<<<<<<<<<<<<<
13069  *                     delta = delta_field[s, r, c]
13070  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
13071  */
13072             __pyx_t_20 = __pyx_v_ncols;
13073             __pyx_t_21 = __pyx_t_20;
13074             for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
13075               __pyx_v_c = __pyx_t_22;
13076 
13077               /* "dipy/align/sumsqdiff.pyx":601
13078  *             for r in range(nrows):
13079  *                 for c in range(ncols):
13080  *                     delta = delta_field[s, r, c]             # <<<<<<<<<<<<<<
13081  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
13082  *                     if(target is None):
13083  */
13084               __pyx_t_23 = __pyx_v_s;
13085               __pyx_t_24 = __pyx_v_r;
13086               __pyx_t_25 = __pyx_v_c;
13087               __pyx_v_delta = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_23 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_24 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_25 * __pyx_v_delta_field.strides[2]) )));
13088 
13089               /* "dipy/align/sumsqdiff.pyx":602
13090  *                 for c in range(ncols):
13091  *                     delta = delta_field[s, r, c]
13092  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1             # <<<<<<<<<<<<<<
13093  *                     if(target is None):
13094  *                         b[0] = delta * gradient_field[s, r, c, 0]
13095  */
13096               if (((((PyObject *) __pyx_v_sigmasq_field.memview) != Py_None) != 0)) {
13097                 __pyx_t_25 = __pyx_v_s;
13098                 __pyx_t_24 = __pyx_v_r;
13099                 __pyx_t_23 = __pyx_v_c;
13100                 __pyx_t_26 = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_sigmasq_field.data + __pyx_t_25 * __pyx_v_sigmasq_field.strides[0]) ) + __pyx_t_24 * __pyx_v_sigmasq_field.strides[1]) ) + __pyx_t_23 * __pyx_v_sigmasq_field.strides[2]) )));
13101               } else {
13102                 __pyx_t_26 = 1.0;
13103               }
13104               __pyx_v_sigmasq = __pyx_t_26;
13105 
13106               /* "dipy/align/sumsqdiff.pyx":603
13107  *                     delta = delta_field[s, r, c]
13108  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
13109  *                     if(target is None):             # <<<<<<<<<<<<<<
13110  *                         b[0] = delta * gradient_field[s, r, c, 0]
13111  *                         b[1] = delta * gradient_field[s, r, c, 1]
13112  */
13113               __pyx_t_10 = ((((PyObject *) __pyx_v_target.memview) == Py_None) != 0);
13114               if (__pyx_t_10) {
13115 
13116                 /* "dipy/align/sumsqdiff.pyx":604
13117  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
13118  *                     if(target is None):
13119  *                         b[0] = delta * gradient_field[s, r, c, 0]             # <<<<<<<<<<<<<<
13120  *                         b[1] = delta * gradient_field[s, r, c, 1]
13121  *                         b[2] = delta * gradient_field[s, r, c, 2]
13122  */
13123                 __pyx_t_23 = __pyx_v_s;
13124                 __pyx_t_24 = __pyx_v_r;
13125                 __pyx_t_25 = __pyx_v_c;
13126                 __pyx_t_27 = 0;
13127                 (__pyx_v_b[0]) = (__pyx_v_delta * (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_23 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_24 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_25 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_27 * __pyx_v_gradient_field.strides[3]) ))));
13128 
13129                 /* "dipy/align/sumsqdiff.pyx":605
13130  *                     if(target is None):
13131  *                         b[0] = delta * gradient_field[s, r, c, 0]
13132  *                         b[1] = delta * gradient_field[s, r, c, 1]             # <<<<<<<<<<<<<<
13133  *                         b[2] = delta * gradient_field[s, r, c, 2]
13134  *                     else:
13135  */
13136                 __pyx_t_27 = __pyx_v_s;
13137                 __pyx_t_25 = __pyx_v_r;
13138                 __pyx_t_24 = __pyx_v_c;
13139                 __pyx_t_23 = 1;
13140                 (__pyx_v_b[1]) = (__pyx_v_delta * (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_27 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_25 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_24 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_23 * __pyx_v_gradient_field.strides[3]) ))));
13141 
13142                 /* "dipy/align/sumsqdiff.pyx":606
13143  *                         b[0] = delta * gradient_field[s, r, c, 0]
13144  *                         b[1] = delta * gradient_field[s, r, c, 1]
13145  *                         b[2] = delta * gradient_field[s, r, c, 2]             # <<<<<<<<<<<<<<
13146  *                     else:
13147  *                         b[0] = target[s, r, c, 0]
13148  */
13149                 __pyx_t_23 = __pyx_v_s;
13150                 __pyx_t_24 = __pyx_v_r;
13151                 __pyx_t_25 = __pyx_v_c;
13152                 __pyx_t_27 = 2;
13153                 (__pyx_v_b[2]) = (__pyx_v_delta * (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_23 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_24 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_25 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_27 * __pyx_v_gradient_field.strides[3]) ))));
13154 
13155                 /* "dipy/align/sumsqdiff.pyx":603
13156  *                     delta = delta_field[s, r, c]
13157  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
13158  *                     if(target is None):             # <<<<<<<<<<<<<<
13159  *                         b[0] = delta * gradient_field[s, r, c, 0]
13160  *                         b[1] = delta * gradient_field[s, r, c, 1]
13161  */
13162                 goto __pyx_L13;
13163               }
13164 
13165               /* "dipy/align/sumsqdiff.pyx":608
13166  *                         b[2] = delta * gradient_field[s, r, c, 2]
13167  *                     else:
13168  *                         b[0] = target[s, r, c, 0]             # <<<<<<<<<<<<<<
13169  *                         b[1] = target[s, r, c, 1]
13170  *                         b[2] = target[s, r, c, 2]
13171  */
13172               /*else*/ {
13173                 __pyx_t_27 = __pyx_v_s;
13174                 __pyx_t_25 = __pyx_v_r;
13175                 __pyx_t_24 = __pyx_v_c;
13176                 __pyx_t_23 = 0;
13177                 (__pyx_v_b[0]) = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_27 * __pyx_v_target.strides[0]) ) + __pyx_t_25 * __pyx_v_target.strides[1]) ) + __pyx_t_24 * __pyx_v_target.strides[2]) ) + __pyx_t_23 * __pyx_v_target.strides[3]) )));
13178 
13179                 /* "dipy/align/sumsqdiff.pyx":609
13180  *                     else:
13181  *                         b[0] = target[s, r, c, 0]
13182  *                         b[1] = target[s, r, c, 1]             # <<<<<<<<<<<<<<
13183  *                         b[2] = target[s, r, c, 2]
13184  *                     y[0] = 0
13185  */
13186                 __pyx_t_23 = __pyx_v_s;
13187                 __pyx_t_24 = __pyx_v_r;
13188                 __pyx_t_25 = __pyx_v_c;
13189                 __pyx_t_27 = 1;
13190                 (__pyx_v_b[1]) = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_23 * __pyx_v_target.strides[0]) ) + __pyx_t_24 * __pyx_v_target.strides[1]) ) + __pyx_t_25 * __pyx_v_target.strides[2]) ) + __pyx_t_27 * __pyx_v_target.strides[3]) )));
13191 
13192                 /* "dipy/align/sumsqdiff.pyx":610
13193  *                         b[0] = target[s, r, c, 0]
13194  *                         b[1] = target[s, r, c, 1]
13195  *                         b[2] = target[s, r, c, 2]             # <<<<<<<<<<<<<<
13196  *                     y[0] = 0
13197  *                     y[1] = 0
13198  */
13199                 __pyx_t_27 = __pyx_v_s;
13200                 __pyx_t_25 = __pyx_v_r;
13201                 __pyx_t_24 = __pyx_v_c;
13202                 __pyx_t_23 = 2;
13203                 (__pyx_v_b[2]) = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_27 * __pyx_v_target.strides[0]) ) + __pyx_t_25 * __pyx_v_target.strides[1]) ) + __pyx_t_24 * __pyx_v_target.strides[2]) ) + __pyx_t_23 * __pyx_v_target.strides[3]) )));
13204               }
13205               __pyx_L13:;
13206 
13207               /* "dipy/align/sumsqdiff.pyx":611
13208  *                         b[1] = target[s, r, c, 1]
13209  *                         b[2] = target[s, r, c, 2]
13210  *                     y[0] = 0             # <<<<<<<<<<<<<<
13211  *                     y[1] = 0
13212  *                     y[2] = 0
13213  */
13214               (__pyx_v_y[0]) = 0.0;
13215 
13216               /* "dipy/align/sumsqdiff.pyx":612
13217  *                         b[2] = target[s, r, c, 2]
13218  *                     y[0] = 0
13219  *                     y[1] = 0             # <<<<<<<<<<<<<<
13220  *                     y[2] = 0
13221  *                     for k in range(NUM_NEIGHBORS):
13222  */
13223               (__pyx_v_y[1]) = 0.0;
13224 
13225               /* "dipy/align/sumsqdiff.pyx":613
13226  *                     y[0] = 0
13227  *                     y[1] = 0
13228  *                     y[2] = 0             # <<<<<<<<<<<<<<
13229  *                     for k in range(NUM_NEIGHBORS):
13230  *                         ds = s + dSlice[k]
13231  */
13232               (__pyx_v_y[2]) = 0.0;
13233 
13234               /* "dipy/align/sumsqdiff.pyx":614
13235  *                     y[1] = 0
13236  *                     y[2] = 0
13237  *                     for k in range(NUM_NEIGHBORS):             # <<<<<<<<<<<<<<
13238  *                         ds = s + dSlice[k]
13239  *                         if((ds < 0) or (ds >= nslices)):
13240  */
13241               __pyx_t_28 = __pyx_v_NUM_NEIGHBORS;
13242               __pyx_t_29 = __pyx_t_28;
13243               for (__pyx_t_30 = 0; __pyx_t_30 < __pyx_t_29; __pyx_t_30+=1) {
13244                 __pyx_v_k = __pyx_t_30;
13245 
13246                 /* "dipy/align/sumsqdiff.pyx":615
13247  *                     y[2] = 0
13248  *                     for k in range(NUM_NEIGHBORS):
13249  *                         ds = s + dSlice[k]             # <<<<<<<<<<<<<<
13250  *                         if((ds < 0) or (ds >= nslices)):
13251  *                             continue
13252  */
13253                 __pyx_v_ds = (__pyx_v_s + (__pyx_v_dSlice[__pyx_v_k]));
13254 
13255                 /* "dipy/align/sumsqdiff.pyx":616
13256  *                     for k in range(NUM_NEIGHBORS):
13257  *                         ds = s + dSlice[k]
13258  *                         if((ds < 0) or (ds >= nslices)):             # <<<<<<<<<<<<<<
13259  *                             continue
13260  *                         dr = r + dRow[k]
13261  */
13262                 __pyx_t_31 = ((__pyx_v_ds < 0) != 0);
13263                 if (!__pyx_t_31) {
13264                 } else {
13265                   __pyx_t_10 = __pyx_t_31;
13266                   goto __pyx_L17_bool_binop_done;
13267                 }
13268                 __pyx_t_31 = ((__pyx_v_ds >= __pyx_v_nslices) != 0);
13269                 __pyx_t_10 = __pyx_t_31;
13270                 __pyx_L17_bool_binop_done:;
13271                 if (__pyx_t_10) {
13272 
13273                   /* "dipy/align/sumsqdiff.pyx":617
13274  *                         ds = s + dSlice[k]
13275  *                         if((ds < 0) or (ds >= nslices)):
13276  *                             continue             # <<<<<<<<<<<<<<
13277  *                         dr = r + dRow[k]
13278  *                         if((dr < 0) or (dr >= nrows)):
13279  */
13280                   goto __pyx_L14_continue;
13281 
13282                   /* "dipy/align/sumsqdiff.pyx":616
13283  *                     for k in range(NUM_NEIGHBORS):
13284  *                         ds = s + dSlice[k]
13285  *                         if((ds < 0) or (ds >= nslices)):             # <<<<<<<<<<<<<<
13286  *                             continue
13287  *                         dr = r + dRow[k]
13288  */
13289                 }
13290 
13291                 /* "dipy/align/sumsqdiff.pyx":618
13292  *                         if((ds < 0) or (ds >= nslices)):
13293  *                             continue
13294  *                         dr = r + dRow[k]             # <<<<<<<<<<<<<<
13295  *                         if((dr < 0) or (dr >= nrows)):
13296  *                             continue
13297  */
13298                 __pyx_v_dr = (__pyx_v_r + (__pyx_v_dRow[__pyx_v_k]));
13299 
13300                 /* "dipy/align/sumsqdiff.pyx":619
13301  *                             continue
13302  *                         dr = r + dRow[k]
13303  *                         if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
13304  *                             continue
13305  *                         dc = c + dCol[k]
13306  */
13307                 __pyx_t_31 = ((__pyx_v_dr < 0) != 0);
13308                 if (!__pyx_t_31) {
13309                 } else {
13310                   __pyx_t_10 = __pyx_t_31;
13311                   goto __pyx_L20_bool_binop_done;
13312                 }
13313                 __pyx_t_31 = ((__pyx_v_dr >= __pyx_v_nrows) != 0);
13314                 __pyx_t_10 = __pyx_t_31;
13315                 __pyx_L20_bool_binop_done:;
13316                 if (__pyx_t_10) {
13317 
13318                   /* "dipy/align/sumsqdiff.pyx":620
13319  *                         dr = r + dRow[k]
13320  *                         if((dr < 0) or (dr >= nrows)):
13321  *                             continue             # <<<<<<<<<<<<<<
13322  *                         dc = c + dCol[k]
13323  *                         if((dc < 0) or (dc >= ncols)):
13324  */
13325                   goto __pyx_L14_continue;
13326 
13327                   /* "dipy/align/sumsqdiff.pyx":619
13328  *                             continue
13329  *                         dr = r + dRow[k]
13330  *                         if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
13331  *                             continue
13332  *                         dc = c + dCol[k]
13333  */
13334                 }
13335 
13336                 /* "dipy/align/sumsqdiff.pyx":621
13337  *                         if((dr < 0) or (dr >= nrows)):
13338  *                             continue
13339  *                         dc = c + dCol[k]             # <<<<<<<<<<<<<<
13340  *                         if((dc < 0) or (dc >= ncols)):
13341  *                             continue
13342  */
13343                 __pyx_v_dc = (__pyx_v_c + (__pyx_v_dCol[__pyx_v_k]));
13344 
13345                 /* "dipy/align/sumsqdiff.pyx":622
13346  *                             continue
13347  *                         dc = c + dCol[k]
13348  *                         if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
13349  *                             continue
13350  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])
13351  */
13352                 __pyx_t_31 = ((__pyx_v_dc < 0) != 0);
13353                 if (!__pyx_t_31) {
13354                 } else {
13355                   __pyx_t_10 = __pyx_t_31;
13356                   goto __pyx_L23_bool_binop_done;
13357                 }
13358                 __pyx_t_31 = ((__pyx_v_dc >= __pyx_v_ncols) != 0);
13359                 __pyx_t_10 = __pyx_t_31;
13360                 __pyx_L23_bool_binop_done:;
13361                 if (__pyx_t_10) {
13362 
13363                   /* "dipy/align/sumsqdiff.pyx":623
13364  *                         dc = c + dCol[k]
13365  *                         if((dc < 0) or (dc >= ncols)):
13366  *                             continue             # <<<<<<<<<<<<<<
13367  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])
13368  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])
13369  */
13370                   goto __pyx_L14_continue;
13371 
13372                   /* "dipy/align/sumsqdiff.pyx":622
13373  *                             continue
13374  *                         dc = c + dCol[k]
13375  *                         if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
13376  *                             continue
13377  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])
13378  */
13379                 }
13380 
13381                 /* "dipy/align/sumsqdiff.pyx":624
13382  *                         if((dc < 0) or (dc >= ncols)):
13383  *                             continue
13384  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])             # <<<<<<<<<<<<<<
13385  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])
13386  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])
13387  */
13388                 __pyx_t_32 = 0;
13389                 __pyx_t_23 = __pyx_v_s;
13390                 __pyx_t_24 = __pyx_v_r;
13391                 __pyx_t_25 = __pyx_v_c;
13392                 __pyx_t_27 = 0;
13393                 __pyx_t_33 = __pyx_v_ds;
13394                 __pyx_t_34 = __pyx_v_dr;
13395                 __pyx_t_35 = __pyx_v_dc;
13396                 __pyx_t_36 = 0;
13397                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + ((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_27 * __pyx_v_disp.strides[3]) ))) - (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_33 * __pyx_v_disp.strides[0]) ) + __pyx_t_34 * __pyx_v_disp.strides[1]) ) + __pyx_t_35 * __pyx_v_disp.strides[2]) ) + __pyx_t_36 * __pyx_v_disp.strides[3]) )))));
13398 
13399                 /* "dipy/align/sumsqdiff.pyx":625
13400  *                             continue
13401  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])
13402  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])             # <<<<<<<<<<<<<<
13403  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])
13404  *                     if dpy_isinf(sigmasq) != 0:
13405  */
13406                 __pyx_t_32 = 1;
13407                 __pyx_t_36 = __pyx_v_s;
13408                 __pyx_t_35 = __pyx_v_r;
13409                 __pyx_t_34 = __pyx_v_c;
13410                 __pyx_t_33 = 1;
13411                 __pyx_t_27 = __pyx_v_ds;
13412                 __pyx_t_25 = __pyx_v_dr;
13413                 __pyx_t_24 = __pyx_v_dc;
13414                 __pyx_t_23 = 1;
13415                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + ((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_36 * __pyx_v_disp.strides[0]) ) + __pyx_t_35 * __pyx_v_disp.strides[1]) ) + __pyx_t_34 * __pyx_v_disp.strides[2]) ) + __pyx_t_33 * __pyx_v_disp.strides[3]) ))) - (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_27 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )))));
13416 
13417                 /* "dipy/align/sumsqdiff.pyx":626
13418  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])
13419  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])
13420  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])             # <<<<<<<<<<<<<<
13421  *                     if dpy_isinf(sigmasq) != 0:
13422  *                         residual[s, r, c, 0] = -lambda_param * y[0]
13423  */
13424                 __pyx_t_32 = 2;
13425                 __pyx_t_23 = __pyx_v_s;
13426                 __pyx_t_24 = __pyx_v_r;
13427                 __pyx_t_25 = __pyx_v_c;
13428                 __pyx_t_27 = 2;
13429                 __pyx_t_33 = __pyx_v_ds;
13430                 __pyx_t_34 = __pyx_v_dr;
13431                 __pyx_t_35 = __pyx_v_dc;
13432                 __pyx_t_36 = 2;
13433                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + ((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_27 * __pyx_v_disp.strides[3]) ))) - (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_33 * __pyx_v_disp.strides[0]) ) + __pyx_t_34 * __pyx_v_disp.strides[1]) ) + __pyx_t_35 * __pyx_v_disp.strides[2]) ) + __pyx_t_36 * __pyx_v_disp.strides[3]) )))));
13434                 __pyx_L14_continue:;
13435               }
13436 
13437               /* "dipy/align/sumsqdiff.pyx":627
13438  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])
13439  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])
13440  *                     if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
13441  *                         residual[s, r, c, 0] = -lambda_param * y[0]
13442  *                         residual[s, r, c, 1] = -lambda_param * y[1]
13443  */
13444               __pyx_t_10 = ((dpy_isinf(__pyx_v_sigmasq) != 0) != 0);
13445               if (__pyx_t_10) {
13446 
13447                 /* "dipy/align/sumsqdiff.pyx":628
13448  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])
13449  *                     if dpy_isinf(sigmasq) != 0:
13450  *                         residual[s, r, c, 0] = -lambda_param * y[0]             # <<<<<<<<<<<<<<
13451  *                         residual[s, r, c, 1] = -lambda_param * y[1]
13452  *                         residual[s, r, c, 2] = -lambda_param * y[2]
13453  */
13454                 __pyx_t_36 = __pyx_v_s;
13455                 __pyx_t_35 = __pyx_v_r;
13456                 __pyx_t_34 = __pyx_v_c;
13457                 __pyx_t_33 = 0;
13458                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_36 * __pyx_v_residual.strides[0]) ) + __pyx_t_35 * __pyx_v_residual.strides[1]) ) + __pyx_t_34 * __pyx_v_residual.strides[2]) ) + __pyx_t_33 * __pyx_v_residual.strides[3]) )) = ((-__pyx_v_lambda_param) * (__pyx_v_y[0]));
13459 
13460                 /* "dipy/align/sumsqdiff.pyx":629
13461  *                     if dpy_isinf(sigmasq) != 0:
13462  *                         residual[s, r, c, 0] = -lambda_param * y[0]
13463  *                         residual[s, r, c, 1] = -lambda_param * y[1]             # <<<<<<<<<<<<<<
13464  *                         residual[s, r, c, 2] = -lambda_param * y[2]
13465  *                     else:
13466  */
13467                 __pyx_t_33 = __pyx_v_s;
13468                 __pyx_t_34 = __pyx_v_r;
13469                 __pyx_t_35 = __pyx_v_c;
13470                 __pyx_t_36 = 1;
13471                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_33 * __pyx_v_residual.strides[0]) ) + __pyx_t_34 * __pyx_v_residual.strides[1]) ) + __pyx_t_35 * __pyx_v_residual.strides[2]) ) + __pyx_t_36 * __pyx_v_residual.strides[3]) )) = ((-__pyx_v_lambda_param) * (__pyx_v_y[1]));
13472 
13473                 /* "dipy/align/sumsqdiff.pyx":630
13474  *                         residual[s, r, c, 0] = -lambda_param * y[0]
13475  *                         residual[s, r, c, 1] = -lambda_param * y[1]
13476  *                         residual[s, r, c, 2] = -lambda_param * y[2]             # <<<<<<<<<<<<<<
13477  *                     else:
13478  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +
13479  */
13480                 __pyx_t_36 = __pyx_v_s;
13481                 __pyx_t_35 = __pyx_v_r;
13482                 __pyx_t_34 = __pyx_v_c;
13483                 __pyx_t_33 = 2;
13484                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_36 * __pyx_v_residual.strides[0]) ) + __pyx_t_35 * __pyx_v_residual.strides[1]) ) + __pyx_t_34 * __pyx_v_residual.strides[2]) ) + __pyx_t_33 * __pyx_v_residual.strides[3]) )) = ((-__pyx_v_lambda_param) * (__pyx_v_y[2]));
13485 
13486                 /* "dipy/align/sumsqdiff.pyx":627
13487  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])
13488  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])
13489  *                     if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
13490  *                         residual[s, r, c, 0] = -lambda_param * y[0]
13491  *                         residual[s, r, c, 1] = -lambda_param * y[1]
13492  */
13493                 goto __pyx_L25;
13494               }
13495 
13496               /* "dipy/align/sumsqdiff.pyx":632
13497  *                         residual[s, r, c, 2] = -lambda_param * y[2]
13498  *                     else:
13499  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +             # <<<<<<<<<<<<<<
13500  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +
13501  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
13502  */
13503               /*else*/ {
13504 
13505                 /* "dipy/align/sumsqdiff.pyx":633
13506  *                     else:
13507  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +
13508  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +             # <<<<<<<<<<<<<<
13509  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
13510  *                         residual[s, r, c, 0] = (b[0] -
13511  */
13512                 __pyx_t_33 = __pyx_v_s;
13513                 __pyx_t_34 = __pyx_v_r;
13514                 __pyx_t_35 = __pyx_v_c;
13515                 __pyx_t_36 = 0;
13516 
13517                 /* "dipy/align/sumsqdiff.pyx":632
13518  *                         residual[s, r, c, 2] = -lambda_param * y[2]
13519  *                     else:
13520  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +             # <<<<<<<<<<<<<<
13521  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +
13522  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
13523  */
13524                 __pyx_t_27 = __pyx_v_s;
13525                 __pyx_t_25 = __pyx_v_r;
13526                 __pyx_t_24 = __pyx_v_c;
13527                 __pyx_t_23 = 0;
13528 
13529                 /* "dipy/align/sumsqdiff.pyx":633
13530  *                     else:
13531  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +
13532  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +             # <<<<<<<<<<<<<<
13533  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
13534  *                         residual[s, r, c, 0] = (b[0] -
13535  */
13536                 __pyx_t_37 = __pyx_v_s;
13537                 __pyx_t_38 = __pyx_v_r;
13538                 __pyx_t_39 = __pyx_v_c;
13539                 __pyx_t_40 = 1;
13540                 __pyx_t_41 = __pyx_v_s;
13541                 __pyx_t_42 = __pyx_v_r;
13542                 __pyx_t_43 = __pyx_v_c;
13543                 __pyx_t_44 = 1;
13544 
13545                 /* "dipy/align/sumsqdiff.pyx":634
13546  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +
13547  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +
13548  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])             # <<<<<<<<<<<<<<
13549  *                         residual[s, r, c, 0] = (b[0] -
13550  *                                                 (gradient_field[s, r, c, 0] * dotP +
13551  */
13552                 __pyx_t_45 = __pyx_v_s;
13553                 __pyx_t_46 = __pyx_v_r;
13554                 __pyx_t_47 = __pyx_v_c;
13555                 __pyx_t_48 = 2;
13556                 __pyx_t_49 = __pyx_v_s;
13557                 __pyx_t_50 = __pyx_v_r;
13558                 __pyx_t_51 = __pyx_v_c;
13559                 __pyx_t_52 = 2;
13560 
13561                 /* "dipy/align/sumsqdiff.pyx":633
13562  *                     else:
13563  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +
13564  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +             # <<<<<<<<<<<<<<
13565  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
13566  *                         residual[s, r, c, 0] = (b[0] -
13567  */
13568                 __pyx_v_dotP = ((((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_33 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_34 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_35 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_36 * __pyx_v_gradient_field.strides[3]) ))) * (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_27 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )))) + ((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_37 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_38 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_39 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_40 * __pyx_v_gradient_field.strides[3]) ))) * (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_41 * __pyx_v_disp.strides[0]) ) + __pyx_t_42 * __pyx_v_disp.strides[1]) ) + __pyx_t_43 * __pyx_v_disp.strides[2]) ) + __pyx_t_44 * __pyx_v_disp.strides[3]) ))))) + ((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_45 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_46 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_47 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_48 * __pyx_v_gradient_field.strides[3]) ))) * (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_49 * __pyx_v_disp.strides[0]) ) + __pyx_t_50 * __pyx_v_disp.strides[1]) ) + __pyx_t_51 * __pyx_v_disp.strides[2]) ) + __pyx_t_52 * __pyx_v_disp.strides[3]) )))));
13569 
13570                 /* "dipy/align/sumsqdiff.pyx":636
13571  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
13572  *                         residual[s, r, c, 0] = (b[0] -
13573  *                                                 (gradient_field[s, r, c, 0] * dotP +             # <<<<<<<<<<<<<<
13574  *                                                  sigmasq * lambda_param * y[0]))
13575  *                         residual[s, r, c, 1] = (b[1] -
13576  */
13577                 __pyx_t_52 = __pyx_v_s;
13578                 __pyx_t_51 = __pyx_v_r;
13579                 __pyx_t_50 = __pyx_v_c;
13580                 __pyx_t_49 = 0;
13581 
13582                 /* "dipy/align/sumsqdiff.pyx":635
13583  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +
13584  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
13585  *                         residual[s, r, c, 0] = (b[0] -             # <<<<<<<<<<<<<<
13586  *                                                 (gradient_field[s, r, c, 0] * dotP +
13587  *                                                  sigmasq * lambda_param * y[0]))
13588  */
13589                 __pyx_t_48 = __pyx_v_s;
13590                 __pyx_t_47 = __pyx_v_r;
13591                 __pyx_t_46 = __pyx_v_c;
13592                 __pyx_t_45 = 0;
13593                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_48 * __pyx_v_residual.strides[0]) ) + __pyx_t_47 * __pyx_v_residual.strides[1]) ) + __pyx_t_46 * __pyx_v_residual.strides[2]) ) + __pyx_t_45 * __pyx_v_residual.strides[3]) )) = ((__pyx_v_b[0]) - (((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_52 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_51 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_50 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_49 * __pyx_v_gradient_field.strides[3]) ))) * __pyx_v_dotP) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[0]))));
13594 
13595                 /* "dipy/align/sumsqdiff.pyx":639
13596  *                                                  sigmasq * lambda_param * y[0]))
13597  *                         residual[s, r, c, 1] = (b[1] -
13598  *                                                 (gradient_field[s, r, c, 1] * dotP +             # <<<<<<<<<<<<<<
13599  *                                                  sigmasq * lambda_param * y[1]))
13600  *                         residual[s, r, c, 2] = (b[2] -
13601  */
13602                 __pyx_t_49 = __pyx_v_s;
13603                 __pyx_t_50 = __pyx_v_r;
13604                 __pyx_t_51 = __pyx_v_c;
13605                 __pyx_t_52 = 1;
13606 
13607                 /* "dipy/align/sumsqdiff.pyx":638
13608  *                                                 (gradient_field[s, r, c, 0] * dotP +
13609  *                                                  sigmasq * lambda_param * y[0]))
13610  *                         residual[s, r, c, 1] = (b[1] -             # <<<<<<<<<<<<<<
13611  *                                                 (gradient_field[s, r, c, 1] * dotP +
13612  *                                                  sigmasq * lambda_param * y[1]))
13613  */
13614                 __pyx_t_45 = __pyx_v_s;
13615                 __pyx_t_46 = __pyx_v_r;
13616                 __pyx_t_47 = __pyx_v_c;
13617                 __pyx_t_48 = 1;
13618                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_45 * __pyx_v_residual.strides[0]) ) + __pyx_t_46 * __pyx_v_residual.strides[1]) ) + __pyx_t_47 * __pyx_v_residual.strides[2]) ) + __pyx_t_48 * __pyx_v_residual.strides[3]) )) = ((__pyx_v_b[1]) - (((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_49 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_50 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_51 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_52 * __pyx_v_gradient_field.strides[3]) ))) * __pyx_v_dotP) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[1]))));
13619 
13620                 /* "dipy/align/sumsqdiff.pyx":642
13621  *                                                  sigmasq * lambda_param * y[1]))
13622  *                         residual[s, r, c, 2] = (b[2] -
13623  *                                                 (gradient_field[s, r, c, 2] * dotP +             # <<<<<<<<<<<<<<
13624  *                                                  sigmasq * lambda_param * y[2]))
13625  *     return np.asarray(residual)
13626  */
13627                 __pyx_t_52 = __pyx_v_s;
13628                 __pyx_t_51 = __pyx_v_r;
13629                 __pyx_t_50 = __pyx_v_c;
13630                 __pyx_t_49 = 2;
13631 
13632                 /* "dipy/align/sumsqdiff.pyx":641
13633  *                                                 (gradient_field[s, r, c, 1] * dotP +
13634  *                                                  sigmasq * lambda_param * y[1]))
13635  *                         residual[s, r, c, 2] = (b[2] -             # <<<<<<<<<<<<<<
13636  *                                                 (gradient_field[s, r, c, 2] * dotP +
13637  *                                                  sigmasq * lambda_param * y[2]))
13638  */
13639                 __pyx_t_48 = __pyx_v_s;
13640                 __pyx_t_47 = __pyx_v_r;
13641                 __pyx_t_46 = __pyx_v_c;
13642                 __pyx_t_45 = 2;
13643                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_48 * __pyx_v_residual.strides[0]) ) + __pyx_t_47 * __pyx_v_residual.strides[1]) ) + __pyx_t_46 * __pyx_v_residual.strides[2]) ) + __pyx_t_45 * __pyx_v_residual.strides[3]) )) = ((__pyx_v_b[2]) - (((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_52 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_51 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_50 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_49 * __pyx_v_gradient_field.strides[3]) ))) * __pyx_v_dotP) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[2]))));
13644               }
13645               __pyx_L25:;
13646             }
13647           }
13648         }
13649       }
13650 
13651       /* "dipy/align/sumsqdiff.pyx":596
13652  *         residual = np.empty(shape=(nslices, nrows, ncols, 3), dtype=ftype)
13653  *
13654  *     with nogil:             # <<<<<<<<<<<<<<
13655  *
13656  *         for s in range(nslices):
13657  */
13658       /*finally:*/ {
13659         /*normal exit:*/{
13660           #ifdef WITH_THREAD
13661           __Pyx_FastGIL_Forget();
13662           Py_BLOCK_THREADS
13663           #endif
13664           goto __pyx_L6;
13665         }
13666         __pyx_L6:;
13667       }
13668   }
13669 
13670   /* "dipy/align/sumsqdiff.pyx":644
13671  *                                                 (gradient_field[s, r, c, 2] * dotP +
13672  *                                                  sigmasq * lambda_param * y[2]))
13673  *     return np.asarray(residual)             # <<<<<<<<<<<<<<
13674  *
13675  *
13676  */
13677   __Pyx_XDECREF(__pyx_r);
13678   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L1_error)
13679   __Pyx_GOTREF(__pyx_t_3);
13680   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 644, __pyx_L1_error)
13681   __Pyx_GOTREF(__pyx_t_1);
13682   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13683   __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_residual, 4, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L1_error)
13684   __Pyx_GOTREF(__pyx_t_3);
13685   __pyx_t_11 = NULL;
13686   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
13687     __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
13688     if (likely(__pyx_t_11)) {
13689       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
13690       __Pyx_INCREF(__pyx_t_11);
13691       __Pyx_INCREF(function);
13692       __Pyx_DECREF_SET(__pyx_t_1, function);
13693     }
13694   }
13695   __pyx_t_12 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_11, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
13696   __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
13697   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13698   if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 644, __pyx_L1_error)
13699   __Pyx_GOTREF(__pyx_t_12);
13700   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13701   __pyx_r = __pyx_t_12;
13702   __pyx_t_12 = 0;
13703   goto __pyx_L0;
13704 
13705   /* "dipy/align/sumsqdiff.pyx":534
13706  * @cython.boundscheck(False)
13707  * @cython.wraparound(False)
13708  * def compute_residual_displacement_field_ssd_3d(             # <<<<<<<<<<<<<<
13709  *         floating[:, :, :] delta_field, floating[:, :, :] sigmasq_field,
13710  *         floating[:, :, :, :] gradient_field, floating[:, :, :, :] target,
13711  */
13712 
13713   /* function exit code */
13714   __pyx_L1_error:;
13715   __Pyx_XDECREF(__pyx_t_1);
13716   __Pyx_XDECREF(__pyx_t_2);
13717   __Pyx_XDECREF(__pyx_t_3);
13718   __Pyx_XDECREF(__pyx_t_4);
13719   __Pyx_XDECREF(__pyx_t_11);
13720   __Pyx_XDECREF(__pyx_t_12);
13721   __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
13722   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_residual_displacement_field_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
13723   __pyx_r = NULL;
13724   __pyx_L0:;
13725   __Pyx_XDECREF(__pyx_v_ftype);
13726   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
13727   __PYX_XDEC_MEMVIEW(&__pyx_v_sigmasq_field, 1);
13728   __PYX_XDEC_MEMVIEW(&__pyx_v_gradient_field, 1);
13729   __PYX_XDEC_MEMVIEW(&__pyx_v_target, 1);
13730   __PYX_XDEC_MEMVIEW(&__pyx_v_disp, 1);
13731   __PYX_XDEC_MEMVIEW(&__pyx_v_residual, 1);
13732   __Pyx_XGIVEREF(__pyx_r);
13733   __Pyx_RefNannyFinishContext();
13734   return __pyx_r;
13735 }
13736 
13737 /* Python wrapper */
13738 static PyObject *__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_47compute_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
13739 static PyMethodDef __pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_47compute_residual_displacement_field_ssd_3d = {"__pyx_fuse_1compute_residual_displacement_field_ssd_3d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_47compute_residual_displacement_field_ssd_3d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_12compute_residual_displacement_field_ssd_3d};
__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_47compute_residual_displacement_field_ssd_3d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)13740 static PyObject *__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_47compute_residual_displacement_field_ssd_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
13741   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
13742   __Pyx_memviewslice __pyx_v_sigmasq_field = { 0, 0, { 0 }, { 0 }, { 0 } };
13743   __Pyx_memviewslice __pyx_v_gradient_field = { 0, 0, { 0 }, { 0 }, { 0 } };
13744   __Pyx_memviewslice __pyx_v_target = { 0, 0, { 0 }, { 0 }, { 0 } };
13745   double __pyx_v_lambda_param;
13746   __Pyx_memviewslice __pyx_v_disp = { 0, 0, { 0 }, { 0 }, { 0 } };
13747   __Pyx_memviewslice __pyx_v_residual = { 0, 0, { 0 }, { 0 }, { 0 } };
13748   int __pyx_lineno = 0;
13749   const char *__pyx_filename = NULL;
13750   int __pyx_clineno = 0;
13751   PyObject *__pyx_r = 0;
13752   __Pyx_RefNannyDeclarations
13753   __Pyx_RefNannySetupContext("compute_residual_displacement_field_ssd_3d (wrapper)", 0);
13754   {
13755     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_sigmasq_field,&__pyx_n_s_gradient_field,&__pyx_n_s_target,&__pyx_n_s_lambda_param,&__pyx_n_s_disp,&__pyx_n_s_residual,0};
13756     PyObject* values[7] = {0,0,0,0,0,0,0};
13757     if (unlikely(__pyx_kwds)) {
13758       Py_ssize_t kw_args;
13759       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
13760       switch (pos_args) {
13761         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
13762         CYTHON_FALLTHROUGH;
13763         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
13764         CYTHON_FALLTHROUGH;
13765         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
13766         CYTHON_FALLTHROUGH;
13767         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
13768         CYTHON_FALLTHROUGH;
13769         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
13770         CYTHON_FALLTHROUGH;
13771         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
13772         CYTHON_FALLTHROUGH;
13773         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
13774         CYTHON_FALLTHROUGH;
13775         case  0: break;
13776         default: goto __pyx_L5_argtuple_error;
13777       }
13778       kw_args = PyDict_Size(__pyx_kwds);
13779       switch (pos_args) {
13780         case  0:
13781         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
13782         else goto __pyx_L5_argtuple_error;
13783         CYTHON_FALLTHROUGH;
13784         case  1:
13785         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigmasq_field)) != 0)) kw_args--;
13786         else {
13787           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 1); __PYX_ERR(0, 534, __pyx_L3_error)
13788         }
13789         CYTHON_FALLTHROUGH;
13790         case  2:
13791         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gradient_field)) != 0)) kw_args--;
13792         else {
13793           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 2); __PYX_ERR(0, 534, __pyx_L3_error)
13794         }
13795         CYTHON_FALLTHROUGH;
13796         case  3:
13797         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--;
13798         else {
13799           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 3); __PYX_ERR(0, 534, __pyx_L3_error)
13800         }
13801         CYTHON_FALLTHROUGH;
13802         case  4:
13803         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lambda_param)) != 0)) kw_args--;
13804         else {
13805           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 4); __PYX_ERR(0, 534, __pyx_L3_error)
13806         }
13807         CYTHON_FALLTHROUGH;
13808         case  5:
13809         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_disp)) != 0)) kw_args--;
13810         else {
13811           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 5); __PYX_ERR(0, 534, __pyx_L3_error)
13812         }
13813         CYTHON_FALLTHROUGH;
13814         case  6:
13815         if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_residual)) != 0)) kw_args--;
13816         else {
13817           __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, 6); __PYX_ERR(0, 534, __pyx_L3_error)
13818         }
13819       }
13820       if (unlikely(kw_args > 0)) {
13821         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compute_residual_displacement_field_ssd_3d") < 0)) __PYX_ERR(0, 534, __pyx_L3_error)
13822       }
13823     } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
13824       goto __pyx_L5_argtuple_error;
13825     } else {
13826       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
13827       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
13828       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
13829       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
13830       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
13831       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
13832       values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
13833     }
13834     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 535, __pyx_L3_error)
13835     __pyx_v_sigmasq_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_sigmasq_field.memview)) __PYX_ERR(0, 535, __pyx_L3_error)
13836     __pyx_v_gradient_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_gradient_field.memview)) __PYX_ERR(0, 536, __pyx_L3_error)
13837     __pyx_v_target = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_target.memview)) __PYX_ERR(0, 536, __pyx_L3_error)
13838     __pyx_v_lambda_param = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_lambda_param == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 537, __pyx_L3_error)
13839     __pyx_v_disp = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_disp.memview)) __PYX_ERR(0, 537, __pyx_L3_error)
13840     __pyx_v_residual = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(values[6], PyBUF_WRITABLE); if (unlikely(!__pyx_v_residual.memview)) __PYX_ERR(0, 538, __pyx_L3_error)
13841   }
13842   goto __pyx_L4_argument_unpacking_done;
13843   __pyx_L5_argtuple_error:;
13844   __Pyx_RaiseArgtupleInvalid("compute_residual_displacement_field_ssd_3d", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 534, __pyx_L3_error)
13845   __pyx_L3_error:;
13846   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_residual_displacement_field_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
13847   __Pyx_RefNannyFinishContext();
13848   return NULL;
13849   __pyx_L4_argument_unpacking_done:;
13850   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_46compute_residual_displacement_field_ssd_3d(__pyx_self, __pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_gradient_field, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_disp, __pyx_v_residual);
13851 
13852   /* function exit code */
13853   __Pyx_RefNannyFinishContext();
13854   return __pyx_r;
13855 }
13856 
__pyx_pf_4dipy_5align_9sumsqdiff_46compute_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_gradient_field,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_disp,__Pyx_memviewslice __pyx_v_residual)13857 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_46compute_residual_displacement_field_ssd_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_gradient_field, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_disp, __Pyx_memviewslice __pyx_v_residual) {
13858   PyObject *__pyx_v_ftype = NULL;
13859   int __pyx_v_NUM_NEIGHBORS;
13860   int *__pyx_v_dSlice;
13861   int *__pyx_v_dRow;
13862   int *__pyx_v_dCol;
13863   double *__pyx_v_b;
13864   double *__pyx_v_y;
13865   npy_intp __pyx_v_nslices;
13866   npy_intp __pyx_v_nrows;
13867   npy_intp __pyx_v_ncols;
13868   double __pyx_v_delta;
13869   double __pyx_v_sigmasq;
13870   double __pyx_v_dotP;
13871   npy_intp __pyx_v_s;
13872   npy_intp __pyx_v_r;
13873   npy_intp __pyx_v_c;
13874   npy_intp __pyx_v_ds;
13875   npy_intp __pyx_v_dr;
13876   npy_intp __pyx_v_dc;
13877   int __pyx_v_k;
13878   PyObject *__pyx_r = NULL;
13879   __Pyx_RefNannyDeclarations
13880   PyObject *__pyx_t_1 = NULL;
13881   PyObject *__pyx_t_2 = NULL;
13882   PyObject *__pyx_t_3 = NULL;
13883   PyObject *__pyx_t_4 = NULL;
13884   int __pyx_t_5[6];
13885   int __pyx_t_6[6];
13886   int __pyx_t_7[6];
13887   double __pyx_t_8[3];
13888   double __pyx_t_9[3];
13889   int __pyx_t_10;
13890   PyObject *__pyx_t_11 = NULL;
13891   PyObject *__pyx_t_12 = NULL;
13892   __Pyx_memviewslice __pyx_t_13 = { 0, 0, { 0 }, { 0 }, { 0 } };
13893   npy_intp __pyx_t_14;
13894   npy_intp __pyx_t_15;
13895   npy_intp __pyx_t_16;
13896   npy_intp __pyx_t_17;
13897   npy_intp __pyx_t_18;
13898   npy_intp __pyx_t_19;
13899   npy_intp __pyx_t_20;
13900   npy_intp __pyx_t_21;
13901   npy_intp __pyx_t_22;
13902   Py_ssize_t __pyx_t_23;
13903   Py_ssize_t __pyx_t_24;
13904   Py_ssize_t __pyx_t_25;
13905   double __pyx_t_26;
13906   Py_ssize_t __pyx_t_27;
13907   int __pyx_t_28;
13908   int __pyx_t_29;
13909   int __pyx_t_30;
13910   int __pyx_t_31;
13911   long __pyx_t_32;
13912   Py_ssize_t __pyx_t_33;
13913   Py_ssize_t __pyx_t_34;
13914   Py_ssize_t __pyx_t_35;
13915   Py_ssize_t __pyx_t_36;
13916   Py_ssize_t __pyx_t_37;
13917   Py_ssize_t __pyx_t_38;
13918   Py_ssize_t __pyx_t_39;
13919   Py_ssize_t __pyx_t_40;
13920   Py_ssize_t __pyx_t_41;
13921   Py_ssize_t __pyx_t_42;
13922   Py_ssize_t __pyx_t_43;
13923   Py_ssize_t __pyx_t_44;
13924   Py_ssize_t __pyx_t_45;
13925   Py_ssize_t __pyx_t_46;
13926   Py_ssize_t __pyx_t_47;
13927   Py_ssize_t __pyx_t_48;
13928   Py_ssize_t __pyx_t_49;
13929   Py_ssize_t __pyx_t_50;
13930   Py_ssize_t __pyx_t_51;
13931   Py_ssize_t __pyx_t_52;
13932   int __pyx_lineno = 0;
13933   const char *__pyx_filename = NULL;
13934   int __pyx_clineno = 0;
13935   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_residual_displacement_field_ssd_3d", 0);
13936 
13937   /* "dipy/align/sumsqdiff.pyx":579
13938  *               Vision, 2005. ICCV 2005.
13939  *     """
13940  *     ftype = np.asarray(delta_field).dtype             # <<<<<<<<<<<<<<
13941  *     cdef:
13942  *         int NUM_NEIGHBORS = 6
13943  */
13944   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 579, __pyx_L1_error)
13945   __Pyx_GOTREF(__pyx_t_2);
13946   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 579, __pyx_L1_error)
13947   __Pyx_GOTREF(__pyx_t_3);
13948   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13949   __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 3, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 579, __pyx_L1_error)
13950   __Pyx_GOTREF(__pyx_t_2);
13951   __pyx_t_4 = NULL;
13952   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
13953     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
13954     if (likely(__pyx_t_4)) {
13955       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
13956       __Pyx_INCREF(__pyx_t_4);
13957       __Pyx_INCREF(function);
13958       __Pyx_DECREF_SET(__pyx_t_3, function);
13959     }
13960   }
13961   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
13962   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
13963   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13964   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 579, __pyx_L1_error)
13965   __Pyx_GOTREF(__pyx_t_1);
13966   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
13967   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 579, __pyx_L1_error)
13968   __Pyx_GOTREF(__pyx_t_3);
13969   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13970   __pyx_v_ftype = __pyx_t_3;
13971   __pyx_t_3 = 0;
13972 
13973   /* "dipy/align/sumsqdiff.pyx":581
13974  *     ftype = np.asarray(delta_field).dtype
13975  *     cdef:
13976  *         int NUM_NEIGHBORS = 6             # <<<<<<<<<<<<<<
13977  *         int* dSlice = [-1,  0, 0, 0,  0, 1]
13978  *         int* dRow = [0, -1, 0, 1,  0, 0]
13979  */
13980   __pyx_v_NUM_NEIGHBORS = 6;
13981 
13982   /* "dipy/align/sumsqdiff.pyx":582
13983  *     cdef:
13984  *         int NUM_NEIGHBORS = 6
13985  *         int* dSlice = [-1,  0, 0, 0,  0, 1]             # <<<<<<<<<<<<<<
13986  *         int* dRow = [0, -1, 0, 1,  0, 0]
13987  *         int* dCol = [0,  0, 1, 0, -1, 0]
13988  */
13989   __pyx_t_5[0] = -1;
13990   __pyx_t_5[1] = 0;
13991   __pyx_t_5[2] = 0;
13992   __pyx_t_5[3] = 0;
13993   __pyx_t_5[4] = 0;
13994   __pyx_t_5[5] = 1;
13995   __pyx_v_dSlice = __pyx_t_5;
13996 
13997   /* "dipy/align/sumsqdiff.pyx":583
13998  *         int NUM_NEIGHBORS = 6
13999  *         int* dSlice = [-1,  0, 0, 0,  0, 1]
14000  *         int* dRow = [0, -1, 0, 1,  0, 0]             # <<<<<<<<<<<<<<
14001  *         int* dCol = [0,  0, 1, 0, -1, 0]
14002  *         double* b = [0, 0, 0]
14003  */
14004   __pyx_t_6[0] = 0;
14005   __pyx_t_6[1] = -1;
14006   __pyx_t_6[2] = 0;
14007   __pyx_t_6[3] = 1;
14008   __pyx_t_6[4] = 0;
14009   __pyx_t_6[5] = 0;
14010   __pyx_v_dRow = __pyx_t_6;
14011 
14012   /* "dipy/align/sumsqdiff.pyx":584
14013  *         int* dSlice = [-1,  0, 0, 0,  0, 1]
14014  *         int* dRow = [0, -1, 0, 1,  0, 0]
14015  *         int* dCol = [0,  0, 1, 0, -1, 0]             # <<<<<<<<<<<<<<
14016  *         double* b = [0, 0, 0]
14017  *         double* y = [0, 0, 0]
14018  */
14019   __pyx_t_7[0] = 0;
14020   __pyx_t_7[1] = 0;
14021   __pyx_t_7[2] = 1;
14022   __pyx_t_7[3] = 0;
14023   __pyx_t_7[4] = -1;
14024   __pyx_t_7[5] = 0;
14025   __pyx_v_dCol = __pyx_t_7;
14026 
14027   /* "dipy/align/sumsqdiff.pyx":585
14028  *         int* dRow = [0, -1, 0, 1,  0, 0]
14029  *         int* dCol = [0,  0, 1, 0, -1, 0]
14030  *         double* b = [0, 0, 0]             # <<<<<<<<<<<<<<
14031  *         double* y = [0, 0, 0]
14032  *
14033  */
14034   __pyx_t_8[0] = 0.0;
14035   __pyx_t_8[1] = 0.0;
14036   __pyx_t_8[2] = 0.0;
14037   __pyx_v_b = __pyx_t_8;
14038 
14039   /* "dipy/align/sumsqdiff.pyx":586
14040  *         int* dCol = [0,  0, 1, 0, -1, 0]
14041  *         double* b = [0, 0, 0]
14042  *         double* y = [0, 0, 0]             # <<<<<<<<<<<<<<
14043  *
14044  *         cnp.npy_intp nslices = delta_field.shape[0]
14045  */
14046   __pyx_t_9[0] = 0.0;
14047   __pyx_t_9[1] = 0.0;
14048   __pyx_t_9[2] = 0.0;
14049   __pyx_v_y = __pyx_t_9;
14050 
14051   /* "dipy/align/sumsqdiff.pyx":588
14052  *         double* y = [0, 0, 0]
14053  *
14054  *         cnp.npy_intp nslices = delta_field.shape[0]             # <<<<<<<<<<<<<<
14055  *         cnp.npy_intp nrows = delta_field.shape[1]
14056  *         cnp.npy_intp ncols = delta_field.shape[2]
14057  */
14058   __pyx_v_nslices = (__pyx_v_delta_field.shape[0]);
14059 
14060   /* "dipy/align/sumsqdiff.pyx":589
14061  *
14062  *         cnp.npy_intp nslices = delta_field.shape[0]
14063  *         cnp.npy_intp nrows = delta_field.shape[1]             # <<<<<<<<<<<<<<
14064  *         cnp.npy_intp ncols = delta_field.shape[2]
14065  *         double delta, sigmasq, dotP
14066  */
14067   __pyx_v_nrows = (__pyx_v_delta_field.shape[1]);
14068 
14069   /* "dipy/align/sumsqdiff.pyx":590
14070  *         cnp.npy_intp nslices = delta_field.shape[0]
14071  *         cnp.npy_intp nrows = delta_field.shape[1]
14072  *         cnp.npy_intp ncols = delta_field.shape[2]             # <<<<<<<<<<<<<<
14073  *         double delta, sigmasq, dotP
14074  *         cnp.npy_intp s, r, c, ds, dr, dc
14075  */
14076   __pyx_v_ncols = (__pyx_v_delta_field.shape[2]);
14077 
14078   /* "dipy/align/sumsqdiff.pyx":593
14079  *         double delta, sigmasq, dotP
14080  *         cnp.npy_intp s, r, c, ds, dr, dc
14081  *     if residual is None:             # <<<<<<<<<<<<<<
14082  *         residual = np.empty(shape=(nslices, nrows, ncols, 3), dtype=ftype)
14083  *
14084  */
14085   __pyx_t_10 = ((((PyObject *) __pyx_v_residual.memview) == Py_None) != 0);
14086   if (__pyx_t_10) {
14087 
14088     /* "dipy/align/sumsqdiff.pyx":594
14089  *         cnp.npy_intp s, r, c, ds, dr, dc
14090  *     if residual is None:
14091  *         residual = np.empty(shape=(nslices, nrows, ncols, 3), dtype=ftype)             # <<<<<<<<<<<<<<
14092  *
14093  *     with nogil:
14094  */
14095     __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
14096     __Pyx_GOTREF(__pyx_t_3);
14097     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 594, __pyx_L1_error)
14098     __Pyx_GOTREF(__pyx_t_1);
14099     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14100     __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
14101     __Pyx_GOTREF(__pyx_t_3);
14102     __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nslices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 594, __pyx_L1_error)
14103     __Pyx_GOTREF(__pyx_t_2);
14104     __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nrows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 594, __pyx_L1_error)
14105     __Pyx_GOTREF(__pyx_t_4);
14106     __pyx_t_11 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_ncols); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 594, __pyx_L1_error)
14107     __Pyx_GOTREF(__pyx_t_11);
14108     __pyx_t_12 = PyTuple_New(4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 594, __pyx_L1_error)
14109     __Pyx_GOTREF(__pyx_t_12);
14110     __Pyx_GIVEREF(__pyx_t_2);
14111     PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
14112     __Pyx_GIVEREF(__pyx_t_4);
14113     PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_4);
14114     __Pyx_GIVEREF(__pyx_t_11);
14115     PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_11);
14116     __Pyx_INCREF(__pyx_int_3);
14117     __Pyx_GIVEREF(__pyx_int_3);
14118     PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_int_3);
14119     __pyx_t_2 = 0;
14120     __pyx_t_4 = 0;
14121     __pyx_t_11 = 0;
14122     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_shape, __pyx_t_12) < 0) __PYX_ERR(0, 594, __pyx_L1_error)
14123     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
14124     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_ftype) < 0) __PYX_ERR(0, 594, __pyx_L1_error)
14125     __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 594, __pyx_L1_error)
14126     __Pyx_GOTREF(__pyx_t_12);
14127     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14128     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14129     __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(__pyx_t_12, PyBUF_WRITABLE); if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 594, __pyx_L1_error)
14130     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
14131     __PYX_XDEC_MEMVIEW(&__pyx_v_residual, 1);
14132     __pyx_v_residual = __pyx_t_13;
14133     __pyx_t_13.memview = NULL;
14134     __pyx_t_13.data = NULL;
14135 
14136     /* "dipy/align/sumsqdiff.pyx":593
14137  *         double delta, sigmasq, dotP
14138  *         cnp.npy_intp s, r, c, ds, dr, dc
14139  *     if residual is None:             # <<<<<<<<<<<<<<
14140  *         residual = np.empty(shape=(nslices, nrows, ncols, 3), dtype=ftype)
14141  *
14142  */
14143   }
14144 
14145   /* "dipy/align/sumsqdiff.pyx":596
14146  *         residual = np.empty(shape=(nslices, nrows, ncols, 3), dtype=ftype)
14147  *
14148  *     with nogil:             # <<<<<<<<<<<<<<
14149  *
14150  *         for s in range(nslices):
14151  */
14152   {
14153       #ifdef WITH_THREAD
14154       PyThreadState *_save;
14155       Py_UNBLOCK_THREADS
14156       __Pyx_FastGIL_Remember();
14157       #endif
14158       /*try:*/ {
14159 
14160         /* "dipy/align/sumsqdiff.pyx":598
14161  *     with nogil:
14162  *
14163  *         for s in range(nslices):             # <<<<<<<<<<<<<<
14164  *             for r in range(nrows):
14165  *                 for c in range(ncols):
14166  */
14167         __pyx_t_14 = __pyx_v_nslices;
14168         __pyx_t_15 = __pyx_t_14;
14169         for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
14170           __pyx_v_s = __pyx_t_16;
14171 
14172           /* "dipy/align/sumsqdiff.pyx":599
14173  *
14174  *         for s in range(nslices):
14175  *             for r in range(nrows):             # <<<<<<<<<<<<<<
14176  *                 for c in range(ncols):
14177  *                     delta = delta_field[s, r, c]
14178  */
14179           __pyx_t_17 = __pyx_v_nrows;
14180           __pyx_t_18 = __pyx_t_17;
14181           for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {
14182             __pyx_v_r = __pyx_t_19;
14183 
14184             /* "dipy/align/sumsqdiff.pyx":600
14185  *         for s in range(nslices):
14186  *             for r in range(nrows):
14187  *                 for c in range(ncols):             # <<<<<<<<<<<<<<
14188  *                     delta = delta_field[s, r, c]
14189  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
14190  */
14191             __pyx_t_20 = __pyx_v_ncols;
14192             __pyx_t_21 = __pyx_t_20;
14193             for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
14194               __pyx_v_c = __pyx_t_22;
14195 
14196               /* "dipy/align/sumsqdiff.pyx":601
14197  *             for r in range(nrows):
14198  *                 for c in range(ncols):
14199  *                     delta = delta_field[s, r, c]             # <<<<<<<<<<<<<<
14200  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
14201  *                     if(target is None):
14202  */
14203               __pyx_t_23 = __pyx_v_s;
14204               __pyx_t_24 = __pyx_v_r;
14205               __pyx_t_25 = __pyx_v_c;
14206               __pyx_v_delta = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_23 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_24 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_25 * __pyx_v_delta_field.strides[2]) )));
14207 
14208               /* "dipy/align/sumsqdiff.pyx":602
14209  *                 for c in range(ncols):
14210  *                     delta = delta_field[s, r, c]
14211  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1             # <<<<<<<<<<<<<<
14212  *                     if(target is None):
14213  *                         b[0] = delta * gradient_field[s, r, c, 0]
14214  */
14215               if (((((PyObject *) __pyx_v_sigmasq_field.memview) != Py_None) != 0)) {
14216                 __pyx_t_25 = __pyx_v_s;
14217                 __pyx_t_24 = __pyx_v_r;
14218                 __pyx_t_23 = __pyx_v_c;
14219                 __pyx_t_26 = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_sigmasq_field.data + __pyx_t_25 * __pyx_v_sigmasq_field.strides[0]) ) + __pyx_t_24 * __pyx_v_sigmasq_field.strides[1]) ) + __pyx_t_23 * __pyx_v_sigmasq_field.strides[2]) )));
14220               } else {
14221                 __pyx_t_26 = 1.0;
14222               }
14223               __pyx_v_sigmasq = __pyx_t_26;
14224 
14225               /* "dipy/align/sumsqdiff.pyx":603
14226  *                     delta = delta_field[s, r, c]
14227  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
14228  *                     if(target is None):             # <<<<<<<<<<<<<<
14229  *                         b[0] = delta * gradient_field[s, r, c, 0]
14230  *                         b[1] = delta * gradient_field[s, r, c, 1]
14231  */
14232               __pyx_t_10 = ((((PyObject *) __pyx_v_target.memview) == Py_None) != 0);
14233               if (__pyx_t_10) {
14234 
14235                 /* "dipy/align/sumsqdiff.pyx":604
14236  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
14237  *                     if(target is None):
14238  *                         b[0] = delta * gradient_field[s, r, c, 0]             # <<<<<<<<<<<<<<
14239  *                         b[1] = delta * gradient_field[s, r, c, 1]
14240  *                         b[2] = delta * gradient_field[s, r, c, 2]
14241  */
14242                 __pyx_t_23 = __pyx_v_s;
14243                 __pyx_t_24 = __pyx_v_r;
14244                 __pyx_t_25 = __pyx_v_c;
14245                 __pyx_t_27 = 0;
14246                 (__pyx_v_b[0]) = (__pyx_v_delta * (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_23 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_24 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_25 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_27 * __pyx_v_gradient_field.strides[3]) ))));
14247 
14248                 /* "dipy/align/sumsqdiff.pyx":605
14249  *                     if(target is None):
14250  *                         b[0] = delta * gradient_field[s, r, c, 0]
14251  *                         b[1] = delta * gradient_field[s, r, c, 1]             # <<<<<<<<<<<<<<
14252  *                         b[2] = delta * gradient_field[s, r, c, 2]
14253  *                     else:
14254  */
14255                 __pyx_t_27 = __pyx_v_s;
14256                 __pyx_t_25 = __pyx_v_r;
14257                 __pyx_t_24 = __pyx_v_c;
14258                 __pyx_t_23 = 1;
14259                 (__pyx_v_b[1]) = (__pyx_v_delta * (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_27 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_25 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_24 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_23 * __pyx_v_gradient_field.strides[3]) ))));
14260 
14261                 /* "dipy/align/sumsqdiff.pyx":606
14262  *                         b[0] = delta * gradient_field[s, r, c, 0]
14263  *                         b[1] = delta * gradient_field[s, r, c, 1]
14264  *                         b[2] = delta * gradient_field[s, r, c, 2]             # <<<<<<<<<<<<<<
14265  *                     else:
14266  *                         b[0] = target[s, r, c, 0]
14267  */
14268                 __pyx_t_23 = __pyx_v_s;
14269                 __pyx_t_24 = __pyx_v_r;
14270                 __pyx_t_25 = __pyx_v_c;
14271                 __pyx_t_27 = 2;
14272                 (__pyx_v_b[2]) = (__pyx_v_delta * (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_23 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_24 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_25 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_27 * __pyx_v_gradient_field.strides[3]) ))));
14273 
14274                 /* "dipy/align/sumsqdiff.pyx":603
14275  *                     delta = delta_field[s, r, c]
14276  *                     sigmasq = sigmasq_field[s, r, c] if sigmasq_field != None else 1
14277  *                     if(target is None):             # <<<<<<<<<<<<<<
14278  *                         b[0] = delta * gradient_field[s, r, c, 0]
14279  *                         b[1] = delta * gradient_field[s, r, c, 1]
14280  */
14281                 goto __pyx_L13;
14282               }
14283 
14284               /* "dipy/align/sumsqdiff.pyx":608
14285  *                         b[2] = delta * gradient_field[s, r, c, 2]
14286  *                     else:
14287  *                         b[0] = target[s, r, c, 0]             # <<<<<<<<<<<<<<
14288  *                         b[1] = target[s, r, c, 1]
14289  *                         b[2] = target[s, r, c, 2]
14290  */
14291               /*else*/ {
14292                 __pyx_t_27 = __pyx_v_s;
14293                 __pyx_t_25 = __pyx_v_r;
14294                 __pyx_t_24 = __pyx_v_c;
14295                 __pyx_t_23 = 0;
14296                 (__pyx_v_b[0]) = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_27 * __pyx_v_target.strides[0]) ) + __pyx_t_25 * __pyx_v_target.strides[1]) ) + __pyx_t_24 * __pyx_v_target.strides[2]) ) + __pyx_t_23 * __pyx_v_target.strides[3]) )));
14297 
14298                 /* "dipy/align/sumsqdiff.pyx":609
14299  *                     else:
14300  *                         b[0] = target[s, r, c, 0]
14301  *                         b[1] = target[s, r, c, 1]             # <<<<<<<<<<<<<<
14302  *                         b[2] = target[s, r, c, 2]
14303  *                     y[0] = 0
14304  */
14305                 __pyx_t_23 = __pyx_v_s;
14306                 __pyx_t_24 = __pyx_v_r;
14307                 __pyx_t_25 = __pyx_v_c;
14308                 __pyx_t_27 = 1;
14309                 (__pyx_v_b[1]) = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_23 * __pyx_v_target.strides[0]) ) + __pyx_t_24 * __pyx_v_target.strides[1]) ) + __pyx_t_25 * __pyx_v_target.strides[2]) ) + __pyx_t_27 * __pyx_v_target.strides[3]) )));
14310 
14311                 /* "dipy/align/sumsqdiff.pyx":610
14312  *                         b[0] = target[s, r, c, 0]
14313  *                         b[1] = target[s, r, c, 1]
14314  *                         b[2] = target[s, r, c, 2]             # <<<<<<<<<<<<<<
14315  *                     y[0] = 0
14316  *                     y[1] = 0
14317  */
14318                 __pyx_t_27 = __pyx_v_s;
14319                 __pyx_t_25 = __pyx_v_r;
14320                 __pyx_t_24 = __pyx_v_c;
14321                 __pyx_t_23 = 2;
14322                 (__pyx_v_b[2]) = (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_27 * __pyx_v_target.strides[0]) ) + __pyx_t_25 * __pyx_v_target.strides[1]) ) + __pyx_t_24 * __pyx_v_target.strides[2]) ) + __pyx_t_23 * __pyx_v_target.strides[3]) )));
14323               }
14324               __pyx_L13:;
14325 
14326               /* "dipy/align/sumsqdiff.pyx":611
14327  *                         b[1] = target[s, r, c, 1]
14328  *                         b[2] = target[s, r, c, 2]
14329  *                     y[0] = 0             # <<<<<<<<<<<<<<
14330  *                     y[1] = 0
14331  *                     y[2] = 0
14332  */
14333               (__pyx_v_y[0]) = 0.0;
14334 
14335               /* "dipy/align/sumsqdiff.pyx":612
14336  *                         b[2] = target[s, r, c, 2]
14337  *                     y[0] = 0
14338  *                     y[1] = 0             # <<<<<<<<<<<<<<
14339  *                     y[2] = 0
14340  *                     for k in range(NUM_NEIGHBORS):
14341  */
14342               (__pyx_v_y[1]) = 0.0;
14343 
14344               /* "dipy/align/sumsqdiff.pyx":613
14345  *                     y[0] = 0
14346  *                     y[1] = 0
14347  *                     y[2] = 0             # <<<<<<<<<<<<<<
14348  *                     for k in range(NUM_NEIGHBORS):
14349  *                         ds = s + dSlice[k]
14350  */
14351               (__pyx_v_y[2]) = 0.0;
14352 
14353               /* "dipy/align/sumsqdiff.pyx":614
14354  *                     y[1] = 0
14355  *                     y[2] = 0
14356  *                     for k in range(NUM_NEIGHBORS):             # <<<<<<<<<<<<<<
14357  *                         ds = s + dSlice[k]
14358  *                         if((ds < 0) or (ds >= nslices)):
14359  */
14360               __pyx_t_28 = __pyx_v_NUM_NEIGHBORS;
14361               __pyx_t_29 = __pyx_t_28;
14362               for (__pyx_t_30 = 0; __pyx_t_30 < __pyx_t_29; __pyx_t_30+=1) {
14363                 __pyx_v_k = __pyx_t_30;
14364 
14365                 /* "dipy/align/sumsqdiff.pyx":615
14366  *                     y[2] = 0
14367  *                     for k in range(NUM_NEIGHBORS):
14368  *                         ds = s + dSlice[k]             # <<<<<<<<<<<<<<
14369  *                         if((ds < 0) or (ds >= nslices)):
14370  *                             continue
14371  */
14372                 __pyx_v_ds = (__pyx_v_s + (__pyx_v_dSlice[__pyx_v_k]));
14373 
14374                 /* "dipy/align/sumsqdiff.pyx":616
14375  *                     for k in range(NUM_NEIGHBORS):
14376  *                         ds = s + dSlice[k]
14377  *                         if((ds < 0) or (ds >= nslices)):             # <<<<<<<<<<<<<<
14378  *                             continue
14379  *                         dr = r + dRow[k]
14380  */
14381                 __pyx_t_31 = ((__pyx_v_ds < 0) != 0);
14382                 if (!__pyx_t_31) {
14383                 } else {
14384                   __pyx_t_10 = __pyx_t_31;
14385                   goto __pyx_L17_bool_binop_done;
14386                 }
14387                 __pyx_t_31 = ((__pyx_v_ds >= __pyx_v_nslices) != 0);
14388                 __pyx_t_10 = __pyx_t_31;
14389                 __pyx_L17_bool_binop_done:;
14390                 if (__pyx_t_10) {
14391 
14392                   /* "dipy/align/sumsqdiff.pyx":617
14393  *                         ds = s + dSlice[k]
14394  *                         if((ds < 0) or (ds >= nslices)):
14395  *                             continue             # <<<<<<<<<<<<<<
14396  *                         dr = r + dRow[k]
14397  *                         if((dr < 0) or (dr >= nrows)):
14398  */
14399                   goto __pyx_L14_continue;
14400 
14401                   /* "dipy/align/sumsqdiff.pyx":616
14402  *                     for k in range(NUM_NEIGHBORS):
14403  *                         ds = s + dSlice[k]
14404  *                         if((ds < 0) or (ds >= nslices)):             # <<<<<<<<<<<<<<
14405  *                             continue
14406  *                         dr = r + dRow[k]
14407  */
14408                 }
14409 
14410                 /* "dipy/align/sumsqdiff.pyx":618
14411  *                         if((ds < 0) or (ds >= nslices)):
14412  *                             continue
14413  *                         dr = r + dRow[k]             # <<<<<<<<<<<<<<
14414  *                         if((dr < 0) or (dr >= nrows)):
14415  *                             continue
14416  */
14417                 __pyx_v_dr = (__pyx_v_r + (__pyx_v_dRow[__pyx_v_k]));
14418 
14419                 /* "dipy/align/sumsqdiff.pyx":619
14420  *                             continue
14421  *                         dr = r + dRow[k]
14422  *                         if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
14423  *                             continue
14424  *                         dc = c + dCol[k]
14425  */
14426                 __pyx_t_31 = ((__pyx_v_dr < 0) != 0);
14427                 if (!__pyx_t_31) {
14428                 } else {
14429                   __pyx_t_10 = __pyx_t_31;
14430                   goto __pyx_L20_bool_binop_done;
14431                 }
14432                 __pyx_t_31 = ((__pyx_v_dr >= __pyx_v_nrows) != 0);
14433                 __pyx_t_10 = __pyx_t_31;
14434                 __pyx_L20_bool_binop_done:;
14435                 if (__pyx_t_10) {
14436 
14437                   /* "dipy/align/sumsqdiff.pyx":620
14438  *                         dr = r + dRow[k]
14439  *                         if((dr < 0) or (dr >= nrows)):
14440  *                             continue             # <<<<<<<<<<<<<<
14441  *                         dc = c + dCol[k]
14442  *                         if((dc < 0) or (dc >= ncols)):
14443  */
14444                   goto __pyx_L14_continue;
14445 
14446                   /* "dipy/align/sumsqdiff.pyx":619
14447  *                             continue
14448  *                         dr = r + dRow[k]
14449  *                         if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
14450  *                             continue
14451  *                         dc = c + dCol[k]
14452  */
14453                 }
14454 
14455                 /* "dipy/align/sumsqdiff.pyx":621
14456  *                         if((dr < 0) or (dr >= nrows)):
14457  *                             continue
14458  *                         dc = c + dCol[k]             # <<<<<<<<<<<<<<
14459  *                         if((dc < 0) or (dc >= ncols)):
14460  *                             continue
14461  */
14462                 __pyx_v_dc = (__pyx_v_c + (__pyx_v_dCol[__pyx_v_k]));
14463 
14464                 /* "dipy/align/sumsqdiff.pyx":622
14465  *                             continue
14466  *                         dc = c + dCol[k]
14467  *                         if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
14468  *                             continue
14469  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])
14470  */
14471                 __pyx_t_31 = ((__pyx_v_dc < 0) != 0);
14472                 if (!__pyx_t_31) {
14473                 } else {
14474                   __pyx_t_10 = __pyx_t_31;
14475                   goto __pyx_L23_bool_binop_done;
14476                 }
14477                 __pyx_t_31 = ((__pyx_v_dc >= __pyx_v_ncols) != 0);
14478                 __pyx_t_10 = __pyx_t_31;
14479                 __pyx_L23_bool_binop_done:;
14480                 if (__pyx_t_10) {
14481 
14482                   /* "dipy/align/sumsqdiff.pyx":623
14483  *                         dc = c + dCol[k]
14484  *                         if((dc < 0) or (dc >= ncols)):
14485  *                             continue             # <<<<<<<<<<<<<<
14486  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])
14487  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])
14488  */
14489                   goto __pyx_L14_continue;
14490 
14491                   /* "dipy/align/sumsqdiff.pyx":622
14492  *                             continue
14493  *                         dc = c + dCol[k]
14494  *                         if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
14495  *                             continue
14496  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])
14497  */
14498                 }
14499 
14500                 /* "dipy/align/sumsqdiff.pyx":624
14501  *                         if((dc < 0) or (dc >= ncols)):
14502  *                             continue
14503  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])             # <<<<<<<<<<<<<<
14504  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])
14505  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])
14506  */
14507                 __pyx_t_32 = 0;
14508                 __pyx_t_23 = __pyx_v_s;
14509                 __pyx_t_24 = __pyx_v_r;
14510                 __pyx_t_25 = __pyx_v_c;
14511                 __pyx_t_27 = 0;
14512                 __pyx_t_33 = __pyx_v_ds;
14513                 __pyx_t_34 = __pyx_v_dr;
14514                 __pyx_t_35 = __pyx_v_dc;
14515                 __pyx_t_36 = 0;
14516                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + ((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_27 * __pyx_v_disp.strides[3]) ))) - (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_33 * __pyx_v_disp.strides[0]) ) + __pyx_t_34 * __pyx_v_disp.strides[1]) ) + __pyx_t_35 * __pyx_v_disp.strides[2]) ) + __pyx_t_36 * __pyx_v_disp.strides[3]) )))));
14517 
14518                 /* "dipy/align/sumsqdiff.pyx":625
14519  *                             continue
14520  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])
14521  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])             # <<<<<<<<<<<<<<
14522  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])
14523  *                     if dpy_isinf(sigmasq) != 0:
14524  */
14525                 __pyx_t_32 = 1;
14526                 __pyx_t_36 = __pyx_v_s;
14527                 __pyx_t_35 = __pyx_v_r;
14528                 __pyx_t_34 = __pyx_v_c;
14529                 __pyx_t_33 = 1;
14530                 __pyx_t_27 = __pyx_v_ds;
14531                 __pyx_t_25 = __pyx_v_dr;
14532                 __pyx_t_24 = __pyx_v_dc;
14533                 __pyx_t_23 = 1;
14534                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + ((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_36 * __pyx_v_disp.strides[0]) ) + __pyx_t_35 * __pyx_v_disp.strides[1]) ) + __pyx_t_34 * __pyx_v_disp.strides[2]) ) + __pyx_t_33 * __pyx_v_disp.strides[3]) ))) - (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_27 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )))));
14535 
14536                 /* "dipy/align/sumsqdiff.pyx":626
14537  *                         y[0] += (disp[s, r, c, 0] - disp[ds, dr, dc, 0])
14538  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])
14539  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])             # <<<<<<<<<<<<<<
14540  *                     if dpy_isinf(sigmasq) != 0:
14541  *                         residual[s, r, c, 0] = -lambda_param * y[0]
14542  */
14543                 __pyx_t_32 = 2;
14544                 __pyx_t_23 = __pyx_v_s;
14545                 __pyx_t_24 = __pyx_v_r;
14546                 __pyx_t_25 = __pyx_v_c;
14547                 __pyx_t_27 = 2;
14548                 __pyx_t_33 = __pyx_v_ds;
14549                 __pyx_t_34 = __pyx_v_dr;
14550                 __pyx_t_35 = __pyx_v_dc;
14551                 __pyx_t_36 = 2;
14552                 (__pyx_v_y[__pyx_t_32]) = ((__pyx_v_y[__pyx_t_32]) + ((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_23 * __pyx_v_disp.strides[0]) ) + __pyx_t_24 * __pyx_v_disp.strides[1]) ) + __pyx_t_25 * __pyx_v_disp.strides[2]) ) + __pyx_t_27 * __pyx_v_disp.strides[3]) ))) - (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_33 * __pyx_v_disp.strides[0]) ) + __pyx_t_34 * __pyx_v_disp.strides[1]) ) + __pyx_t_35 * __pyx_v_disp.strides[2]) ) + __pyx_t_36 * __pyx_v_disp.strides[3]) )))));
14553                 __pyx_L14_continue:;
14554               }
14555 
14556               /* "dipy/align/sumsqdiff.pyx":627
14557  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])
14558  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])
14559  *                     if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
14560  *                         residual[s, r, c, 0] = -lambda_param * y[0]
14561  *                         residual[s, r, c, 1] = -lambda_param * y[1]
14562  */
14563               __pyx_t_10 = ((dpy_isinf(__pyx_v_sigmasq) != 0) != 0);
14564               if (__pyx_t_10) {
14565 
14566                 /* "dipy/align/sumsqdiff.pyx":628
14567  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])
14568  *                     if dpy_isinf(sigmasq) != 0:
14569  *                         residual[s, r, c, 0] = -lambda_param * y[0]             # <<<<<<<<<<<<<<
14570  *                         residual[s, r, c, 1] = -lambda_param * y[1]
14571  *                         residual[s, r, c, 2] = -lambda_param * y[2]
14572  */
14573                 __pyx_t_36 = __pyx_v_s;
14574                 __pyx_t_35 = __pyx_v_r;
14575                 __pyx_t_34 = __pyx_v_c;
14576                 __pyx_t_33 = 0;
14577                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_36 * __pyx_v_residual.strides[0]) ) + __pyx_t_35 * __pyx_v_residual.strides[1]) ) + __pyx_t_34 * __pyx_v_residual.strides[2]) ) + __pyx_t_33 * __pyx_v_residual.strides[3]) )) = ((-__pyx_v_lambda_param) * (__pyx_v_y[0]));
14578 
14579                 /* "dipy/align/sumsqdiff.pyx":629
14580  *                     if dpy_isinf(sigmasq) != 0:
14581  *                         residual[s, r, c, 0] = -lambda_param * y[0]
14582  *                         residual[s, r, c, 1] = -lambda_param * y[1]             # <<<<<<<<<<<<<<
14583  *                         residual[s, r, c, 2] = -lambda_param * y[2]
14584  *                     else:
14585  */
14586                 __pyx_t_33 = __pyx_v_s;
14587                 __pyx_t_34 = __pyx_v_r;
14588                 __pyx_t_35 = __pyx_v_c;
14589                 __pyx_t_36 = 1;
14590                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_33 * __pyx_v_residual.strides[0]) ) + __pyx_t_34 * __pyx_v_residual.strides[1]) ) + __pyx_t_35 * __pyx_v_residual.strides[2]) ) + __pyx_t_36 * __pyx_v_residual.strides[3]) )) = ((-__pyx_v_lambda_param) * (__pyx_v_y[1]));
14591 
14592                 /* "dipy/align/sumsqdiff.pyx":630
14593  *                         residual[s, r, c, 0] = -lambda_param * y[0]
14594  *                         residual[s, r, c, 1] = -lambda_param * y[1]
14595  *                         residual[s, r, c, 2] = -lambda_param * y[2]             # <<<<<<<<<<<<<<
14596  *                     else:
14597  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +
14598  */
14599                 __pyx_t_36 = __pyx_v_s;
14600                 __pyx_t_35 = __pyx_v_r;
14601                 __pyx_t_34 = __pyx_v_c;
14602                 __pyx_t_33 = 2;
14603                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_36 * __pyx_v_residual.strides[0]) ) + __pyx_t_35 * __pyx_v_residual.strides[1]) ) + __pyx_t_34 * __pyx_v_residual.strides[2]) ) + __pyx_t_33 * __pyx_v_residual.strides[3]) )) = ((-__pyx_v_lambda_param) * (__pyx_v_y[2]));
14604 
14605                 /* "dipy/align/sumsqdiff.pyx":627
14606  *                         y[1] += (disp[s, r, c, 1] - disp[ds, dr, dc, 1])
14607  *                         y[2] += (disp[s, r, c, 2] - disp[ds, dr, dc, 2])
14608  *                     if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
14609  *                         residual[s, r, c, 0] = -lambda_param * y[0]
14610  *                         residual[s, r, c, 1] = -lambda_param * y[1]
14611  */
14612                 goto __pyx_L25;
14613               }
14614 
14615               /* "dipy/align/sumsqdiff.pyx":632
14616  *                         residual[s, r, c, 2] = -lambda_param * y[2]
14617  *                     else:
14618  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +             # <<<<<<<<<<<<<<
14619  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +
14620  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
14621  */
14622               /*else*/ {
14623 
14624                 /* "dipy/align/sumsqdiff.pyx":633
14625  *                     else:
14626  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +
14627  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +             # <<<<<<<<<<<<<<
14628  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
14629  *                         residual[s, r, c, 0] = (b[0] -
14630  */
14631                 __pyx_t_33 = __pyx_v_s;
14632                 __pyx_t_34 = __pyx_v_r;
14633                 __pyx_t_35 = __pyx_v_c;
14634                 __pyx_t_36 = 0;
14635 
14636                 /* "dipy/align/sumsqdiff.pyx":632
14637  *                         residual[s, r, c, 2] = -lambda_param * y[2]
14638  *                     else:
14639  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +             # <<<<<<<<<<<<<<
14640  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +
14641  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
14642  */
14643                 __pyx_t_27 = __pyx_v_s;
14644                 __pyx_t_25 = __pyx_v_r;
14645                 __pyx_t_24 = __pyx_v_c;
14646                 __pyx_t_23 = 0;
14647 
14648                 /* "dipy/align/sumsqdiff.pyx":633
14649  *                     else:
14650  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +
14651  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +             # <<<<<<<<<<<<<<
14652  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
14653  *                         residual[s, r, c, 0] = (b[0] -
14654  */
14655                 __pyx_t_37 = __pyx_v_s;
14656                 __pyx_t_38 = __pyx_v_r;
14657                 __pyx_t_39 = __pyx_v_c;
14658                 __pyx_t_40 = 1;
14659                 __pyx_t_41 = __pyx_v_s;
14660                 __pyx_t_42 = __pyx_v_r;
14661                 __pyx_t_43 = __pyx_v_c;
14662                 __pyx_t_44 = 1;
14663 
14664                 /* "dipy/align/sumsqdiff.pyx":634
14665  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +
14666  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +
14667  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])             # <<<<<<<<<<<<<<
14668  *                         residual[s, r, c, 0] = (b[0] -
14669  *                                                 (gradient_field[s, r, c, 0] * dotP +
14670  */
14671                 __pyx_t_45 = __pyx_v_s;
14672                 __pyx_t_46 = __pyx_v_r;
14673                 __pyx_t_47 = __pyx_v_c;
14674                 __pyx_t_48 = 2;
14675                 __pyx_t_49 = __pyx_v_s;
14676                 __pyx_t_50 = __pyx_v_r;
14677                 __pyx_t_51 = __pyx_v_c;
14678                 __pyx_t_52 = 2;
14679 
14680                 /* "dipy/align/sumsqdiff.pyx":633
14681  *                     else:
14682  *                         dotP = (gradient_field[s, r, c, 0] * disp[s, r, c, 0] +
14683  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +             # <<<<<<<<<<<<<<
14684  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
14685  *                         residual[s, r, c, 0] = (b[0] -
14686  */
14687                 __pyx_v_dotP = ((((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_33 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_34 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_35 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_36 * __pyx_v_gradient_field.strides[3]) ))) * (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_27 * __pyx_v_disp.strides[0]) ) + __pyx_t_25 * __pyx_v_disp.strides[1]) ) + __pyx_t_24 * __pyx_v_disp.strides[2]) ) + __pyx_t_23 * __pyx_v_disp.strides[3]) )))) + ((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_37 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_38 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_39 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_40 * __pyx_v_gradient_field.strides[3]) ))) * (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_41 * __pyx_v_disp.strides[0]) ) + __pyx_t_42 * __pyx_v_disp.strides[1]) ) + __pyx_t_43 * __pyx_v_disp.strides[2]) ) + __pyx_t_44 * __pyx_v_disp.strides[3]) ))))) + ((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_45 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_46 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_47 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_48 * __pyx_v_gradient_field.strides[3]) ))) * (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_disp.data + __pyx_t_49 * __pyx_v_disp.strides[0]) ) + __pyx_t_50 * __pyx_v_disp.strides[1]) ) + __pyx_t_51 * __pyx_v_disp.strides[2]) ) + __pyx_t_52 * __pyx_v_disp.strides[3]) )))));
14688 
14689                 /* "dipy/align/sumsqdiff.pyx":636
14690  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
14691  *                         residual[s, r, c, 0] = (b[0] -
14692  *                                                 (gradient_field[s, r, c, 0] * dotP +             # <<<<<<<<<<<<<<
14693  *                                                  sigmasq * lambda_param * y[0]))
14694  *                         residual[s, r, c, 1] = (b[1] -
14695  */
14696                 __pyx_t_52 = __pyx_v_s;
14697                 __pyx_t_51 = __pyx_v_r;
14698                 __pyx_t_50 = __pyx_v_c;
14699                 __pyx_t_49 = 0;
14700 
14701                 /* "dipy/align/sumsqdiff.pyx":635
14702  *                                 gradient_field[s, r, c, 1] * disp[s, r, c, 1] +
14703  *                                 gradient_field[s, r, c, 2] * disp[s, r, c, 2])
14704  *                         residual[s, r, c, 0] = (b[0] -             # <<<<<<<<<<<<<<
14705  *                                                 (gradient_field[s, r, c, 0] * dotP +
14706  *                                                  sigmasq * lambda_param * y[0]))
14707  */
14708                 __pyx_t_48 = __pyx_v_s;
14709                 __pyx_t_47 = __pyx_v_r;
14710                 __pyx_t_46 = __pyx_v_c;
14711                 __pyx_t_45 = 0;
14712                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_48 * __pyx_v_residual.strides[0]) ) + __pyx_t_47 * __pyx_v_residual.strides[1]) ) + __pyx_t_46 * __pyx_v_residual.strides[2]) ) + __pyx_t_45 * __pyx_v_residual.strides[3]) )) = ((__pyx_v_b[0]) - (((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_52 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_51 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_50 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_49 * __pyx_v_gradient_field.strides[3]) ))) * __pyx_v_dotP) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[0]))));
14713 
14714                 /* "dipy/align/sumsqdiff.pyx":639
14715  *                                                  sigmasq * lambda_param * y[0]))
14716  *                         residual[s, r, c, 1] = (b[1] -
14717  *                                                 (gradient_field[s, r, c, 1] * dotP +             # <<<<<<<<<<<<<<
14718  *                                                  sigmasq * lambda_param * y[1]))
14719  *                         residual[s, r, c, 2] = (b[2] -
14720  */
14721                 __pyx_t_49 = __pyx_v_s;
14722                 __pyx_t_50 = __pyx_v_r;
14723                 __pyx_t_51 = __pyx_v_c;
14724                 __pyx_t_52 = 1;
14725 
14726                 /* "dipy/align/sumsqdiff.pyx":638
14727  *                                                 (gradient_field[s, r, c, 0] * dotP +
14728  *                                                  sigmasq * lambda_param * y[0]))
14729  *                         residual[s, r, c, 1] = (b[1] -             # <<<<<<<<<<<<<<
14730  *                                                 (gradient_field[s, r, c, 1] * dotP +
14731  *                                                  sigmasq * lambda_param * y[1]))
14732  */
14733                 __pyx_t_45 = __pyx_v_s;
14734                 __pyx_t_46 = __pyx_v_r;
14735                 __pyx_t_47 = __pyx_v_c;
14736                 __pyx_t_48 = 1;
14737                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_45 * __pyx_v_residual.strides[0]) ) + __pyx_t_46 * __pyx_v_residual.strides[1]) ) + __pyx_t_47 * __pyx_v_residual.strides[2]) ) + __pyx_t_48 * __pyx_v_residual.strides[3]) )) = ((__pyx_v_b[1]) - (((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_49 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_50 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_51 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_52 * __pyx_v_gradient_field.strides[3]) ))) * __pyx_v_dotP) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[1]))));
14738 
14739                 /* "dipy/align/sumsqdiff.pyx":642
14740  *                                                  sigmasq * lambda_param * y[1]))
14741  *                         residual[s, r, c, 2] = (b[2] -
14742  *                                                 (gradient_field[s, r, c, 2] * dotP +             # <<<<<<<<<<<<<<
14743  *                                                  sigmasq * lambda_param * y[2]))
14744  *     return np.asarray(residual)
14745  */
14746                 __pyx_t_52 = __pyx_v_s;
14747                 __pyx_t_51 = __pyx_v_r;
14748                 __pyx_t_50 = __pyx_v_c;
14749                 __pyx_t_49 = 2;
14750 
14751                 /* "dipy/align/sumsqdiff.pyx":641
14752  *                                                 (gradient_field[s, r, c, 1] * dotP +
14753  *                                                  sigmasq * lambda_param * y[1]))
14754  *                         residual[s, r, c, 2] = (b[2] -             # <<<<<<<<<<<<<<
14755  *                                                 (gradient_field[s, r, c, 2] * dotP +
14756  *                                                  sigmasq * lambda_param * y[2]))
14757  */
14758                 __pyx_t_48 = __pyx_v_s;
14759                 __pyx_t_47 = __pyx_v_r;
14760                 __pyx_t_46 = __pyx_v_c;
14761                 __pyx_t_45 = 2;
14762                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_48 * __pyx_v_residual.strides[0]) ) + __pyx_t_47 * __pyx_v_residual.strides[1]) ) + __pyx_t_46 * __pyx_v_residual.strides[2]) ) + __pyx_t_45 * __pyx_v_residual.strides[3]) )) = ((__pyx_v_b[2]) - (((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_52 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_51 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_50 * __pyx_v_gradient_field.strides[2]) ) + __pyx_t_49 * __pyx_v_gradient_field.strides[3]) ))) * __pyx_v_dotP) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[2]))));
14763               }
14764               __pyx_L25:;
14765             }
14766           }
14767         }
14768       }
14769 
14770       /* "dipy/align/sumsqdiff.pyx":596
14771  *         residual = np.empty(shape=(nslices, nrows, ncols, 3), dtype=ftype)
14772  *
14773  *     with nogil:             # <<<<<<<<<<<<<<
14774  *
14775  *         for s in range(nslices):
14776  */
14777       /*finally:*/ {
14778         /*normal exit:*/{
14779           #ifdef WITH_THREAD
14780           __Pyx_FastGIL_Forget();
14781           Py_BLOCK_THREADS
14782           #endif
14783           goto __pyx_L6;
14784         }
14785         __pyx_L6:;
14786       }
14787   }
14788 
14789   /* "dipy/align/sumsqdiff.pyx":644
14790  *                                                 (gradient_field[s, r, c, 2] * dotP +
14791  *                                                  sigmasq * lambda_param * y[2]))
14792  *     return np.asarray(residual)             # <<<<<<<<<<<<<<
14793  *
14794  *
14795  */
14796   __Pyx_XDECREF(__pyx_r);
14797   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L1_error)
14798   __Pyx_GOTREF(__pyx_t_3);
14799   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 644, __pyx_L1_error)
14800   __Pyx_GOTREF(__pyx_t_1);
14801   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14802   __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_residual, 4, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L1_error)
14803   __Pyx_GOTREF(__pyx_t_3);
14804   __pyx_t_11 = NULL;
14805   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
14806     __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
14807     if (likely(__pyx_t_11)) {
14808       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
14809       __Pyx_INCREF(__pyx_t_11);
14810       __Pyx_INCREF(function);
14811       __Pyx_DECREF_SET(__pyx_t_1, function);
14812     }
14813   }
14814   __pyx_t_12 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_11, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
14815   __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
14816   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14817   if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 644, __pyx_L1_error)
14818   __Pyx_GOTREF(__pyx_t_12);
14819   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14820   __pyx_r = __pyx_t_12;
14821   __pyx_t_12 = 0;
14822   goto __pyx_L0;
14823 
14824   /* "dipy/align/sumsqdiff.pyx":534
14825  * @cython.boundscheck(False)
14826  * @cython.wraparound(False)
14827  * def compute_residual_displacement_field_ssd_3d(             # <<<<<<<<<<<<<<
14828  *         floating[:, :, :] delta_field, floating[:, :, :] sigmasq_field,
14829  *         floating[:, :, :, :] gradient_field, floating[:, :, :, :] target,
14830  */
14831 
14832   /* function exit code */
14833   __pyx_L1_error:;
14834   __Pyx_XDECREF(__pyx_t_1);
14835   __Pyx_XDECREF(__pyx_t_2);
14836   __Pyx_XDECREF(__pyx_t_3);
14837   __Pyx_XDECREF(__pyx_t_4);
14838   __Pyx_XDECREF(__pyx_t_11);
14839   __Pyx_XDECREF(__pyx_t_12);
14840   __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
14841   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_residual_displacement_field_ssd_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
14842   __pyx_r = NULL;
14843   __pyx_L0:;
14844   __Pyx_XDECREF(__pyx_v_ftype);
14845   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
14846   __PYX_XDEC_MEMVIEW(&__pyx_v_sigmasq_field, 1);
14847   __PYX_XDEC_MEMVIEW(&__pyx_v_gradient_field, 1);
14848   __PYX_XDEC_MEMVIEW(&__pyx_v_target, 1);
14849   __PYX_XDEC_MEMVIEW(&__pyx_v_disp, 1);
14850   __PYX_XDEC_MEMVIEW(&__pyx_v_residual, 1);
14851   __Pyx_XGIVEREF(__pyx_r);
14852   __Pyx_RefNannyFinishContext();
14853   return __pyx_r;
14854 }
14855 
14856 /* "dipy/align/sumsqdiff.pyx":649
14857  * @cython.boundscheck(False)
14858  * @cython.wraparound(False)
14859  * cpdef compute_residual_displacement_field_ssd_2d(             # <<<<<<<<<<<<<<
14860  *         floating[:, :] delta_field, floating[:, :] sigmasq_field,
14861  *         floating[:, :, :] gradient_field, floating[:, :, :] target,
14862  */
14863 
14864 /* Python wrapper */
14865 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_15compute_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
14866 static char __pyx_doc_4dipy_5align_9sumsqdiff_14compute_residual_displacement_field_ssd_2d[] = "The residual displacement field to be fit on the next iteration\n\n    Computes the residual displacement field corresponding to the current\n    displacement field in the Multi-resolution Gauss-Seidel solver proposed by\n    Bruhn and Weickert [Bruhn05].\n\n    Parameters\n    ----------\n    delta_field : array, shape (R, C)\n        the difference between the static and moving image (the 'derivative\n        w.r.t. time' in the optical flow model)\n    sigmasq_field : array, shape (R, C)\n        the variance of the gray level value at each voxel, according to the\n        EM model (for SSD, it is 1 for all voxels). Inf and 0 values\n        are processed specially to support infinite and zero variance.\n    gradient_field : array, shape (R, C, 2)\n        the gradient of the moving image\n    target : array, shape (R, C, 2)\n        right-hand side of the linear system to be solved in the Weickert's\n        multi-resolution algorithm\n    lambda_param : float\n        smoothness parameter in the objective function\n    d : array, shape (R, C, 2)\n        the current displacement field to compute the residual from\n    residual : array, shape (R, C, 2)\n        the displacement field to put the residual to\n\n    Returns\n    -------\n    residual : array, shape (R, C, 2)\n        the residual displacement field. If residual was None a input, then\n        a new field is returned, otherwise the same array is returned\n\n    References\n    ----------\n    [Bruhn05] Andres Bruhn and Joachim Weickert, \"Towards ultimate motion\n              estimation: combining highest accuracy with real-time\n              performance\", 10th IEEE International Conference on Computer\n              Vision, 2005. ICCV 2005.\n    ";
14867 static PyMethodDef __pyx_mdef_4dipy_5align_9sumsqdiff_15compute_residual_displacement_field_ssd_2d = {"compute_residual_displacement_field_ssd_2d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_15compute_residual_displacement_field_ssd_2d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_14compute_residual_displacement_field_ssd_2d};
__pyx_pw_4dipy_5align_9sumsqdiff_15compute_residual_displacement_field_ssd_2d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)14868 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_15compute_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
14869   PyObject *__pyx_v_signatures = 0;
14870   PyObject *__pyx_v_args = 0;
14871   PyObject *__pyx_v_kwargs = 0;
14872   CYTHON_UNUSED PyObject *__pyx_v_defaults = 0;
14873   int __pyx_lineno = 0;
14874   const char *__pyx_filename = NULL;
14875   int __pyx_clineno = 0;
14876   PyObject *__pyx_r = 0;
14877   __Pyx_RefNannyDeclarations
14878   __Pyx_RefNannySetupContext("__pyx_fused_cpdef (wrapper)", 0);
14879   {
14880     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signatures,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_defaults,0};
14881     PyObject* values[4] = {0,0,0,0};
14882     if (unlikely(__pyx_kwds)) {
14883       Py_ssize_t kw_args;
14884       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
14885       switch (pos_args) {
14886         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
14887         CYTHON_FALLTHROUGH;
14888         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
14889         CYTHON_FALLTHROUGH;
14890         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
14891         CYTHON_FALLTHROUGH;
14892         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
14893         CYTHON_FALLTHROUGH;
14894         case  0: break;
14895         default: goto __pyx_L5_argtuple_error;
14896       }
14897       kw_args = PyDict_Size(__pyx_kwds);
14898       switch (pos_args) {
14899         case  0:
14900         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signatures)) != 0)) kw_args--;
14901         else goto __pyx_L5_argtuple_error;
14902         CYTHON_FALLTHROUGH;
14903         case  1:
14904         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
14905         else {
14906           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 1); __PYX_ERR(0, 649, __pyx_L3_error)
14907         }
14908         CYTHON_FALLTHROUGH;
14909         case  2:
14910         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
14911         else {
14912           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); __PYX_ERR(0, 649, __pyx_L3_error)
14913         }
14914         CYTHON_FALLTHROUGH;
14915         case  3:
14916         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--;
14917         else {
14918           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); __PYX_ERR(0, 649, __pyx_L3_error)
14919         }
14920       }
14921       if (unlikely(kw_args > 0)) {
14922         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) __PYX_ERR(0, 649, __pyx_L3_error)
14923       }
14924     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
14925       goto __pyx_L5_argtuple_error;
14926     } else {
14927       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
14928       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
14929       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
14930       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
14931     }
14932     __pyx_v_signatures = values[0];
14933     __pyx_v_args = values[1];
14934     __pyx_v_kwargs = values[2];
14935     __pyx_v_defaults = values[3];
14936   }
14937   goto __pyx_L4_argument_unpacking_done;
14938   __pyx_L5_argtuple_error:;
14939   __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 649, __pyx_L3_error)
14940   __pyx_L3_error:;
14941   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
14942   __Pyx_RefNannyFinishContext();
14943   return NULL;
14944   __pyx_L4_argument_unpacking_done:;
14945   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_14compute_residual_displacement_field_ssd_2d(__pyx_self, __pyx_v_signatures, __pyx_v_args, __pyx_v_kwargs, __pyx_v_defaults);
14946 
14947   /* function exit code */
14948   __Pyx_RefNannyFinishContext();
14949   return __pyx_r;
14950 }
14951 
__pyx_pf_4dipy_5align_9sumsqdiff_14compute_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_signatures,PyObject * __pyx_v_args,PyObject * __pyx_v_kwargs,CYTHON_UNUSED PyObject * __pyx_v_defaults)14952 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_14compute_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults) {
14953   PyObject *__pyx_v_dest_sig = NULL;
14954   Py_ssize_t __pyx_v_i;
14955   PyTypeObject *__pyx_v_ndarray = 0;
14956   __Pyx_memviewslice __pyx_v_memslice;
14957   Py_ssize_t __pyx_v_itemsize;
14958   CYTHON_UNUSED int __pyx_v_dtype_signed;
14959   char __pyx_v_kind;
14960   PyObject *__pyx_v_arg = NULL;
14961   PyObject *__pyx_v_dtype = NULL;
14962   PyObject *__pyx_v_arg_base = NULL;
14963   PyObject *__pyx_v_candidates = NULL;
14964   PyObject *__pyx_v_sig = NULL;
14965   int __pyx_v_match_found;
14966   PyObject *__pyx_v_src_sig = NULL;
14967   PyObject *__pyx_v_dst_type = NULL;
14968   PyObject *__pyx_r = NULL;
14969   __Pyx_RefNannyDeclarations
14970   PyObject *__pyx_t_1 = NULL;
14971   int __pyx_t_2;
14972   int __pyx_t_3;
14973   int __pyx_t_4;
14974   Py_ssize_t __pyx_t_5;
14975   PyObject *__pyx_t_6 = NULL;
14976   long __pyx_t_7;
14977   __Pyx_memviewslice __pyx_t_8;
14978   Py_ssize_t __pyx_t_9;
14979   int __pyx_t_10;
14980   int __pyx_t_11;
14981   PyObject *__pyx_t_12 = NULL;
14982   PyObject *__pyx_t_13 = NULL;
14983   PyObject *__pyx_t_14 = NULL;
14984   Py_ssize_t __pyx_t_15;
14985   Py_ssize_t __pyx_t_16;
14986   Py_ssize_t __pyx_t_17;
14987   int __pyx_t_18;
14988   int __pyx_lineno = 0;
14989   const char *__pyx_filename = NULL;
14990   int __pyx_clineno = 0;
14991   __Pyx_RefNannySetupContext("compute_residual_displacement_field_ssd_2d", 0);
14992   __Pyx_INCREF(__pyx_v_kwargs);
14993   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
14994   __Pyx_GOTREF(__pyx_t_1);
14995   __Pyx_INCREF(Py_None);
14996   __Pyx_GIVEREF(Py_None);
14997   PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
14998   __pyx_v_dest_sig = ((PyObject*)__pyx_t_1);
14999   __pyx_t_1 = 0;
15000   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
15001   __pyx_t_4 = (__pyx_t_3 != 0);
15002   if (__pyx_t_4) {
15003   } else {
15004     __pyx_t_2 = __pyx_t_4;
15005     goto __pyx_L4_bool_binop_done;
15006   }
15007   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
15008   __pyx_t_3 = ((!__pyx_t_4) != 0);
15009   __pyx_t_2 = __pyx_t_3;
15010   __pyx_L4_bool_binop_done:;
15011   if (__pyx_t_2) {
15012     __Pyx_INCREF(Py_None);
15013     __Pyx_DECREF_SET(__pyx_v_kwargs, Py_None);
15014   }
15015   __pyx_t_1 = ((PyObject *)__Pyx_ImportNumPyArrayTypeIfAvailable()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
15016   __Pyx_GOTREF(__pyx_t_1);
15017   __pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1);
15018   __pyx_t_1 = 0;
15019   __pyx_v_itemsize = -1L;
15020   if (unlikely(__pyx_v_args == Py_None)) {
15021     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
15022     __PYX_ERR(0, 649, __pyx_L1_error)
15023   }
15024   __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 649, __pyx_L1_error)
15025   __pyx_t_2 = ((0 < __pyx_t_5) != 0);
15026   if (__pyx_t_2) {
15027     if (unlikely(__pyx_v_args == Py_None)) {
15028       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
15029       __PYX_ERR(0, 649, __pyx_L1_error)
15030     }
15031     __pyx_t_1 = PyTuple_GET_ITEM(((PyObject*)__pyx_v_args), 0);
15032     __Pyx_INCREF(__pyx_t_1);
15033     __pyx_v_arg = __pyx_t_1;
15034     __pyx_t_1 = 0;
15035     goto __pyx_L6;
15036   }
15037   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
15038   __pyx_t_4 = (__pyx_t_3 != 0);
15039   if (__pyx_t_4) {
15040   } else {
15041     __pyx_t_2 = __pyx_t_4;
15042     goto __pyx_L7_bool_binop_done;
15043   }
15044   if (unlikely(__pyx_v_kwargs == Py_None)) {
15045     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
15046     __PYX_ERR(0, 649, __pyx_L1_error)
15047   }
15048   __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_delta_field, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
15049   __pyx_t_3 = (__pyx_t_4 != 0);
15050   __pyx_t_2 = __pyx_t_3;
15051   __pyx_L7_bool_binop_done:;
15052   if (__pyx_t_2) {
15053     if (unlikely(__pyx_v_kwargs == Py_None)) {
15054       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
15055       __PYX_ERR(0, 649, __pyx_L1_error)
15056     }
15057     __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_delta_field); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
15058     __Pyx_GOTREF(__pyx_t_1);
15059     __pyx_v_arg = __pyx_t_1;
15060     __pyx_t_1 = 0;
15061     goto __pyx_L6;
15062   }
15063   /*else*/ {
15064     if (unlikely(__pyx_v_args == Py_None)) {
15065       PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
15066       __PYX_ERR(0, 649, __pyx_L1_error)
15067     }
15068     __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 649, __pyx_L1_error)
15069     __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
15070     __Pyx_GOTREF(__pyx_t_1);
15071     __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15072     __Pyx_GOTREF(__pyx_t_6);
15073     __Pyx_INCREF(__pyx_int_7);
15074     __Pyx_GIVEREF(__pyx_int_7);
15075     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_7);
15076     __Pyx_INCREF(__pyx_n_s_s);
15077     __Pyx_GIVEREF(__pyx_n_s_s);
15078     PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_s);
15079     __Pyx_GIVEREF(__pyx_t_1);
15080     PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
15081     __pyx_t_1 = 0;
15082     __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
15083     __Pyx_GOTREF(__pyx_t_1);
15084     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15085     __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15086     __Pyx_GOTREF(__pyx_t_6);
15087     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15088     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
15089     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15090     __PYX_ERR(0, 649, __pyx_L1_error)
15091   }
15092   __pyx_L6:;
15093   while (1) {
15094     __pyx_t_2 = (__pyx_v_ndarray != ((PyTypeObject*)Py_None));
15095     __pyx_t_3 = (__pyx_t_2 != 0);
15096     if (__pyx_t_3) {
15097       __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray);
15098       __pyx_t_2 = (__pyx_t_3 != 0);
15099       if (__pyx_t_2) {
15100         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15101         __Pyx_GOTREF(__pyx_t_6);
15102         __pyx_v_dtype = __pyx_t_6;
15103         __pyx_t_6 = 0;
15104         goto __pyx_L12;
15105       }
15106       __pyx_t_2 = __pyx_memoryview_check(__pyx_v_arg);
15107       __pyx_t_3 = (__pyx_t_2 != 0);
15108       if (__pyx_t_3) {
15109         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15110         __Pyx_GOTREF(__pyx_t_6);
15111         __pyx_v_arg_base = __pyx_t_6;
15112         __pyx_t_6 = 0;
15113         __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray);
15114         __pyx_t_2 = (__pyx_t_3 != 0);
15115         if (__pyx_t_2) {
15116           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15117           __Pyx_GOTREF(__pyx_t_6);
15118           __pyx_v_dtype = __pyx_t_6;
15119           __pyx_t_6 = 0;
15120           goto __pyx_L13;
15121         }
15122         /*else*/ {
15123           __Pyx_INCREF(Py_None);
15124           __pyx_v_dtype = Py_None;
15125         }
15126         __pyx_L13:;
15127         goto __pyx_L12;
15128       }
15129       /*else*/ {
15130         __Pyx_INCREF(Py_None);
15131         __pyx_v_dtype = Py_None;
15132       }
15133       __pyx_L12:;
15134       __pyx_v_itemsize = -1L;
15135       __pyx_t_2 = (__pyx_v_dtype != Py_None);
15136       __pyx_t_3 = (__pyx_t_2 != 0);
15137       if (__pyx_t_3) {
15138         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15139         __Pyx_GOTREF(__pyx_t_6);
15140         __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 649, __pyx_L1_error)
15141         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15142         __pyx_v_itemsize = __pyx_t_5;
15143         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15144         __Pyx_GOTREF(__pyx_t_6);
15145         __pyx_t_7 = __Pyx_PyObject_Ord(__pyx_t_6); if (unlikely(__pyx_t_7 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 649, __pyx_L1_error)
15146         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15147         __pyx_v_kind = __pyx_t_7;
15148         __pyx_v_dtype_signed = (__pyx_v_kind == 'i');
15149         switch (__pyx_v_kind) {
15150           case 'i':
15151           case 'u':
15152           break;
15153           case 'f':
15154           __pyx_t_2 = (((sizeof(float)) == __pyx_v_itemsize) != 0);
15155           if (__pyx_t_2) {
15156           } else {
15157             __pyx_t_3 = __pyx_t_2;
15158             goto __pyx_L16_bool_binop_done;
15159           }
15160           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15161           __Pyx_GOTREF(__pyx_t_6);
15162           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 649, __pyx_L1_error)
15163           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15164           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 2) != 0);
15165           __pyx_t_3 = __pyx_t_2;
15166           __pyx_L16_bool_binop_done:;
15167           if (__pyx_t_3) {
15168             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
15169             goto __pyx_L10_break;
15170           }
15171           __pyx_t_2 = (((sizeof(double)) == __pyx_v_itemsize) != 0);
15172           if (__pyx_t_2) {
15173           } else {
15174             __pyx_t_3 = __pyx_t_2;
15175             goto __pyx_L19_bool_binop_done;
15176           }
15177           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15178           __Pyx_GOTREF(__pyx_t_6);
15179           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 649, __pyx_L1_error)
15180           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15181           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 2) != 0);
15182           __pyx_t_3 = __pyx_t_2;
15183           __pyx_L19_bool_binop_done:;
15184           if (__pyx_t_3) {
15185             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
15186             goto __pyx_L10_break;
15187           }
15188           break;
15189           case 'c':
15190           break;
15191           case 'O':
15192           break;
15193           default: break;
15194         }
15195       }
15196     }
15197     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
15198     if (!__pyx_t_2) {
15199     } else {
15200       __pyx_t_3 = __pyx_t_2;
15201       goto __pyx_L22_bool_binop_done;
15202     }
15203     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(float))) != 0);
15204     __pyx_t_3 = __pyx_t_2;
15205     __pyx_L22_bool_binop_done:;
15206     if (__pyx_t_3) {
15207       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_v_arg, 0);
15208       __pyx_v_memslice = __pyx_t_8;
15209       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
15210       if (__pyx_t_3) {
15211         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
15212         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
15213         goto __pyx_L10_break;
15214       }
15215       /*else*/ {
15216         PyErr_Clear();
15217       }
15218     }
15219     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
15220     if (!__pyx_t_2) {
15221     } else {
15222       __pyx_t_3 = __pyx_t_2;
15223       goto __pyx_L26_bool_binop_done;
15224     }
15225     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(double))) != 0);
15226     __pyx_t_3 = __pyx_t_2;
15227     __pyx_L26_bool_binop_done:;
15228     if (__pyx_t_3) {
15229       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_v_arg, 0);
15230       __pyx_v_memslice = __pyx_t_8;
15231       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
15232       if (__pyx_t_3) {
15233         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
15234         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
15235         goto __pyx_L10_break;
15236       }
15237       /*else*/ {
15238         PyErr_Clear();
15239       }
15240     }
15241     if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
15242     goto __pyx_L10_break;
15243   }
15244   __pyx_L10_break:;
15245   __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15246   __Pyx_GOTREF(__pyx_t_6);
15247   __pyx_v_candidates = ((PyObject*)__pyx_t_6);
15248   __pyx_t_6 = 0;
15249   __pyx_t_5 = 0;
15250   if (unlikely(__pyx_v_signatures == Py_None)) {
15251     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
15252     __PYX_ERR(0, 649, __pyx_L1_error)
15253   }
15254   __pyx_t_1 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
15255   __Pyx_GOTREF(__pyx_t_1);
15256   __Pyx_XDECREF(__pyx_t_6);
15257   __pyx_t_6 = __pyx_t_1;
15258   __pyx_t_1 = 0;
15259   while (1) {
15260     __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_5, &__pyx_t_1, NULL, NULL, __pyx_t_10);
15261     if (unlikely(__pyx_t_11 == 0)) break;
15262     if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 649, __pyx_L1_error)
15263     __Pyx_GOTREF(__pyx_t_1);
15264     __Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_1);
15265     __pyx_t_1 = 0;
15266     __pyx_v_match_found = 0;
15267     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 649, __pyx_L1_error)
15268     __Pyx_GOTREF(__pyx_t_13);
15269     __pyx_t_14 = NULL;
15270     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
15271       __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
15272       if (likely(__pyx_t_14)) {
15273         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
15274         __Pyx_INCREF(__pyx_t_14);
15275         __Pyx_INCREF(function);
15276         __Pyx_DECREF_SET(__pyx_t_13, function);
15277       }
15278     }
15279     __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_kp_s__3) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__3);
15280     __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
15281     if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 649, __pyx_L1_error)
15282     __Pyx_GOTREF(__pyx_t_12);
15283     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
15284     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_split); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 649, __pyx_L1_error)
15285     __Pyx_GOTREF(__pyx_t_13);
15286     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
15287     __pyx_t_12 = NULL;
15288     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
15289       __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
15290       if (likely(__pyx_t_12)) {
15291         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
15292         __Pyx_INCREF(__pyx_t_12);
15293         __Pyx_INCREF(function);
15294         __Pyx_DECREF_SET(__pyx_t_13, function);
15295       }
15296     }
15297     __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_kp_s__4) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__4);
15298     __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
15299     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
15300     __Pyx_GOTREF(__pyx_t_1);
15301     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
15302     __Pyx_XDECREF_SET(__pyx_v_src_sig, __pyx_t_1);
15303     __pyx_t_1 = 0;
15304     __pyx_t_15 = PyList_GET_SIZE(__pyx_v_dest_sig); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 649, __pyx_L1_error)
15305     __pyx_t_16 = __pyx_t_15;
15306     for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
15307       __pyx_v_i = __pyx_t_17;
15308       __pyx_t_1 = PyList_GET_ITEM(__pyx_v_dest_sig, __pyx_v_i);
15309       __Pyx_INCREF(__pyx_t_1);
15310       __Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_1);
15311       __pyx_t_1 = 0;
15312       __pyx_t_3 = (__pyx_v_dst_type != Py_None);
15313       __pyx_t_2 = (__pyx_t_3 != 0);
15314       if (__pyx_t_2) {
15315         __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
15316         __Pyx_GOTREF(__pyx_t_1);
15317         __pyx_t_13 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 649, __pyx_L1_error)
15318         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15319         __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 649, __pyx_L1_error)
15320         __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
15321         if (__pyx_t_2) {
15322           __pyx_v_match_found = 1;
15323           goto __pyx_L34;
15324         }
15325         /*else*/ {
15326           __pyx_v_match_found = 0;
15327           goto __pyx_L32_break;
15328         }
15329         __pyx_L34:;
15330       }
15331     }
15332     __pyx_L32_break:;
15333     __pyx_t_2 = (__pyx_v_match_found != 0);
15334     if (__pyx_t_2) {
15335       __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 649, __pyx_L1_error)
15336     }
15337   }
15338   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15339   __pyx_t_2 = (PyList_GET_SIZE(__pyx_v_candidates) != 0);
15340   __pyx_t_3 = ((!__pyx_t_2) != 0);
15341   if (__pyx_t_3) {
15342     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15343     __Pyx_GOTREF(__pyx_t_6);
15344     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
15345     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15346     __PYX_ERR(0, 649, __pyx_L1_error)
15347   }
15348   __pyx_t_9 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 649, __pyx_L1_error)
15349   __pyx_t_3 = ((__pyx_t_9 > 1) != 0);
15350   if (__pyx_t_3) {
15351     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15352     __Pyx_GOTREF(__pyx_t_6);
15353     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
15354     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15355     __PYX_ERR(0, 649, __pyx_L1_error)
15356   }
15357   /*else*/ {
15358     __Pyx_XDECREF(__pyx_r);
15359     if (unlikely(__pyx_v_signatures == Py_None)) {
15360       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
15361       __PYX_ERR(0, 649, __pyx_L1_error)
15362     }
15363     __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), PyList_GET_ITEM(__pyx_v_candidates, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 649, __pyx_L1_error)
15364     __Pyx_GOTREF(__pyx_t_6);
15365     __pyx_r = __pyx_t_6;
15366     __pyx_t_6 = 0;
15367     goto __pyx_L0;
15368   }
15369 
15370   /* function exit code */
15371   __pyx_L1_error:;
15372   __Pyx_XDECREF(__pyx_t_1);
15373   __Pyx_XDECREF(__pyx_t_6);
15374   __Pyx_XDECREF(__pyx_t_12);
15375   __Pyx_XDECREF(__pyx_t_13);
15376   __Pyx_XDECREF(__pyx_t_14);
15377   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
15378   __pyx_r = NULL;
15379   __pyx_L0:;
15380   __Pyx_XDECREF(__pyx_v_dest_sig);
15381   __Pyx_XDECREF(__pyx_v_ndarray);
15382   __Pyx_XDECREF(__pyx_v_arg);
15383   __Pyx_XDECREF(__pyx_v_dtype);
15384   __Pyx_XDECREF(__pyx_v_arg_base);
15385   __Pyx_XDECREF(__pyx_v_candidates);
15386   __Pyx_XDECREF(__pyx_v_sig);
15387   __Pyx_XDECREF(__pyx_v_src_sig);
15388   __Pyx_XDECREF(__pyx_v_dst_type);
15389   __Pyx_XDECREF(__pyx_v_kwargs);
15390   __Pyx_XGIVEREF(__pyx_r);
15391   __Pyx_RefNannyFinishContext();
15392   return __pyx_r;
15393 }
15394 
15395 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_51__pyx_fuse_0compute_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
15396 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_15compute_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_residual_displacement_field_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_gradient_field,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_d,__Pyx_memviewslice __pyx_v_residual,CYTHON_UNUSED int __pyx_skip_dispatch)15397 static PyObject *__pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_residual_displacement_field_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_gradient_field, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_d, __Pyx_memviewslice __pyx_v_residual, CYTHON_UNUSED int __pyx_skip_dispatch) {
15398   PyObject *__pyx_v_ftype = NULL;
15399   int __pyx_v_NUM_NEIGHBORS;
15400   int *__pyx_v_dRow;
15401   int *__pyx_v_dCol;
15402   double *__pyx_v_b;
15403   double *__pyx_v_y;
15404   npy_intp __pyx_v_nrows;
15405   npy_intp __pyx_v_ncols;
15406   double __pyx_v_delta;
15407   double __pyx_v_sigmasq;
15408   double __pyx_v_dotP;
15409   npy_intp __pyx_v_r;
15410   npy_intp __pyx_v_c;
15411   npy_intp __pyx_v_dr;
15412   npy_intp __pyx_v_dc;
15413   CYTHON_UNUSED long __pyx_v_nn;
15414   int __pyx_v_k;
15415   PyObject *__pyx_r = NULL;
15416   __Pyx_RefNannyDeclarations
15417   PyObject *__pyx_t_1 = NULL;
15418   PyObject *__pyx_t_2 = NULL;
15419   PyObject *__pyx_t_3 = NULL;
15420   PyObject *__pyx_t_4 = NULL;
15421   int __pyx_t_5[4];
15422   int __pyx_t_6[4];
15423   double __pyx_t_7[2];
15424   double __pyx_t_8[2];
15425   int __pyx_t_9;
15426   PyObject *__pyx_t_10 = NULL;
15427   __Pyx_memviewslice __pyx_t_11 = { 0, 0, { 0 }, { 0 }, { 0 } };
15428   npy_intp __pyx_t_12;
15429   npy_intp __pyx_t_13;
15430   npy_intp __pyx_t_14;
15431   npy_intp __pyx_t_15;
15432   npy_intp __pyx_t_16;
15433   npy_intp __pyx_t_17;
15434   Py_ssize_t __pyx_t_18;
15435   Py_ssize_t __pyx_t_19;
15436   double __pyx_t_20;
15437   Py_ssize_t __pyx_t_21;
15438   int __pyx_t_22;
15439   int __pyx_t_23;
15440   int __pyx_t_24;
15441   int __pyx_t_25;
15442   long __pyx_t_26;
15443   Py_ssize_t __pyx_t_27;
15444   Py_ssize_t __pyx_t_28;
15445   Py_ssize_t __pyx_t_29;
15446   Py_ssize_t __pyx_t_30;
15447   Py_ssize_t __pyx_t_31;
15448   Py_ssize_t __pyx_t_32;
15449   Py_ssize_t __pyx_t_33;
15450   Py_ssize_t __pyx_t_34;
15451   Py_ssize_t __pyx_t_35;
15452   int __pyx_lineno = 0;
15453   const char *__pyx_filename = NULL;
15454   int __pyx_clineno = 0;
15455   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_residual_displacement_field_ssd_2d", 0);
15456   __PYX_INC_MEMVIEW(&__pyx_v_residual, 1);
15457 
15458   /* "dipy/align/sumsqdiff.pyx":694
15459  *               Vision, 2005. ICCV 2005.
15460  *     """
15461  *     ftype = np.asarray(delta_field).dtype             # <<<<<<<<<<<<<<
15462  *     cdef:
15463  *         int NUM_NEIGHBORS = 4
15464  */
15465   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __pyx_L1_error)
15466   __Pyx_GOTREF(__pyx_t_2);
15467   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 694, __pyx_L1_error)
15468   __Pyx_GOTREF(__pyx_t_3);
15469   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15470   __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __pyx_L1_error)
15471   __Pyx_GOTREF(__pyx_t_2);
15472   __pyx_t_4 = NULL;
15473   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
15474     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
15475     if (likely(__pyx_t_4)) {
15476       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
15477       __Pyx_INCREF(__pyx_t_4);
15478       __Pyx_INCREF(function);
15479       __Pyx_DECREF_SET(__pyx_t_3, function);
15480     }
15481   }
15482   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
15483   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
15484   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15485   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 694, __pyx_L1_error)
15486   __Pyx_GOTREF(__pyx_t_1);
15487   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15488   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 694, __pyx_L1_error)
15489   __Pyx_GOTREF(__pyx_t_3);
15490   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15491   __pyx_v_ftype = __pyx_t_3;
15492   __pyx_t_3 = 0;
15493 
15494   /* "dipy/align/sumsqdiff.pyx":696
15495  *     ftype = np.asarray(delta_field).dtype
15496  *     cdef:
15497  *         int NUM_NEIGHBORS = 4             # <<<<<<<<<<<<<<
15498  *         int* dRow = [-1, 0, 1,  0]
15499  *         int* dCol = [0, 1, 0, -1]
15500  */
15501   __pyx_v_NUM_NEIGHBORS = 4;
15502 
15503   /* "dipy/align/sumsqdiff.pyx":697
15504  *     cdef:
15505  *         int NUM_NEIGHBORS = 4
15506  *         int* dRow = [-1, 0, 1,  0]             # <<<<<<<<<<<<<<
15507  *         int* dCol = [0, 1, 0, -1]
15508  *         double* b = [0, 0]
15509  */
15510   __pyx_t_5[0] = -1;
15511   __pyx_t_5[1] = 0;
15512   __pyx_t_5[2] = 1;
15513   __pyx_t_5[3] = 0;
15514   __pyx_v_dRow = __pyx_t_5;
15515 
15516   /* "dipy/align/sumsqdiff.pyx":698
15517  *         int NUM_NEIGHBORS = 4
15518  *         int* dRow = [-1, 0, 1,  0]
15519  *         int* dCol = [0, 1, 0, -1]             # <<<<<<<<<<<<<<
15520  *         double* b = [0, 0]
15521  *         double* y = [0, 0]
15522  */
15523   __pyx_t_6[0] = 0;
15524   __pyx_t_6[1] = 1;
15525   __pyx_t_6[2] = 0;
15526   __pyx_t_6[3] = -1;
15527   __pyx_v_dCol = __pyx_t_6;
15528 
15529   /* "dipy/align/sumsqdiff.pyx":699
15530  *         int* dRow = [-1, 0, 1,  0]
15531  *         int* dCol = [0, 1, 0, -1]
15532  *         double* b = [0, 0]             # <<<<<<<<<<<<<<
15533  *         double* y = [0, 0]
15534  *
15535  */
15536   __pyx_t_7[0] = 0.0;
15537   __pyx_t_7[1] = 0.0;
15538   __pyx_v_b = __pyx_t_7;
15539 
15540   /* "dipy/align/sumsqdiff.pyx":700
15541  *         int* dCol = [0, 1, 0, -1]
15542  *         double* b = [0, 0]
15543  *         double* y = [0, 0]             # <<<<<<<<<<<<<<
15544  *
15545  *         cnp.npy_intp nrows = delta_field.shape[0]
15546  */
15547   __pyx_t_8[0] = 0.0;
15548   __pyx_t_8[1] = 0.0;
15549   __pyx_v_y = __pyx_t_8;
15550 
15551   /* "dipy/align/sumsqdiff.pyx":702
15552  *         double* y = [0, 0]
15553  *
15554  *         cnp.npy_intp nrows = delta_field.shape[0]             # <<<<<<<<<<<<<<
15555  *         cnp.npy_intp ncols = delta_field.shape[1]
15556  *         double delta, sigmasq, dotP
15557  */
15558   __pyx_v_nrows = (__pyx_v_delta_field.shape[0]);
15559 
15560   /* "dipy/align/sumsqdiff.pyx":703
15561  *
15562  *         cnp.npy_intp nrows = delta_field.shape[0]
15563  *         cnp.npy_intp ncols = delta_field.shape[1]             # <<<<<<<<<<<<<<
15564  *         double delta, sigmasq, dotP
15565  *         cnp.npy_intp r, c, dr, dc
15566  */
15567   __pyx_v_ncols = (__pyx_v_delta_field.shape[1]);
15568 
15569   /* "dipy/align/sumsqdiff.pyx":706
15570  *         double delta, sigmasq, dotP
15571  *         cnp.npy_intp r, c, dr, dc
15572  *     if residual is None:             # <<<<<<<<<<<<<<
15573  *         residual = np.empty(shape=(nrows, ncols, 2), dtype=ftype)
15574  *
15575  */
15576   __pyx_t_9 = ((((PyObject *) __pyx_v_residual.memview) == Py_None) != 0);
15577   if (__pyx_t_9) {
15578 
15579     /* "dipy/align/sumsqdiff.pyx":707
15580  *         cnp.npy_intp r, c, dr, dc
15581  *     if residual is None:
15582  *         residual = np.empty(shape=(nrows, ncols, 2), dtype=ftype)             # <<<<<<<<<<<<<<
15583  *
15584  *     with nogil:
15585  */
15586     __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 707, __pyx_L1_error)
15587     __Pyx_GOTREF(__pyx_t_3);
15588     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error)
15589     __Pyx_GOTREF(__pyx_t_1);
15590     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15591     __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 707, __pyx_L1_error)
15592     __Pyx_GOTREF(__pyx_t_3);
15593     __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nrows); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error)
15594     __Pyx_GOTREF(__pyx_t_2);
15595     __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_ncols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 707, __pyx_L1_error)
15596     __Pyx_GOTREF(__pyx_t_4);
15597     __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 707, __pyx_L1_error)
15598     __Pyx_GOTREF(__pyx_t_10);
15599     __Pyx_GIVEREF(__pyx_t_2);
15600     PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
15601     __Pyx_GIVEREF(__pyx_t_4);
15602     PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_4);
15603     __Pyx_INCREF(__pyx_int_2);
15604     __Pyx_GIVEREF(__pyx_int_2);
15605     PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_int_2);
15606     __pyx_t_2 = 0;
15607     __pyx_t_4 = 0;
15608     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_shape, __pyx_t_10) < 0) __PYX_ERR(0, 707, __pyx_L1_error)
15609     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
15610     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_ftype) < 0) __PYX_ERR(0, 707, __pyx_L1_error)
15611     __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 707, __pyx_L1_error)
15612     __Pyx_GOTREF(__pyx_t_10);
15613     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15614     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
15615     __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(__pyx_t_10, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 707, __pyx_L1_error)
15616     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
15617     __PYX_XDEC_MEMVIEW(&__pyx_v_residual, 1);
15618     __pyx_v_residual = __pyx_t_11;
15619     __pyx_t_11.memview = NULL;
15620     __pyx_t_11.data = NULL;
15621 
15622     /* "dipy/align/sumsqdiff.pyx":706
15623  *         double delta, sigmasq, dotP
15624  *         cnp.npy_intp r, c, dr, dc
15625  *     if residual is None:             # <<<<<<<<<<<<<<
15626  *         residual = np.empty(shape=(nrows, ncols, 2), dtype=ftype)
15627  *
15628  */
15629   }
15630 
15631   /* "dipy/align/sumsqdiff.pyx":709
15632  *         residual = np.empty(shape=(nrows, ncols, 2), dtype=ftype)
15633  *
15634  *     with nogil:             # <<<<<<<<<<<<<<
15635  *
15636  *         for r in range(nrows):
15637  */
15638   {
15639       #ifdef WITH_THREAD
15640       PyThreadState *_save;
15641       Py_UNBLOCK_THREADS
15642       __Pyx_FastGIL_Remember();
15643       #endif
15644       /*try:*/ {
15645 
15646         /* "dipy/align/sumsqdiff.pyx":711
15647  *     with nogil:
15648  *
15649  *         for r in range(nrows):             # <<<<<<<<<<<<<<
15650  *             for c in range(ncols):
15651  *                 delta = delta_field[r, c]
15652  */
15653         __pyx_t_12 = __pyx_v_nrows;
15654         __pyx_t_13 = __pyx_t_12;
15655         for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
15656           __pyx_v_r = __pyx_t_14;
15657 
15658           /* "dipy/align/sumsqdiff.pyx":712
15659  *
15660  *         for r in range(nrows):
15661  *             for c in range(ncols):             # <<<<<<<<<<<<<<
15662  *                 delta = delta_field[r, c]
15663  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
15664  */
15665           __pyx_t_15 = __pyx_v_ncols;
15666           __pyx_t_16 = __pyx_t_15;
15667           for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
15668             __pyx_v_c = __pyx_t_17;
15669 
15670             /* "dipy/align/sumsqdiff.pyx":713
15671  *         for r in range(nrows):
15672  *             for c in range(ncols):
15673  *                 delta = delta_field[r, c]             # <<<<<<<<<<<<<<
15674  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
15675  *                 if target is None:
15676  */
15677             __pyx_t_18 = __pyx_v_r;
15678             __pyx_t_19 = __pyx_v_c;
15679             __pyx_v_delta = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_18 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_19 * __pyx_v_delta_field.strides[1]) )));
15680 
15681             /* "dipy/align/sumsqdiff.pyx":714
15682  *             for c in range(ncols):
15683  *                 delta = delta_field[r, c]
15684  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1             # <<<<<<<<<<<<<<
15685  *                 if target is None:
15686  *                     b[0] = delta * gradient_field[r, c, 0]
15687  */
15688             if (((((PyObject *) __pyx_v_sigmasq_field.memview) != Py_None) != 0)) {
15689               __pyx_t_19 = __pyx_v_r;
15690               __pyx_t_18 = __pyx_v_c;
15691               __pyx_t_20 = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_sigmasq_field.data + __pyx_t_19 * __pyx_v_sigmasq_field.strides[0]) ) + __pyx_t_18 * __pyx_v_sigmasq_field.strides[1]) )));
15692             } else {
15693               __pyx_t_20 = 1.0;
15694             }
15695             __pyx_v_sigmasq = __pyx_t_20;
15696 
15697             /* "dipy/align/sumsqdiff.pyx":715
15698  *                 delta = delta_field[r, c]
15699  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
15700  *                 if target is None:             # <<<<<<<<<<<<<<
15701  *                     b[0] = delta * gradient_field[r, c, 0]
15702  *                     b[1] = delta * gradient_field[r, c, 1]
15703  */
15704             __pyx_t_9 = ((((PyObject *) __pyx_v_target.memview) == Py_None) != 0);
15705             if (__pyx_t_9) {
15706 
15707               /* "dipy/align/sumsqdiff.pyx":716
15708  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
15709  *                 if target is None:
15710  *                     b[0] = delta * gradient_field[r, c, 0]             # <<<<<<<<<<<<<<
15711  *                     b[1] = delta * gradient_field[r, c, 1]
15712  *                 else:
15713  */
15714               __pyx_t_18 = __pyx_v_r;
15715               __pyx_t_19 = __pyx_v_c;
15716               __pyx_t_21 = 0;
15717               (__pyx_v_b[0]) = (__pyx_v_delta * (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_18 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_19 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_21 * __pyx_v_gradient_field.strides[2]) ))));
15718 
15719               /* "dipy/align/sumsqdiff.pyx":717
15720  *                 if target is None:
15721  *                     b[0] = delta * gradient_field[r, c, 0]
15722  *                     b[1] = delta * gradient_field[r, c, 1]             # <<<<<<<<<<<<<<
15723  *                 else:
15724  *                     b[0] = target[r, c, 0]
15725  */
15726               __pyx_t_21 = __pyx_v_r;
15727               __pyx_t_19 = __pyx_v_c;
15728               __pyx_t_18 = 1;
15729               (__pyx_v_b[1]) = (__pyx_v_delta * (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_21 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_19 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_18 * __pyx_v_gradient_field.strides[2]) ))));
15730 
15731               /* "dipy/align/sumsqdiff.pyx":715
15732  *                 delta = delta_field[r, c]
15733  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
15734  *                 if target is None:             # <<<<<<<<<<<<<<
15735  *                     b[0] = delta * gradient_field[r, c, 0]
15736  *                     b[1] = delta * gradient_field[r, c, 1]
15737  */
15738               goto __pyx_L11;
15739             }
15740 
15741             /* "dipy/align/sumsqdiff.pyx":719
15742  *                     b[1] = delta * gradient_field[r, c, 1]
15743  *                 else:
15744  *                     b[0] = target[r, c, 0]             # <<<<<<<<<<<<<<
15745  *                     b[1] = target[r, c, 1]
15746  *                 y[0] = 0  # reset y
15747  */
15748             /*else*/ {
15749               __pyx_t_18 = __pyx_v_r;
15750               __pyx_t_19 = __pyx_v_c;
15751               __pyx_t_21 = 0;
15752               (__pyx_v_b[0]) = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_18 * __pyx_v_target.strides[0]) ) + __pyx_t_19 * __pyx_v_target.strides[1]) ) + __pyx_t_21 * __pyx_v_target.strides[2]) )));
15753 
15754               /* "dipy/align/sumsqdiff.pyx":720
15755  *                 else:
15756  *                     b[0] = target[r, c, 0]
15757  *                     b[1] = target[r, c, 1]             # <<<<<<<<<<<<<<
15758  *                 y[0] = 0  # reset y
15759  *                 y[1] = 0
15760  */
15761               __pyx_t_21 = __pyx_v_r;
15762               __pyx_t_19 = __pyx_v_c;
15763               __pyx_t_18 = 1;
15764               (__pyx_v_b[1]) = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_21 * __pyx_v_target.strides[0]) ) + __pyx_t_19 * __pyx_v_target.strides[1]) ) + __pyx_t_18 * __pyx_v_target.strides[2]) )));
15765             }
15766             __pyx_L11:;
15767 
15768             /* "dipy/align/sumsqdiff.pyx":721
15769  *                     b[0] = target[r, c, 0]
15770  *                     b[1] = target[r, c, 1]
15771  *                 y[0] = 0  # reset y             # <<<<<<<<<<<<<<
15772  *                 y[1] = 0
15773  *                 nn=0
15774  */
15775             (__pyx_v_y[0]) = 0.0;
15776 
15777             /* "dipy/align/sumsqdiff.pyx":722
15778  *                     b[1] = target[r, c, 1]
15779  *                 y[0] = 0  # reset y
15780  *                 y[1] = 0             # <<<<<<<<<<<<<<
15781  *                 nn=0
15782  *                 for k in range(NUM_NEIGHBORS):
15783  */
15784             (__pyx_v_y[1]) = 0.0;
15785 
15786             /* "dipy/align/sumsqdiff.pyx":723
15787  *                 y[0] = 0  # reset y
15788  *                 y[1] = 0
15789  *                 nn=0             # <<<<<<<<<<<<<<
15790  *                 for k in range(NUM_NEIGHBORS):
15791  *                     dr = r + dRow[k]
15792  */
15793             __pyx_v_nn = 0;
15794 
15795             /* "dipy/align/sumsqdiff.pyx":724
15796  *                 y[1] = 0
15797  *                 nn=0
15798  *                 for k in range(NUM_NEIGHBORS):             # <<<<<<<<<<<<<<
15799  *                     dr = r + dRow[k]
15800  *                     if((dr < 0) or (dr >= nrows)):
15801  */
15802             __pyx_t_22 = __pyx_v_NUM_NEIGHBORS;
15803             __pyx_t_23 = __pyx_t_22;
15804             for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_23; __pyx_t_24+=1) {
15805               __pyx_v_k = __pyx_t_24;
15806 
15807               /* "dipy/align/sumsqdiff.pyx":725
15808  *                 nn=0
15809  *                 for k in range(NUM_NEIGHBORS):
15810  *                     dr = r + dRow[k]             # <<<<<<<<<<<<<<
15811  *                     if((dr < 0) or (dr >= nrows)):
15812  *                         continue
15813  */
15814               __pyx_v_dr = (__pyx_v_r + (__pyx_v_dRow[__pyx_v_k]));
15815 
15816               /* "dipy/align/sumsqdiff.pyx":726
15817  *                 for k in range(NUM_NEIGHBORS):
15818  *                     dr = r + dRow[k]
15819  *                     if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
15820  *                         continue
15821  *                     dc = c + dCol[k]
15822  */
15823               __pyx_t_25 = ((__pyx_v_dr < 0) != 0);
15824               if (!__pyx_t_25) {
15825               } else {
15826                 __pyx_t_9 = __pyx_t_25;
15827                 goto __pyx_L15_bool_binop_done;
15828               }
15829               __pyx_t_25 = ((__pyx_v_dr >= __pyx_v_nrows) != 0);
15830               __pyx_t_9 = __pyx_t_25;
15831               __pyx_L15_bool_binop_done:;
15832               if (__pyx_t_9) {
15833 
15834                 /* "dipy/align/sumsqdiff.pyx":727
15835  *                     dr = r + dRow[k]
15836  *                     if((dr < 0) or (dr >= nrows)):
15837  *                         continue             # <<<<<<<<<<<<<<
15838  *                     dc = c + dCol[k]
15839  *                     if((dc < 0) or (dc >= ncols)):
15840  */
15841                 goto __pyx_L12_continue;
15842 
15843                 /* "dipy/align/sumsqdiff.pyx":726
15844  *                 for k in range(NUM_NEIGHBORS):
15845  *                     dr = r + dRow[k]
15846  *                     if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
15847  *                         continue
15848  *                     dc = c + dCol[k]
15849  */
15850               }
15851 
15852               /* "dipy/align/sumsqdiff.pyx":728
15853  *                     if((dr < 0) or (dr >= nrows)):
15854  *                         continue
15855  *                     dc = c + dCol[k]             # <<<<<<<<<<<<<<
15856  *                     if((dc < 0) or (dc >= ncols)):
15857  *                         continue
15858  */
15859               __pyx_v_dc = (__pyx_v_c + (__pyx_v_dCol[__pyx_v_k]));
15860 
15861               /* "dipy/align/sumsqdiff.pyx":729
15862  *                         continue
15863  *                     dc = c + dCol[k]
15864  *                     if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
15865  *                         continue
15866  *                     y[0] += (d[r, c, 0] - d[dr, dc, 0])
15867  */
15868               __pyx_t_25 = ((__pyx_v_dc < 0) != 0);
15869               if (!__pyx_t_25) {
15870               } else {
15871                 __pyx_t_9 = __pyx_t_25;
15872                 goto __pyx_L18_bool_binop_done;
15873               }
15874               __pyx_t_25 = ((__pyx_v_dc >= __pyx_v_ncols) != 0);
15875               __pyx_t_9 = __pyx_t_25;
15876               __pyx_L18_bool_binop_done:;
15877               if (__pyx_t_9) {
15878 
15879                 /* "dipy/align/sumsqdiff.pyx":730
15880  *                     dc = c + dCol[k]
15881  *                     if((dc < 0) or (dc >= ncols)):
15882  *                         continue             # <<<<<<<<<<<<<<
15883  *                     y[0] += (d[r, c, 0] - d[dr, dc, 0])
15884  *                     y[1] += (d[r, c, 1] - d[dr, dc, 1])
15885  */
15886                 goto __pyx_L12_continue;
15887 
15888                 /* "dipy/align/sumsqdiff.pyx":729
15889  *                         continue
15890  *                     dc = c + dCol[k]
15891  *                     if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
15892  *                         continue
15893  *                     y[0] += (d[r, c, 0] - d[dr, dc, 0])
15894  */
15895               }
15896 
15897               /* "dipy/align/sumsqdiff.pyx":731
15898  *                     if((dc < 0) or (dc >= ncols)):
15899  *                         continue
15900  *                     y[0] += (d[r, c, 0] - d[dr, dc, 0])             # <<<<<<<<<<<<<<
15901  *                     y[1] += (d[r, c, 1] - d[dr, dc, 1])
15902  *
15903  */
15904               __pyx_t_26 = 0;
15905               __pyx_t_18 = __pyx_v_r;
15906               __pyx_t_19 = __pyx_v_c;
15907               __pyx_t_21 = 0;
15908               __pyx_t_27 = __pyx_v_dr;
15909               __pyx_t_28 = __pyx_v_dc;
15910               __pyx_t_29 = 0;
15911               (__pyx_v_y[__pyx_t_26]) = ((__pyx_v_y[__pyx_t_26]) + ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_18 * __pyx_v_d.strides[0]) ) + __pyx_t_19 * __pyx_v_d.strides[1]) ) + __pyx_t_21 * __pyx_v_d.strides[2]) ))) - (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_27 * __pyx_v_d.strides[0]) ) + __pyx_t_28 * __pyx_v_d.strides[1]) ) + __pyx_t_29 * __pyx_v_d.strides[2]) )))));
15912 
15913               /* "dipy/align/sumsqdiff.pyx":732
15914  *                         continue
15915  *                     y[0] += (d[r, c, 0] - d[dr, dc, 0])
15916  *                     y[1] += (d[r, c, 1] - d[dr, dc, 1])             # <<<<<<<<<<<<<<
15917  *
15918  *                 if dpy_isinf(sigmasq) != 0:
15919  */
15920               __pyx_t_26 = 1;
15921               __pyx_t_29 = __pyx_v_r;
15922               __pyx_t_28 = __pyx_v_c;
15923               __pyx_t_27 = 1;
15924               __pyx_t_21 = __pyx_v_dr;
15925               __pyx_t_19 = __pyx_v_dc;
15926               __pyx_t_18 = 1;
15927               (__pyx_v_y[__pyx_t_26]) = ((__pyx_v_y[__pyx_t_26]) + ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_29 * __pyx_v_d.strides[0]) ) + __pyx_t_28 * __pyx_v_d.strides[1]) ) + __pyx_t_27 * __pyx_v_d.strides[2]) ))) - (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_21 * __pyx_v_d.strides[0]) ) + __pyx_t_19 * __pyx_v_d.strides[1]) ) + __pyx_t_18 * __pyx_v_d.strides[2]) )))));
15928               __pyx_L12_continue:;
15929             }
15930 
15931             /* "dipy/align/sumsqdiff.pyx":734
15932  *                     y[1] += (d[r, c, 1] - d[dr, dc, 1])
15933  *
15934  *                 if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
15935  *                     residual[r, c, 0] = -lambda_param * y[0]
15936  *                     residual[r, c, 1] = -lambda_param * y[1]
15937  */
15938             __pyx_t_9 = ((dpy_isinf(__pyx_v_sigmasq) != 0) != 0);
15939             if (__pyx_t_9) {
15940 
15941               /* "dipy/align/sumsqdiff.pyx":735
15942  *
15943  *                 if dpy_isinf(sigmasq) != 0:
15944  *                     residual[r, c, 0] = -lambda_param * y[0]             # <<<<<<<<<<<<<<
15945  *                     residual[r, c, 1] = -lambda_param * y[1]
15946  *                 else:
15947  */
15948               __pyx_t_18 = __pyx_v_r;
15949               __pyx_t_19 = __pyx_v_c;
15950               __pyx_t_21 = 0;
15951               *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_18 * __pyx_v_residual.strides[0]) ) + __pyx_t_19 * __pyx_v_residual.strides[1]) ) + __pyx_t_21 * __pyx_v_residual.strides[2]) )) = ((-__pyx_v_lambda_param) * (__pyx_v_y[0]));
15952 
15953               /* "dipy/align/sumsqdiff.pyx":736
15954  *                 if dpy_isinf(sigmasq) != 0:
15955  *                     residual[r, c, 0] = -lambda_param * y[0]
15956  *                     residual[r, c, 1] = -lambda_param * y[1]             # <<<<<<<<<<<<<<
15957  *                 else:
15958  *                     dotP = (gradient_field[r, c, 0] * d[r, c, 0] +
15959  */
15960               __pyx_t_21 = __pyx_v_r;
15961               __pyx_t_19 = __pyx_v_c;
15962               __pyx_t_18 = 1;
15963               *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_21 * __pyx_v_residual.strides[0]) ) + __pyx_t_19 * __pyx_v_residual.strides[1]) ) + __pyx_t_18 * __pyx_v_residual.strides[2]) )) = ((-__pyx_v_lambda_param) * (__pyx_v_y[1]));
15964 
15965               /* "dipy/align/sumsqdiff.pyx":734
15966  *                     y[1] += (d[r, c, 1] - d[dr, dc, 1])
15967  *
15968  *                 if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
15969  *                     residual[r, c, 0] = -lambda_param * y[0]
15970  *                     residual[r, c, 1] = -lambda_param * y[1]
15971  */
15972               goto __pyx_L20;
15973             }
15974 
15975             /* "dipy/align/sumsqdiff.pyx":738
15976  *                     residual[r, c, 1] = -lambda_param * y[1]
15977  *                 else:
15978  *                     dotP = (gradient_field[r, c, 0] * d[r, c, 0] +             # <<<<<<<<<<<<<<
15979  *                             gradient_field[r, c, 1] * d[r, c, 1])
15980  *                     residual[r, c, 0] = (b[0] -
15981  */
15982             /*else*/ {
15983               __pyx_t_18 = __pyx_v_r;
15984               __pyx_t_19 = __pyx_v_c;
15985               __pyx_t_21 = 0;
15986               __pyx_t_27 = __pyx_v_r;
15987               __pyx_t_28 = __pyx_v_c;
15988               __pyx_t_29 = 0;
15989 
15990               /* "dipy/align/sumsqdiff.pyx":739
15991  *                 else:
15992  *                     dotP = (gradient_field[r, c, 0] * d[r, c, 0] +
15993  *                             gradient_field[r, c, 1] * d[r, c, 1])             # <<<<<<<<<<<<<<
15994  *                     residual[r, c, 0] = (b[0] -
15995  *                                          (gradient_field[r, c, 0] * dotP +
15996  */
15997               __pyx_t_30 = __pyx_v_r;
15998               __pyx_t_31 = __pyx_v_c;
15999               __pyx_t_32 = 1;
16000               __pyx_t_33 = __pyx_v_r;
16001               __pyx_t_34 = __pyx_v_c;
16002               __pyx_t_35 = 1;
16003 
16004               /* "dipy/align/sumsqdiff.pyx":738
16005  *                     residual[r, c, 1] = -lambda_param * y[1]
16006  *                 else:
16007  *                     dotP = (gradient_field[r, c, 0] * d[r, c, 0] +             # <<<<<<<<<<<<<<
16008  *                             gradient_field[r, c, 1] * d[r, c, 1])
16009  *                     residual[r, c, 0] = (b[0] -
16010  */
16011               __pyx_v_dotP = (((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_18 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_19 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_21 * __pyx_v_gradient_field.strides[2]) ))) * (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_27 * __pyx_v_d.strides[0]) ) + __pyx_t_28 * __pyx_v_d.strides[1]) ) + __pyx_t_29 * __pyx_v_d.strides[2]) )))) + ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_30 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_31 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_32 * __pyx_v_gradient_field.strides[2]) ))) * (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_33 * __pyx_v_d.strides[0]) ) + __pyx_t_34 * __pyx_v_d.strides[1]) ) + __pyx_t_35 * __pyx_v_d.strides[2]) )))));
16012 
16013               /* "dipy/align/sumsqdiff.pyx":741
16014  *                             gradient_field[r, c, 1] * d[r, c, 1])
16015  *                     residual[r, c, 0] = (b[0] -
16016  *                                          (gradient_field[r, c, 0] * dotP +             # <<<<<<<<<<<<<<
16017  *                                           sigmasq * lambda_param * y[0]))
16018  *                     residual[r, c, 1] = (b[1] -
16019  */
16020               __pyx_t_35 = __pyx_v_r;
16021               __pyx_t_34 = __pyx_v_c;
16022               __pyx_t_33 = 0;
16023 
16024               /* "dipy/align/sumsqdiff.pyx":740
16025  *                     dotP = (gradient_field[r, c, 0] * d[r, c, 0] +
16026  *                             gradient_field[r, c, 1] * d[r, c, 1])
16027  *                     residual[r, c, 0] = (b[0] -             # <<<<<<<<<<<<<<
16028  *                                          (gradient_field[r, c, 0] * dotP +
16029  *                                           sigmasq * lambda_param * y[0]))
16030  */
16031               __pyx_t_32 = __pyx_v_r;
16032               __pyx_t_31 = __pyx_v_c;
16033               __pyx_t_30 = 0;
16034               *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_32 * __pyx_v_residual.strides[0]) ) + __pyx_t_31 * __pyx_v_residual.strides[1]) ) + __pyx_t_30 * __pyx_v_residual.strides[2]) )) = ((__pyx_v_b[0]) - (((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_35 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_34 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_33 * __pyx_v_gradient_field.strides[2]) ))) * __pyx_v_dotP) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[0]))));
16035 
16036               /* "dipy/align/sumsqdiff.pyx":744
16037  *                                           sigmasq * lambda_param * y[0]))
16038  *                     residual[r, c, 1] = (b[1] -
16039  *                                          (gradient_field[r, c, 1] * dotP +             # <<<<<<<<<<<<<<
16040  *                                           sigmasq * lambda_param * y[1]))
16041  *     return np.asarray(residual)
16042  */
16043               __pyx_t_33 = __pyx_v_r;
16044               __pyx_t_34 = __pyx_v_c;
16045               __pyx_t_35 = 1;
16046 
16047               /* "dipy/align/sumsqdiff.pyx":743
16048  *                                          (gradient_field[r, c, 0] * dotP +
16049  *                                           sigmasq * lambda_param * y[0]))
16050  *                     residual[r, c, 1] = (b[1] -             # <<<<<<<<<<<<<<
16051  *                                          (gradient_field[r, c, 1] * dotP +
16052  *                                           sigmasq * lambda_param * y[1]))
16053  */
16054               __pyx_t_30 = __pyx_v_r;
16055               __pyx_t_31 = __pyx_v_c;
16056               __pyx_t_32 = 1;
16057               *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_30 * __pyx_v_residual.strides[0]) ) + __pyx_t_31 * __pyx_v_residual.strides[1]) ) + __pyx_t_32 * __pyx_v_residual.strides[2]) )) = ((__pyx_v_b[1]) - (((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_33 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_34 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_35 * __pyx_v_gradient_field.strides[2]) ))) * __pyx_v_dotP) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[1]))));
16058             }
16059             __pyx_L20:;
16060           }
16061         }
16062       }
16063 
16064       /* "dipy/align/sumsqdiff.pyx":709
16065  *         residual = np.empty(shape=(nrows, ncols, 2), dtype=ftype)
16066  *
16067  *     with nogil:             # <<<<<<<<<<<<<<
16068  *
16069  *         for r in range(nrows):
16070  */
16071       /*finally:*/ {
16072         /*normal exit:*/{
16073           #ifdef WITH_THREAD
16074           __Pyx_FastGIL_Forget();
16075           Py_BLOCK_THREADS
16076           #endif
16077           goto __pyx_L6;
16078         }
16079         __pyx_L6:;
16080       }
16081   }
16082 
16083   /* "dipy/align/sumsqdiff.pyx":746
16084  *                                          (gradient_field[r, c, 1] * dotP +
16085  *                                           sigmasq * lambda_param * y[1]))
16086  *     return np.asarray(residual)             # <<<<<<<<<<<<<<
16087  *
16088  *
16089  */
16090   __Pyx_XDECREF(__pyx_r);
16091   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 746, __pyx_L1_error)
16092   __Pyx_GOTREF(__pyx_t_3);
16093   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 746, __pyx_L1_error)
16094   __Pyx_GOTREF(__pyx_t_1);
16095   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16096   __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_residual, 3, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 746, __pyx_L1_error)
16097   __Pyx_GOTREF(__pyx_t_3);
16098   __pyx_t_4 = NULL;
16099   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
16100     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
16101     if (likely(__pyx_t_4)) {
16102       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
16103       __Pyx_INCREF(__pyx_t_4);
16104       __Pyx_INCREF(function);
16105       __Pyx_DECREF_SET(__pyx_t_1, function);
16106     }
16107   }
16108   __pyx_t_10 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
16109   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
16110   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16111   if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 746, __pyx_L1_error)
16112   __Pyx_GOTREF(__pyx_t_10);
16113   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16114   __pyx_r = __pyx_t_10;
16115   __pyx_t_10 = 0;
16116   goto __pyx_L0;
16117 
16118   /* "dipy/align/sumsqdiff.pyx":649
16119  * @cython.boundscheck(False)
16120  * @cython.wraparound(False)
16121  * cpdef compute_residual_displacement_field_ssd_2d(             # <<<<<<<<<<<<<<
16122  *         floating[:, :] delta_field, floating[:, :] sigmasq_field,
16123  *         floating[:, :, :] gradient_field, floating[:, :, :] target,
16124  */
16125 
16126   /* function exit code */
16127   __pyx_L1_error:;
16128   __Pyx_XDECREF(__pyx_t_1);
16129   __Pyx_XDECREF(__pyx_t_2);
16130   __Pyx_XDECREF(__pyx_t_3);
16131   __Pyx_XDECREF(__pyx_t_4);
16132   __Pyx_XDECREF(__pyx_t_10);
16133   __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
16134   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
16135   __pyx_r = 0;
16136   __pyx_L0:;
16137   __Pyx_XDECREF(__pyx_v_ftype);
16138   __PYX_XDEC_MEMVIEW(&__pyx_v_residual, 1);
16139   __Pyx_XGIVEREF(__pyx_r);
16140   __Pyx_RefNannyFinishContext();
16141   return __pyx_r;
16142 }
16143 
16144 /* Python wrapper */
16145 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_51__pyx_fuse_0compute_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
16146 static PyMethodDef __pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_51__pyx_fuse_0compute_residual_displacement_field_ssd_2d = {"__pyx_fuse_0compute_residual_displacement_field_ssd_2d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_51__pyx_fuse_0compute_residual_displacement_field_ssd_2d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_14compute_residual_displacement_field_ssd_2d};
__pyx_pw_4dipy_5align_9sumsqdiff_51__pyx_fuse_0compute_residual_displacement_field_ssd_2d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)16147 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_51__pyx_fuse_0compute_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
16148   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
16149   __Pyx_memviewslice __pyx_v_sigmasq_field = { 0, 0, { 0 }, { 0 }, { 0 } };
16150   __Pyx_memviewslice __pyx_v_gradient_field = { 0, 0, { 0 }, { 0 }, { 0 } };
16151   __Pyx_memviewslice __pyx_v_target = { 0, 0, { 0 }, { 0 }, { 0 } };
16152   double __pyx_v_lambda_param;
16153   __Pyx_memviewslice __pyx_v_d = { 0, 0, { 0 }, { 0 }, { 0 } };
16154   __Pyx_memviewslice __pyx_v_residual = { 0, 0, { 0 }, { 0 }, { 0 } };
16155   int __pyx_lineno = 0;
16156   const char *__pyx_filename = NULL;
16157   int __pyx_clineno = 0;
16158   PyObject *__pyx_r = 0;
16159   __Pyx_RefNannyDeclarations
16160   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_residual_displacement_field_ssd_2d (wrapper)", 0);
16161   {
16162     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_sigmasq_field,&__pyx_n_s_gradient_field,&__pyx_n_s_target,&__pyx_n_s_lambda_param,&__pyx_n_s_d,&__pyx_n_s_residual,0};
16163     PyObject* values[7] = {0,0,0,0,0,0,0};
16164     if (unlikely(__pyx_kwds)) {
16165       Py_ssize_t kw_args;
16166       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
16167       switch (pos_args) {
16168         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
16169         CYTHON_FALLTHROUGH;
16170         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
16171         CYTHON_FALLTHROUGH;
16172         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
16173         CYTHON_FALLTHROUGH;
16174         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
16175         CYTHON_FALLTHROUGH;
16176         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
16177         CYTHON_FALLTHROUGH;
16178         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
16179         CYTHON_FALLTHROUGH;
16180         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
16181         CYTHON_FALLTHROUGH;
16182         case  0: break;
16183         default: goto __pyx_L5_argtuple_error;
16184       }
16185       kw_args = PyDict_Size(__pyx_kwds);
16186       switch (pos_args) {
16187         case  0:
16188         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
16189         else goto __pyx_L5_argtuple_error;
16190         CYTHON_FALLTHROUGH;
16191         case  1:
16192         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigmasq_field)) != 0)) kw_args--;
16193         else {
16194           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0compute_residual_displacement_field_ssd_2d", 1, 7, 7, 1); __PYX_ERR(0, 649, __pyx_L3_error)
16195         }
16196         CYTHON_FALLTHROUGH;
16197         case  2:
16198         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gradient_field)) != 0)) kw_args--;
16199         else {
16200           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0compute_residual_displacement_field_ssd_2d", 1, 7, 7, 2); __PYX_ERR(0, 649, __pyx_L3_error)
16201         }
16202         CYTHON_FALLTHROUGH;
16203         case  3:
16204         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--;
16205         else {
16206           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0compute_residual_displacement_field_ssd_2d", 1, 7, 7, 3); __PYX_ERR(0, 649, __pyx_L3_error)
16207         }
16208         CYTHON_FALLTHROUGH;
16209         case  4:
16210         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lambda_param)) != 0)) kw_args--;
16211         else {
16212           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0compute_residual_displacement_field_ssd_2d", 1, 7, 7, 4); __PYX_ERR(0, 649, __pyx_L3_error)
16213         }
16214         CYTHON_FALLTHROUGH;
16215         case  5:
16216         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_d)) != 0)) kw_args--;
16217         else {
16218           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0compute_residual_displacement_field_ssd_2d", 1, 7, 7, 5); __PYX_ERR(0, 649, __pyx_L3_error)
16219         }
16220         CYTHON_FALLTHROUGH;
16221         case  6:
16222         if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_residual)) != 0)) kw_args--;
16223         else {
16224           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0compute_residual_displacement_field_ssd_2d", 1, 7, 7, 6); __PYX_ERR(0, 649, __pyx_L3_error)
16225         }
16226       }
16227       if (unlikely(kw_args > 0)) {
16228         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fuse_0compute_residual_displacement_field_ssd_2d") < 0)) __PYX_ERR(0, 649, __pyx_L3_error)
16229       }
16230     } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
16231       goto __pyx_L5_argtuple_error;
16232     } else {
16233       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
16234       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
16235       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
16236       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
16237       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
16238       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
16239       values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
16240     }
16241     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 650, __pyx_L3_error)
16242     __pyx_v_sigmasq_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_sigmasq_field.memview)) __PYX_ERR(0, 650, __pyx_L3_error)
16243     __pyx_v_gradient_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_gradient_field.memview)) __PYX_ERR(0, 651, __pyx_L3_error)
16244     __pyx_v_target = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_target.memview)) __PYX_ERR(0, 651, __pyx_L3_error)
16245     __pyx_v_lambda_param = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_lambda_param == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 652, __pyx_L3_error)
16246     __pyx_v_d = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_d.memview)) __PYX_ERR(0, 652, __pyx_L3_error)
16247     __pyx_v_residual = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[6], PyBUF_WRITABLE); if (unlikely(!__pyx_v_residual.memview)) __PYX_ERR(0, 653, __pyx_L3_error)
16248   }
16249   goto __pyx_L4_argument_unpacking_done;
16250   __pyx_L5_argtuple_error:;
16251   __Pyx_RaiseArgtupleInvalid("__pyx_fuse_0compute_residual_displacement_field_ssd_2d", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 649, __pyx_L3_error)
16252   __pyx_L3_error:;
16253   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_0compute_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
16254   __Pyx_RefNannyFinishContext();
16255   return NULL;
16256   __pyx_L4_argument_unpacking_done:;
16257   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_50__pyx_fuse_0compute_residual_displacement_field_ssd_2d(__pyx_self, __pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_gradient_field, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_d, __pyx_v_residual);
16258 
16259   /* function exit code */
16260   __Pyx_RefNannyFinishContext();
16261   return __pyx_r;
16262 }
16263 
__pyx_pf_4dipy_5align_9sumsqdiff_50__pyx_fuse_0compute_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_gradient_field,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_d,__Pyx_memviewslice __pyx_v_residual)16264 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_50__pyx_fuse_0compute_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_gradient_field, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_d, __Pyx_memviewslice __pyx_v_residual) {
16265   PyObject *__pyx_r = NULL;
16266   __Pyx_RefNannyDeclarations
16267   PyObject *__pyx_t_1 = NULL;
16268   int __pyx_lineno = 0;
16269   const char *__pyx_filename = NULL;
16270   int __pyx_clineno = 0;
16271   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_residual_displacement_field_ssd_2d", 0);
16272   __Pyx_XDECREF(__pyx_r);
16273   if (unlikely(!__pyx_v_delta_field.memview)) { __Pyx_RaiseUnboundLocalError("delta_field"); __PYX_ERR(0, 649, __pyx_L1_error) }
16274   if (unlikely(!__pyx_v_sigmasq_field.memview)) { __Pyx_RaiseUnboundLocalError("sigmasq_field"); __PYX_ERR(0, 649, __pyx_L1_error) }
16275   if (unlikely(!__pyx_v_gradient_field.memview)) { __Pyx_RaiseUnboundLocalError("gradient_field"); __PYX_ERR(0, 649, __pyx_L1_error) }
16276   if (unlikely(!__pyx_v_target.memview)) { __Pyx_RaiseUnboundLocalError("target"); __PYX_ERR(0, 649, __pyx_L1_error) }
16277   if (unlikely(!__pyx_v_d.memview)) { __Pyx_RaiseUnboundLocalError("d"); __PYX_ERR(0, 649, __pyx_L1_error) }
16278   if (unlikely(!__pyx_v_residual.memview)) { __Pyx_RaiseUnboundLocalError("residual"); __PYX_ERR(0, 649, __pyx_L1_error) }
16279   __pyx_t_1 = __pyx_fuse_0__pyx_f_4dipy_5align_9sumsqdiff_compute_residual_displacement_field_ssd_2d(__pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_gradient_field, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_d, __pyx_v_residual, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
16280   __Pyx_GOTREF(__pyx_t_1);
16281   __pyx_r = __pyx_t_1;
16282   __pyx_t_1 = 0;
16283   goto __pyx_L0;
16284 
16285   /* function exit code */
16286   __pyx_L1_error:;
16287   __Pyx_XDECREF(__pyx_t_1);
16288   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_0compute_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
16289   __pyx_r = NULL;
16290   __pyx_L0:;
16291   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
16292   __PYX_XDEC_MEMVIEW(&__pyx_v_sigmasq_field, 1);
16293   __PYX_XDEC_MEMVIEW(&__pyx_v_gradient_field, 1);
16294   __PYX_XDEC_MEMVIEW(&__pyx_v_target, 1);
16295   __PYX_XDEC_MEMVIEW(&__pyx_v_d, 1);
16296   __PYX_XDEC_MEMVIEW(&__pyx_v_residual, 1);
16297   __Pyx_XGIVEREF(__pyx_r);
16298   __Pyx_RefNannyFinishContext();
16299   return __pyx_r;
16300 }
16301 
16302 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_53__pyx_fuse_1compute_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
16303 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_15compute_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
__pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_residual_displacement_field_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_gradient_field,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_d,__Pyx_memviewslice __pyx_v_residual,CYTHON_UNUSED int __pyx_skip_dispatch)16304 static PyObject *__pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_residual_displacement_field_ssd_2d(__Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_gradient_field, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_d, __Pyx_memviewslice __pyx_v_residual, CYTHON_UNUSED int __pyx_skip_dispatch) {
16305   PyObject *__pyx_v_ftype = NULL;
16306   int __pyx_v_NUM_NEIGHBORS;
16307   int *__pyx_v_dRow;
16308   int *__pyx_v_dCol;
16309   double *__pyx_v_b;
16310   double *__pyx_v_y;
16311   npy_intp __pyx_v_nrows;
16312   npy_intp __pyx_v_ncols;
16313   double __pyx_v_delta;
16314   double __pyx_v_sigmasq;
16315   double __pyx_v_dotP;
16316   npy_intp __pyx_v_r;
16317   npy_intp __pyx_v_c;
16318   npy_intp __pyx_v_dr;
16319   npy_intp __pyx_v_dc;
16320   CYTHON_UNUSED long __pyx_v_nn;
16321   int __pyx_v_k;
16322   PyObject *__pyx_r = NULL;
16323   __Pyx_RefNannyDeclarations
16324   PyObject *__pyx_t_1 = NULL;
16325   PyObject *__pyx_t_2 = NULL;
16326   PyObject *__pyx_t_3 = NULL;
16327   PyObject *__pyx_t_4 = NULL;
16328   int __pyx_t_5[4];
16329   int __pyx_t_6[4];
16330   double __pyx_t_7[2];
16331   double __pyx_t_8[2];
16332   int __pyx_t_9;
16333   PyObject *__pyx_t_10 = NULL;
16334   __Pyx_memviewslice __pyx_t_11 = { 0, 0, { 0 }, { 0 }, { 0 } };
16335   npy_intp __pyx_t_12;
16336   npy_intp __pyx_t_13;
16337   npy_intp __pyx_t_14;
16338   npy_intp __pyx_t_15;
16339   npy_intp __pyx_t_16;
16340   npy_intp __pyx_t_17;
16341   Py_ssize_t __pyx_t_18;
16342   Py_ssize_t __pyx_t_19;
16343   double __pyx_t_20;
16344   Py_ssize_t __pyx_t_21;
16345   int __pyx_t_22;
16346   int __pyx_t_23;
16347   int __pyx_t_24;
16348   int __pyx_t_25;
16349   long __pyx_t_26;
16350   Py_ssize_t __pyx_t_27;
16351   Py_ssize_t __pyx_t_28;
16352   Py_ssize_t __pyx_t_29;
16353   Py_ssize_t __pyx_t_30;
16354   Py_ssize_t __pyx_t_31;
16355   Py_ssize_t __pyx_t_32;
16356   Py_ssize_t __pyx_t_33;
16357   Py_ssize_t __pyx_t_34;
16358   Py_ssize_t __pyx_t_35;
16359   int __pyx_lineno = 0;
16360   const char *__pyx_filename = NULL;
16361   int __pyx_clineno = 0;
16362   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_residual_displacement_field_ssd_2d", 0);
16363   __PYX_INC_MEMVIEW(&__pyx_v_residual, 1);
16364 
16365   /* "dipy/align/sumsqdiff.pyx":694
16366  *               Vision, 2005. ICCV 2005.
16367  *     """
16368  *     ftype = np.asarray(delta_field).dtype             # <<<<<<<<<<<<<<
16369  *     cdef:
16370  *         int NUM_NEIGHBORS = 4
16371  */
16372   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __pyx_L1_error)
16373   __Pyx_GOTREF(__pyx_t_2);
16374   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 694, __pyx_L1_error)
16375   __Pyx_GOTREF(__pyx_t_3);
16376   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16377   __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __pyx_L1_error)
16378   __Pyx_GOTREF(__pyx_t_2);
16379   __pyx_t_4 = NULL;
16380   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
16381     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
16382     if (likely(__pyx_t_4)) {
16383       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
16384       __Pyx_INCREF(__pyx_t_4);
16385       __Pyx_INCREF(function);
16386       __Pyx_DECREF_SET(__pyx_t_3, function);
16387     }
16388   }
16389   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
16390   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
16391   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16392   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 694, __pyx_L1_error)
16393   __Pyx_GOTREF(__pyx_t_1);
16394   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16395   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 694, __pyx_L1_error)
16396   __Pyx_GOTREF(__pyx_t_3);
16397   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16398   __pyx_v_ftype = __pyx_t_3;
16399   __pyx_t_3 = 0;
16400 
16401   /* "dipy/align/sumsqdiff.pyx":696
16402  *     ftype = np.asarray(delta_field).dtype
16403  *     cdef:
16404  *         int NUM_NEIGHBORS = 4             # <<<<<<<<<<<<<<
16405  *         int* dRow = [-1, 0, 1,  0]
16406  *         int* dCol = [0, 1, 0, -1]
16407  */
16408   __pyx_v_NUM_NEIGHBORS = 4;
16409 
16410   /* "dipy/align/sumsqdiff.pyx":697
16411  *     cdef:
16412  *         int NUM_NEIGHBORS = 4
16413  *         int* dRow = [-1, 0, 1,  0]             # <<<<<<<<<<<<<<
16414  *         int* dCol = [0, 1, 0, -1]
16415  *         double* b = [0, 0]
16416  */
16417   __pyx_t_5[0] = -1;
16418   __pyx_t_5[1] = 0;
16419   __pyx_t_5[2] = 1;
16420   __pyx_t_5[3] = 0;
16421   __pyx_v_dRow = __pyx_t_5;
16422 
16423   /* "dipy/align/sumsqdiff.pyx":698
16424  *         int NUM_NEIGHBORS = 4
16425  *         int* dRow = [-1, 0, 1,  0]
16426  *         int* dCol = [0, 1, 0, -1]             # <<<<<<<<<<<<<<
16427  *         double* b = [0, 0]
16428  *         double* y = [0, 0]
16429  */
16430   __pyx_t_6[0] = 0;
16431   __pyx_t_6[1] = 1;
16432   __pyx_t_6[2] = 0;
16433   __pyx_t_6[3] = -1;
16434   __pyx_v_dCol = __pyx_t_6;
16435 
16436   /* "dipy/align/sumsqdiff.pyx":699
16437  *         int* dRow = [-1, 0, 1,  0]
16438  *         int* dCol = [0, 1, 0, -1]
16439  *         double* b = [0, 0]             # <<<<<<<<<<<<<<
16440  *         double* y = [0, 0]
16441  *
16442  */
16443   __pyx_t_7[0] = 0.0;
16444   __pyx_t_7[1] = 0.0;
16445   __pyx_v_b = __pyx_t_7;
16446 
16447   /* "dipy/align/sumsqdiff.pyx":700
16448  *         int* dCol = [0, 1, 0, -1]
16449  *         double* b = [0, 0]
16450  *         double* y = [0, 0]             # <<<<<<<<<<<<<<
16451  *
16452  *         cnp.npy_intp nrows = delta_field.shape[0]
16453  */
16454   __pyx_t_8[0] = 0.0;
16455   __pyx_t_8[1] = 0.0;
16456   __pyx_v_y = __pyx_t_8;
16457 
16458   /* "dipy/align/sumsqdiff.pyx":702
16459  *         double* y = [0, 0]
16460  *
16461  *         cnp.npy_intp nrows = delta_field.shape[0]             # <<<<<<<<<<<<<<
16462  *         cnp.npy_intp ncols = delta_field.shape[1]
16463  *         double delta, sigmasq, dotP
16464  */
16465   __pyx_v_nrows = (__pyx_v_delta_field.shape[0]);
16466 
16467   /* "dipy/align/sumsqdiff.pyx":703
16468  *
16469  *         cnp.npy_intp nrows = delta_field.shape[0]
16470  *         cnp.npy_intp ncols = delta_field.shape[1]             # <<<<<<<<<<<<<<
16471  *         double delta, sigmasq, dotP
16472  *         cnp.npy_intp r, c, dr, dc
16473  */
16474   __pyx_v_ncols = (__pyx_v_delta_field.shape[1]);
16475 
16476   /* "dipy/align/sumsqdiff.pyx":706
16477  *         double delta, sigmasq, dotP
16478  *         cnp.npy_intp r, c, dr, dc
16479  *     if residual is None:             # <<<<<<<<<<<<<<
16480  *         residual = np.empty(shape=(nrows, ncols, 2), dtype=ftype)
16481  *
16482  */
16483   __pyx_t_9 = ((((PyObject *) __pyx_v_residual.memview) == Py_None) != 0);
16484   if (__pyx_t_9) {
16485 
16486     /* "dipy/align/sumsqdiff.pyx":707
16487  *         cnp.npy_intp r, c, dr, dc
16488  *     if residual is None:
16489  *         residual = np.empty(shape=(nrows, ncols, 2), dtype=ftype)             # <<<<<<<<<<<<<<
16490  *
16491  *     with nogil:
16492  */
16493     __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 707, __pyx_L1_error)
16494     __Pyx_GOTREF(__pyx_t_3);
16495     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error)
16496     __Pyx_GOTREF(__pyx_t_1);
16497     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16498     __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 707, __pyx_L1_error)
16499     __Pyx_GOTREF(__pyx_t_3);
16500     __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nrows); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error)
16501     __Pyx_GOTREF(__pyx_t_2);
16502     __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_ncols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 707, __pyx_L1_error)
16503     __Pyx_GOTREF(__pyx_t_4);
16504     __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 707, __pyx_L1_error)
16505     __Pyx_GOTREF(__pyx_t_10);
16506     __Pyx_GIVEREF(__pyx_t_2);
16507     PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
16508     __Pyx_GIVEREF(__pyx_t_4);
16509     PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_4);
16510     __Pyx_INCREF(__pyx_int_2);
16511     __Pyx_GIVEREF(__pyx_int_2);
16512     PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_int_2);
16513     __pyx_t_2 = 0;
16514     __pyx_t_4 = 0;
16515     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_shape, __pyx_t_10) < 0) __PYX_ERR(0, 707, __pyx_L1_error)
16516     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
16517     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_v_ftype) < 0) __PYX_ERR(0, 707, __pyx_L1_error)
16518     __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 707, __pyx_L1_error)
16519     __Pyx_GOTREF(__pyx_t_10);
16520     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16521     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16522     __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(__pyx_t_10, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 707, __pyx_L1_error)
16523     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
16524     __PYX_XDEC_MEMVIEW(&__pyx_v_residual, 1);
16525     __pyx_v_residual = __pyx_t_11;
16526     __pyx_t_11.memview = NULL;
16527     __pyx_t_11.data = NULL;
16528 
16529     /* "dipy/align/sumsqdiff.pyx":706
16530  *         double delta, sigmasq, dotP
16531  *         cnp.npy_intp r, c, dr, dc
16532  *     if residual is None:             # <<<<<<<<<<<<<<
16533  *         residual = np.empty(shape=(nrows, ncols, 2), dtype=ftype)
16534  *
16535  */
16536   }
16537 
16538   /* "dipy/align/sumsqdiff.pyx":709
16539  *         residual = np.empty(shape=(nrows, ncols, 2), dtype=ftype)
16540  *
16541  *     with nogil:             # <<<<<<<<<<<<<<
16542  *
16543  *         for r in range(nrows):
16544  */
16545   {
16546       #ifdef WITH_THREAD
16547       PyThreadState *_save;
16548       Py_UNBLOCK_THREADS
16549       __Pyx_FastGIL_Remember();
16550       #endif
16551       /*try:*/ {
16552 
16553         /* "dipy/align/sumsqdiff.pyx":711
16554  *     with nogil:
16555  *
16556  *         for r in range(nrows):             # <<<<<<<<<<<<<<
16557  *             for c in range(ncols):
16558  *                 delta = delta_field[r, c]
16559  */
16560         __pyx_t_12 = __pyx_v_nrows;
16561         __pyx_t_13 = __pyx_t_12;
16562         for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
16563           __pyx_v_r = __pyx_t_14;
16564 
16565           /* "dipy/align/sumsqdiff.pyx":712
16566  *
16567  *         for r in range(nrows):
16568  *             for c in range(ncols):             # <<<<<<<<<<<<<<
16569  *                 delta = delta_field[r, c]
16570  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
16571  */
16572           __pyx_t_15 = __pyx_v_ncols;
16573           __pyx_t_16 = __pyx_t_15;
16574           for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
16575             __pyx_v_c = __pyx_t_17;
16576 
16577             /* "dipy/align/sumsqdiff.pyx":713
16578  *         for r in range(nrows):
16579  *             for c in range(ncols):
16580  *                 delta = delta_field[r, c]             # <<<<<<<<<<<<<<
16581  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
16582  *                 if target is None:
16583  */
16584             __pyx_t_18 = __pyx_v_r;
16585             __pyx_t_19 = __pyx_v_c;
16586             __pyx_v_delta = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_18 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_19 * __pyx_v_delta_field.strides[1]) )));
16587 
16588             /* "dipy/align/sumsqdiff.pyx":714
16589  *             for c in range(ncols):
16590  *                 delta = delta_field[r, c]
16591  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1             # <<<<<<<<<<<<<<
16592  *                 if target is None:
16593  *                     b[0] = delta * gradient_field[r, c, 0]
16594  */
16595             if (((((PyObject *) __pyx_v_sigmasq_field.memview) != Py_None) != 0)) {
16596               __pyx_t_19 = __pyx_v_r;
16597               __pyx_t_18 = __pyx_v_c;
16598               __pyx_t_20 = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_sigmasq_field.data + __pyx_t_19 * __pyx_v_sigmasq_field.strides[0]) ) + __pyx_t_18 * __pyx_v_sigmasq_field.strides[1]) )));
16599             } else {
16600               __pyx_t_20 = 1.0;
16601             }
16602             __pyx_v_sigmasq = __pyx_t_20;
16603 
16604             /* "dipy/align/sumsqdiff.pyx":715
16605  *                 delta = delta_field[r, c]
16606  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
16607  *                 if target is None:             # <<<<<<<<<<<<<<
16608  *                     b[0] = delta * gradient_field[r, c, 0]
16609  *                     b[1] = delta * gradient_field[r, c, 1]
16610  */
16611             __pyx_t_9 = ((((PyObject *) __pyx_v_target.memview) == Py_None) != 0);
16612             if (__pyx_t_9) {
16613 
16614               /* "dipy/align/sumsqdiff.pyx":716
16615  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
16616  *                 if target is None:
16617  *                     b[0] = delta * gradient_field[r, c, 0]             # <<<<<<<<<<<<<<
16618  *                     b[1] = delta * gradient_field[r, c, 1]
16619  *                 else:
16620  */
16621               __pyx_t_18 = __pyx_v_r;
16622               __pyx_t_19 = __pyx_v_c;
16623               __pyx_t_21 = 0;
16624               (__pyx_v_b[0]) = (__pyx_v_delta * (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_18 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_19 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_21 * __pyx_v_gradient_field.strides[2]) ))));
16625 
16626               /* "dipy/align/sumsqdiff.pyx":717
16627  *                 if target is None:
16628  *                     b[0] = delta * gradient_field[r, c, 0]
16629  *                     b[1] = delta * gradient_field[r, c, 1]             # <<<<<<<<<<<<<<
16630  *                 else:
16631  *                     b[0] = target[r, c, 0]
16632  */
16633               __pyx_t_21 = __pyx_v_r;
16634               __pyx_t_19 = __pyx_v_c;
16635               __pyx_t_18 = 1;
16636               (__pyx_v_b[1]) = (__pyx_v_delta * (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_21 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_19 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_18 * __pyx_v_gradient_field.strides[2]) ))));
16637 
16638               /* "dipy/align/sumsqdiff.pyx":715
16639  *                 delta = delta_field[r, c]
16640  *                 sigmasq = sigmasq_field[r, c] if sigmasq_field != None else 1
16641  *                 if target is None:             # <<<<<<<<<<<<<<
16642  *                     b[0] = delta * gradient_field[r, c, 0]
16643  *                     b[1] = delta * gradient_field[r, c, 1]
16644  */
16645               goto __pyx_L11;
16646             }
16647 
16648             /* "dipy/align/sumsqdiff.pyx":719
16649  *                     b[1] = delta * gradient_field[r, c, 1]
16650  *                 else:
16651  *                     b[0] = target[r, c, 0]             # <<<<<<<<<<<<<<
16652  *                     b[1] = target[r, c, 1]
16653  *                 y[0] = 0  # reset y
16654  */
16655             /*else*/ {
16656               __pyx_t_18 = __pyx_v_r;
16657               __pyx_t_19 = __pyx_v_c;
16658               __pyx_t_21 = 0;
16659               (__pyx_v_b[0]) = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_18 * __pyx_v_target.strides[0]) ) + __pyx_t_19 * __pyx_v_target.strides[1]) ) + __pyx_t_21 * __pyx_v_target.strides[2]) )));
16660 
16661               /* "dipy/align/sumsqdiff.pyx":720
16662  *                 else:
16663  *                     b[0] = target[r, c, 0]
16664  *                     b[1] = target[r, c, 1]             # <<<<<<<<<<<<<<
16665  *                 y[0] = 0  # reset y
16666  *                 y[1] = 0
16667  */
16668               __pyx_t_21 = __pyx_v_r;
16669               __pyx_t_19 = __pyx_v_c;
16670               __pyx_t_18 = 1;
16671               (__pyx_v_b[1]) = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_target.data + __pyx_t_21 * __pyx_v_target.strides[0]) ) + __pyx_t_19 * __pyx_v_target.strides[1]) ) + __pyx_t_18 * __pyx_v_target.strides[2]) )));
16672             }
16673             __pyx_L11:;
16674 
16675             /* "dipy/align/sumsqdiff.pyx":721
16676  *                     b[0] = target[r, c, 0]
16677  *                     b[1] = target[r, c, 1]
16678  *                 y[0] = 0  # reset y             # <<<<<<<<<<<<<<
16679  *                 y[1] = 0
16680  *                 nn=0
16681  */
16682             (__pyx_v_y[0]) = 0.0;
16683 
16684             /* "dipy/align/sumsqdiff.pyx":722
16685  *                     b[1] = target[r, c, 1]
16686  *                 y[0] = 0  # reset y
16687  *                 y[1] = 0             # <<<<<<<<<<<<<<
16688  *                 nn=0
16689  *                 for k in range(NUM_NEIGHBORS):
16690  */
16691             (__pyx_v_y[1]) = 0.0;
16692 
16693             /* "dipy/align/sumsqdiff.pyx":723
16694  *                 y[0] = 0  # reset y
16695  *                 y[1] = 0
16696  *                 nn=0             # <<<<<<<<<<<<<<
16697  *                 for k in range(NUM_NEIGHBORS):
16698  *                     dr = r + dRow[k]
16699  */
16700             __pyx_v_nn = 0;
16701 
16702             /* "dipy/align/sumsqdiff.pyx":724
16703  *                 y[1] = 0
16704  *                 nn=0
16705  *                 for k in range(NUM_NEIGHBORS):             # <<<<<<<<<<<<<<
16706  *                     dr = r + dRow[k]
16707  *                     if((dr < 0) or (dr >= nrows)):
16708  */
16709             __pyx_t_22 = __pyx_v_NUM_NEIGHBORS;
16710             __pyx_t_23 = __pyx_t_22;
16711             for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_23; __pyx_t_24+=1) {
16712               __pyx_v_k = __pyx_t_24;
16713 
16714               /* "dipy/align/sumsqdiff.pyx":725
16715  *                 nn=0
16716  *                 for k in range(NUM_NEIGHBORS):
16717  *                     dr = r + dRow[k]             # <<<<<<<<<<<<<<
16718  *                     if((dr < 0) or (dr >= nrows)):
16719  *                         continue
16720  */
16721               __pyx_v_dr = (__pyx_v_r + (__pyx_v_dRow[__pyx_v_k]));
16722 
16723               /* "dipy/align/sumsqdiff.pyx":726
16724  *                 for k in range(NUM_NEIGHBORS):
16725  *                     dr = r + dRow[k]
16726  *                     if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
16727  *                         continue
16728  *                     dc = c + dCol[k]
16729  */
16730               __pyx_t_25 = ((__pyx_v_dr < 0) != 0);
16731               if (!__pyx_t_25) {
16732               } else {
16733                 __pyx_t_9 = __pyx_t_25;
16734                 goto __pyx_L15_bool_binop_done;
16735               }
16736               __pyx_t_25 = ((__pyx_v_dr >= __pyx_v_nrows) != 0);
16737               __pyx_t_9 = __pyx_t_25;
16738               __pyx_L15_bool_binop_done:;
16739               if (__pyx_t_9) {
16740 
16741                 /* "dipy/align/sumsqdiff.pyx":727
16742  *                     dr = r + dRow[k]
16743  *                     if((dr < 0) or (dr >= nrows)):
16744  *                         continue             # <<<<<<<<<<<<<<
16745  *                     dc = c + dCol[k]
16746  *                     if((dc < 0) or (dc >= ncols)):
16747  */
16748                 goto __pyx_L12_continue;
16749 
16750                 /* "dipy/align/sumsqdiff.pyx":726
16751  *                 for k in range(NUM_NEIGHBORS):
16752  *                     dr = r + dRow[k]
16753  *                     if((dr < 0) or (dr >= nrows)):             # <<<<<<<<<<<<<<
16754  *                         continue
16755  *                     dc = c + dCol[k]
16756  */
16757               }
16758 
16759               /* "dipy/align/sumsqdiff.pyx":728
16760  *                     if((dr < 0) or (dr >= nrows)):
16761  *                         continue
16762  *                     dc = c + dCol[k]             # <<<<<<<<<<<<<<
16763  *                     if((dc < 0) or (dc >= ncols)):
16764  *                         continue
16765  */
16766               __pyx_v_dc = (__pyx_v_c + (__pyx_v_dCol[__pyx_v_k]));
16767 
16768               /* "dipy/align/sumsqdiff.pyx":729
16769  *                         continue
16770  *                     dc = c + dCol[k]
16771  *                     if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
16772  *                         continue
16773  *                     y[0] += (d[r, c, 0] - d[dr, dc, 0])
16774  */
16775               __pyx_t_25 = ((__pyx_v_dc < 0) != 0);
16776               if (!__pyx_t_25) {
16777               } else {
16778                 __pyx_t_9 = __pyx_t_25;
16779                 goto __pyx_L18_bool_binop_done;
16780               }
16781               __pyx_t_25 = ((__pyx_v_dc >= __pyx_v_ncols) != 0);
16782               __pyx_t_9 = __pyx_t_25;
16783               __pyx_L18_bool_binop_done:;
16784               if (__pyx_t_9) {
16785 
16786                 /* "dipy/align/sumsqdiff.pyx":730
16787  *                     dc = c + dCol[k]
16788  *                     if((dc < 0) or (dc >= ncols)):
16789  *                         continue             # <<<<<<<<<<<<<<
16790  *                     y[0] += (d[r, c, 0] - d[dr, dc, 0])
16791  *                     y[1] += (d[r, c, 1] - d[dr, dc, 1])
16792  */
16793                 goto __pyx_L12_continue;
16794 
16795                 /* "dipy/align/sumsqdiff.pyx":729
16796  *                         continue
16797  *                     dc = c + dCol[k]
16798  *                     if((dc < 0) or (dc >= ncols)):             # <<<<<<<<<<<<<<
16799  *                         continue
16800  *                     y[0] += (d[r, c, 0] - d[dr, dc, 0])
16801  */
16802               }
16803 
16804               /* "dipy/align/sumsqdiff.pyx":731
16805  *                     if((dc < 0) or (dc >= ncols)):
16806  *                         continue
16807  *                     y[0] += (d[r, c, 0] - d[dr, dc, 0])             # <<<<<<<<<<<<<<
16808  *                     y[1] += (d[r, c, 1] - d[dr, dc, 1])
16809  *
16810  */
16811               __pyx_t_26 = 0;
16812               __pyx_t_18 = __pyx_v_r;
16813               __pyx_t_19 = __pyx_v_c;
16814               __pyx_t_21 = 0;
16815               __pyx_t_27 = __pyx_v_dr;
16816               __pyx_t_28 = __pyx_v_dc;
16817               __pyx_t_29 = 0;
16818               (__pyx_v_y[__pyx_t_26]) = ((__pyx_v_y[__pyx_t_26]) + ((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_18 * __pyx_v_d.strides[0]) ) + __pyx_t_19 * __pyx_v_d.strides[1]) ) + __pyx_t_21 * __pyx_v_d.strides[2]) ))) - (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_27 * __pyx_v_d.strides[0]) ) + __pyx_t_28 * __pyx_v_d.strides[1]) ) + __pyx_t_29 * __pyx_v_d.strides[2]) )))));
16819 
16820               /* "dipy/align/sumsqdiff.pyx":732
16821  *                         continue
16822  *                     y[0] += (d[r, c, 0] - d[dr, dc, 0])
16823  *                     y[1] += (d[r, c, 1] - d[dr, dc, 1])             # <<<<<<<<<<<<<<
16824  *
16825  *                 if dpy_isinf(sigmasq) != 0:
16826  */
16827               __pyx_t_26 = 1;
16828               __pyx_t_29 = __pyx_v_r;
16829               __pyx_t_28 = __pyx_v_c;
16830               __pyx_t_27 = 1;
16831               __pyx_t_21 = __pyx_v_dr;
16832               __pyx_t_19 = __pyx_v_dc;
16833               __pyx_t_18 = 1;
16834               (__pyx_v_y[__pyx_t_26]) = ((__pyx_v_y[__pyx_t_26]) + ((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_29 * __pyx_v_d.strides[0]) ) + __pyx_t_28 * __pyx_v_d.strides[1]) ) + __pyx_t_27 * __pyx_v_d.strides[2]) ))) - (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_21 * __pyx_v_d.strides[0]) ) + __pyx_t_19 * __pyx_v_d.strides[1]) ) + __pyx_t_18 * __pyx_v_d.strides[2]) )))));
16835               __pyx_L12_continue:;
16836             }
16837 
16838             /* "dipy/align/sumsqdiff.pyx":734
16839  *                     y[1] += (d[r, c, 1] - d[dr, dc, 1])
16840  *
16841  *                 if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
16842  *                     residual[r, c, 0] = -lambda_param * y[0]
16843  *                     residual[r, c, 1] = -lambda_param * y[1]
16844  */
16845             __pyx_t_9 = ((dpy_isinf(__pyx_v_sigmasq) != 0) != 0);
16846             if (__pyx_t_9) {
16847 
16848               /* "dipy/align/sumsqdiff.pyx":735
16849  *
16850  *                 if dpy_isinf(sigmasq) != 0:
16851  *                     residual[r, c, 0] = -lambda_param * y[0]             # <<<<<<<<<<<<<<
16852  *                     residual[r, c, 1] = -lambda_param * y[1]
16853  *                 else:
16854  */
16855               __pyx_t_18 = __pyx_v_r;
16856               __pyx_t_19 = __pyx_v_c;
16857               __pyx_t_21 = 0;
16858               *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_18 * __pyx_v_residual.strides[0]) ) + __pyx_t_19 * __pyx_v_residual.strides[1]) ) + __pyx_t_21 * __pyx_v_residual.strides[2]) )) = ((-__pyx_v_lambda_param) * (__pyx_v_y[0]));
16859 
16860               /* "dipy/align/sumsqdiff.pyx":736
16861  *                 if dpy_isinf(sigmasq) != 0:
16862  *                     residual[r, c, 0] = -lambda_param * y[0]
16863  *                     residual[r, c, 1] = -lambda_param * y[1]             # <<<<<<<<<<<<<<
16864  *                 else:
16865  *                     dotP = (gradient_field[r, c, 0] * d[r, c, 0] +
16866  */
16867               __pyx_t_21 = __pyx_v_r;
16868               __pyx_t_19 = __pyx_v_c;
16869               __pyx_t_18 = 1;
16870               *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_21 * __pyx_v_residual.strides[0]) ) + __pyx_t_19 * __pyx_v_residual.strides[1]) ) + __pyx_t_18 * __pyx_v_residual.strides[2]) )) = ((-__pyx_v_lambda_param) * (__pyx_v_y[1]));
16871 
16872               /* "dipy/align/sumsqdiff.pyx":734
16873  *                     y[1] += (d[r, c, 1] - d[dr, dc, 1])
16874  *
16875  *                 if dpy_isinf(sigmasq) != 0:             # <<<<<<<<<<<<<<
16876  *                     residual[r, c, 0] = -lambda_param * y[0]
16877  *                     residual[r, c, 1] = -lambda_param * y[1]
16878  */
16879               goto __pyx_L20;
16880             }
16881 
16882             /* "dipy/align/sumsqdiff.pyx":738
16883  *                     residual[r, c, 1] = -lambda_param * y[1]
16884  *                 else:
16885  *                     dotP = (gradient_field[r, c, 0] * d[r, c, 0] +             # <<<<<<<<<<<<<<
16886  *                             gradient_field[r, c, 1] * d[r, c, 1])
16887  *                     residual[r, c, 0] = (b[0] -
16888  */
16889             /*else*/ {
16890               __pyx_t_18 = __pyx_v_r;
16891               __pyx_t_19 = __pyx_v_c;
16892               __pyx_t_21 = 0;
16893               __pyx_t_27 = __pyx_v_r;
16894               __pyx_t_28 = __pyx_v_c;
16895               __pyx_t_29 = 0;
16896 
16897               /* "dipy/align/sumsqdiff.pyx":739
16898  *                 else:
16899  *                     dotP = (gradient_field[r, c, 0] * d[r, c, 0] +
16900  *                             gradient_field[r, c, 1] * d[r, c, 1])             # <<<<<<<<<<<<<<
16901  *                     residual[r, c, 0] = (b[0] -
16902  *                                          (gradient_field[r, c, 0] * dotP +
16903  */
16904               __pyx_t_30 = __pyx_v_r;
16905               __pyx_t_31 = __pyx_v_c;
16906               __pyx_t_32 = 1;
16907               __pyx_t_33 = __pyx_v_r;
16908               __pyx_t_34 = __pyx_v_c;
16909               __pyx_t_35 = 1;
16910 
16911               /* "dipy/align/sumsqdiff.pyx":738
16912  *                     residual[r, c, 1] = -lambda_param * y[1]
16913  *                 else:
16914  *                     dotP = (gradient_field[r, c, 0] * d[r, c, 0] +             # <<<<<<<<<<<<<<
16915  *                             gradient_field[r, c, 1] * d[r, c, 1])
16916  *                     residual[r, c, 0] = (b[0] -
16917  */
16918               __pyx_v_dotP = (((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_18 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_19 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_21 * __pyx_v_gradient_field.strides[2]) ))) * (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_27 * __pyx_v_d.strides[0]) ) + __pyx_t_28 * __pyx_v_d.strides[1]) ) + __pyx_t_29 * __pyx_v_d.strides[2]) )))) + ((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_30 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_31 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_32 * __pyx_v_gradient_field.strides[2]) ))) * (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_d.data + __pyx_t_33 * __pyx_v_d.strides[0]) ) + __pyx_t_34 * __pyx_v_d.strides[1]) ) + __pyx_t_35 * __pyx_v_d.strides[2]) )))));
16919 
16920               /* "dipy/align/sumsqdiff.pyx":741
16921  *                             gradient_field[r, c, 1] * d[r, c, 1])
16922  *                     residual[r, c, 0] = (b[0] -
16923  *                                          (gradient_field[r, c, 0] * dotP +             # <<<<<<<<<<<<<<
16924  *                                           sigmasq * lambda_param * y[0]))
16925  *                     residual[r, c, 1] = (b[1] -
16926  */
16927               __pyx_t_35 = __pyx_v_r;
16928               __pyx_t_34 = __pyx_v_c;
16929               __pyx_t_33 = 0;
16930 
16931               /* "dipy/align/sumsqdiff.pyx":740
16932  *                     dotP = (gradient_field[r, c, 0] * d[r, c, 0] +
16933  *                             gradient_field[r, c, 1] * d[r, c, 1])
16934  *                     residual[r, c, 0] = (b[0] -             # <<<<<<<<<<<<<<
16935  *                                          (gradient_field[r, c, 0] * dotP +
16936  *                                           sigmasq * lambda_param * y[0]))
16937  */
16938               __pyx_t_32 = __pyx_v_r;
16939               __pyx_t_31 = __pyx_v_c;
16940               __pyx_t_30 = 0;
16941               *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_32 * __pyx_v_residual.strides[0]) ) + __pyx_t_31 * __pyx_v_residual.strides[1]) ) + __pyx_t_30 * __pyx_v_residual.strides[2]) )) = ((__pyx_v_b[0]) - (((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_35 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_34 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_33 * __pyx_v_gradient_field.strides[2]) ))) * __pyx_v_dotP) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[0]))));
16942 
16943               /* "dipy/align/sumsqdiff.pyx":744
16944  *                                           sigmasq * lambda_param * y[0]))
16945  *                     residual[r, c, 1] = (b[1] -
16946  *                                          (gradient_field[r, c, 1] * dotP +             # <<<<<<<<<<<<<<
16947  *                                           sigmasq * lambda_param * y[1]))
16948  *     return np.asarray(residual)
16949  */
16950               __pyx_t_33 = __pyx_v_r;
16951               __pyx_t_34 = __pyx_v_c;
16952               __pyx_t_35 = 1;
16953 
16954               /* "dipy/align/sumsqdiff.pyx":743
16955  *                                          (gradient_field[r, c, 0] * dotP +
16956  *                                           sigmasq * lambda_param * y[0]))
16957  *                     residual[r, c, 1] = (b[1] -             # <<<<<<<<<<<<<<
16958  *                                          (gradient_field[r, c, 1] * dotP +
16959  *                                           sigmasq * lambda_param * y[1]))
16960  */
16961               __pyx_t_30 = __pyx_v_r;
16962               __pyx_t_31 = __pyx_v_c;
16963               __pyx_t_32 = 1;
16964               *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_residual.data + __pyx_t_30 * __pyx_v_residual.strides[0]) ) + __pyx_t_31 * __pyx_v_residual.strides[1]) ) + __pyx_t_32 * __pyx_v_residual.strides[2]) )) = ((__pyx_v_b[1]) - (((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_field.data + __pyx_t_33 * __pyx_v_gradient_field.strides[0]) ) + __pyx_t_34 * __pyx_v_gradient_field.strides[1]) ) + __pyx_t_35 * __pyx_v_gradient_field.strides[2]) ))) * __pyx_v_dotP) + ((__pyx_v_sigmasq * __pyx_v_lambda_param) * (__pyx_v_y[1]))));
16965             }
16966             __pyx_L20:;
16967           }
16968         }
16969       }
16970 
16971       /* "dipy/align/sumsqdiff.pyx":709
16972  *         residual = np.empty(shape=(nrows, ncols, 2), dtype=ftype)
16973  *
16974  *     with nogil:             # <<<<<<<<<<<<<<
16975  *
16976  *         for r in range(nrows):
16977  */
16978       /*finally:*/ {
16979         /*normal exit:*/{
16980           #ifdef WITH_THREAD
16981           __Pyx_FastGIL_Forget();
16982           Py_BLOCK_THREADS
16983           #endif
16984           goto __pyx_L6;
16985         }
16986         __pyx_L6:;
16987       }
16988   }
16989 
16990   /* "dipy/align/sumsqdiff.pyx":746
16991  *                                          (gradient_field[r, c, 1] * dotP +
16992  *                                           sigmasq * lambda_param * y[1]))
16993  *     return np.asarray(residual)             # <<<<<<<<<<<<<<
16994  *
16995  *
16996  */
16997   __Pyx_XDECREF(__pyx_r);
16998   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 746, __pyx_L1_error)
16999   __Pyx_GOTREF(__pyx_t_3);
17000   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 746, __pyx_L1_error)
17001   __Pyx_GOTREF(__pyx_t_1);
17002   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17003   __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_residual, 3, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 746, __pyx_L1_error)
17004   __Pyx_GOTREF(__pyx_t_3);
17005   __pyx_t_4 = NULL;
17006   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
17007     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
17008     if (likely(__pyx_t_4)) {
17009       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
17010       __Pyx_INCREF(__pyx_t_4);
17011       __Pyx_INCREF(function);
17012       __Pyx_DECREF_SET(__pyx_t_1, function);
17013     }
17014   }
17015   __pyx_t_10 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
17016   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
17017   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17018   if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 746, __pyx_L1_error)
17019   __Pyx_GOTREF(__pyx_t_10);
17020   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17021   __pyx_r = __pyx_t_10;
17022   __pyx_t_10 = 0;
17023   goto __pyx_L0;
17024 
17025   /* "dipy/align/sumsqdiff.pyx":649
17026  * @cython.boundscheck(False)
17027  * @cython.wraparound(False)
17028  * cpdef compute_residual_displacement_field_ssd_2d(             # <<<<<<<<<<<<<<
17029  *         floating[:, :] delta_field, floating[:, :] sigmasq_field,
17030  *         floating[:, :, :] gradient_field, floating[:, :, :] target,
17031  */
17032 
17033   /* function exit code */
17034   __pyx_L1_error:;
17035   __Pyx_XDECREF(__pyx_t_1);
17036   __Pyx_XDECREF(__pyx_t_2);
17037   __Pyx_XDECREF(__pyx_t_3);
17038   __Pyx_XDECREF(__pyx_t_4);
17039   __Pyx_XDECREF(__pyx_t_10);
17040   __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
17041   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
17042   __pyx_r = 0;
17043   __pyx_L0:;
17044   __Pyx_XDECREF(__pyx_v_ftype);
17045   __PYX_XDEC_MEMVIEW(&__pyx_v_residual, 1);
17046   __Pyx_XGIVEREF(__pyx_r);
17047   __Pyx_RefNannyFinishContext();
17048   return __pyx_r;
17049 }
17050 
17051 /* Python wrapper */
17052 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_53__pyx_fuse_1compute_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
17053 static PyMethodDef __pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_53__pyx_fuse_1compute_residual_displacement_field_ssd_2d = {"__pyx_fuse_1compute_residual_displacement_field_ssd_2d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_53__pyx_fuse_1compute_residual_displacement_field_ssd_2d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_14compute_residual_displacement_field_ssd_2d};
__pyx_pw_4dipy_5align_9sumsqdiff_53__pyx_fuse_1compute_residual_displacement_field_ssd_2d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)17054 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_53__pyx_fuse_1compute_residual_displacement_field_ssd_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
17055   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
17056   __Pyx_memviewslice __pyx_v_sigmasq_field = { 0, 0, { 0 }, { 0 }, { 0 } };
17057   __Pyx_memviewslice __pyx_v_gradient_field = { 0, 0, { 0 }, { 0 }, { 0 } };
17058   __Pyx_memviewslice __pyx_v_target = { 0, 0, { 0 }, { 0 }, { 0 } };
17059   double __pyx_v_lambda_param;
17060   __Pyx_memviewslice __pyx_v_d = { 0, 0, { 0 }, { 0 }, { 0 } };
17061   __Pyx_memviewslice __pyx_v_residual = { 0, 0, { 0 }, { 0 }, { 0 } };
17062   int __pyx_lineno = 0;
17063   const char *__pyx_filename = NULL;
17064   int __pyx_clineno = 0;
17065   PyObject *__pyx_r = 0;
17066   __Pyx_RefNannyDeclarations
17067   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_residual_displacement_field_ssd_2d (wrapper)", 0);
17068   {
17069     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_sigmasq_field,&__pyx_n_s_gradient_field,&__pyx_n_s_target,&__pyx_n_s_lambda_param,&__pyx_n_s_d,&__pyx_n_s_residual,0};
17070     PyObject* values[7] = {0,0,0,0,0,0,0};
17071     if (unlikely(__pyx_kwds)) {
17072       Py_ssize_t kw_args;
17073       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
17074       switch (pos_args) {
17075         case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
17076         CYTHON_FALLTHROUGH;
17077         case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
17078         CYTHON_FALLTHROUGH;
17079         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
17080         CYTHON_FALLTHROUGH;
17081         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
17082         CYTHON_FALLTHROUGH;
17083         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
17084         CYTHON_FALLTHROUGH;
17085         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
17086         CYTHON_FALLTHROUGH;
17087         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
17088         CYTHON_FALLTHROUGH;
17089         case  0: break;
17090         default: goto __pyx_L5_argtuple_error;
17091       }
17092       kw_args = PyDict_Size(__pyx_kwds);
17093       switch (pos_args) {
17094         case  0:
17095         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
17096         else goto __pyx_L5_argtuple_error;
17097         CYTHON_FALLTHROUGH;
17098         case  1:
17099         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigmasq_field)) != 0)) kw_args--;
17100         else {
17101           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1compute_residual_displacement_field_ssd_2d", 1, 7, 7, 1); __PYX_ERR(0, 649, __pyx_L3_error)
17102         }
17103         CYTHON_FALLTHROUGH;
17104         case  2:
17105         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gradient_field)) != 0)) kw_args--;
17106         else {
17107           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1compute_residual_displacement_field_ssd_2d", 1, 7, 7, 2); __PYX_ERR(0, 649, __pyx_L3_error)
17108         }
17109         CYTHON_FALLTHROUGH;
17110         case  3:
17111         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target)) != 0)) kw_args--;
17112         else {
17113           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1compute_residual_displacement_field_ssd_2d", 1, 7, 7, 3); __PYX_ERR(0, 649, __pyx_L3_error)
17114         }
17115         CYTHON_FALLTHROUGH;
17116         case  4:
17117         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_lambda_param)) != 0)) kw_args--;
17118         else {
17119           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1compute_residual_displacement_field_ssd_2d", 1, 7, 7, 4); __PYX_ERR(0, 649, __pyx_L3_error)
17120         }
17121         CYTHON_FALLTHROUGH;
17122         case  5:
17123         if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_d)) != 0)) kw_args--;
17124         else {
17125           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1compute_residual_displacement_field_ssd_2d", 1, 7, 7, 5); __PYX_ERR(0, 649, __pyx_L3_error)
17126         }
17127         CYTHON_FALLTHROUGH;
17128         case  6:
17129         if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_residual)) != 0)) kw_args--;
17130         else {
17131           __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1compute_residual_displacement_field_ssd_2d", 1, 7, 7, 6); __PYX_ERR(0, 649, __pyx_L3_error)
17132         }
17133       }
17134       if (unlikely(kw_args > 0)) {
17135         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fuse_1compute_residual_displacement_field_ssd_2d") < 0)) __PYX_ERR(0, 649, __pyx_L3_error)
17136       }
17137     } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
17138       goto __pyx_L5_argtuple_error;
17139     } else {
17140       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
17141       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
17142       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
17143       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
17144       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
17145       values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
17146       values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
17147     }
17148     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 650, __pyx_L3_error)
17149     __pyx_v_sigmasq_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_sigmasq_field.memview)) __PYX_ERR(0, 650, __pyx_L3_error)
17150     __pyx_v_gradient_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_gradient_field.memview)) __PYX_ERR(0, 651, __pyx_L3_error)
17151     __pyx_v_target = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_target.memview)) __PYX_ERR(0, 651, __pyx_L3_error)
17152     __pyx_v_lambda_param = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_lambda_param == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 652, __pyx_L3_error)
17153     __pyx_v_d = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_d.memview)) __PYX_ERR(0, 652, __pyx_L3_error)
17154     __pyx_v_residual = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[6], PyBUF_WRITABLE); if (unlikely(!__pyx_v_residual.memview)) __PYX_ERR(0, 653, __pyx_L3_error)
17155   }
17156   goto __pyx_L4_argument_unpacking_done;
17157   __pyx_L5_argtuple_error:;
17158   __Pyx_RaiseArgtupleInvalid("__pyx_fuse_1compute_residual_displacement_field_ssd_2d", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 649, __pyx_L3_error)
17159   __pyx_L3_error:;
17160   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_1compute_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
17161   __Pyx_RefNannyFinishContext();
17162   return NULL;
17163   __pyx_L4_argument_unpacking_done:;
17164   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_52__pyx_fuse_1compute_residual_displacement_field_ssd_2d(__pyx_self, __pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_gradient_field, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_d, __pyx_v_residual);
17165 
17166   /* function exit code */
17167   __Pyx_RefNannyFinishContext();
17168   return __pyx_r;
17169 }
17170 
__pyx_pf_4dipy_5align_9sumsqdiff_52__pyx_fuse_1compute_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_sigmasq_field,__Pyx_memviewslice __pyx_v_gradient_field,__Pyx_memviewslice __pyx_v_target,double __pyx_v_lambda_param,__Pyx_memviewslice __pyx_v_d,__Pyx_memviewslice __pyx_v_residual)17171 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_52__pyx_fuse_1compute_residual_displacement_field_ssd_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_sigmasq_field, __Pyx_memviewslice __pyx_v_gradient_field, __Pyx_memviewslice __pyx_v_target, double __pyx_v_lambda_param, __Pyx_memviewslice __pyx_v_d, __Pyx_memviewslice __pyx_v_residual) {
17172   PyObject *__pyx_r = NULL;
17173   __Pyx_RefNannyDeclarations
17174   PyObject *__pyx_t_1 = NULL;
17175   int __pyx_lineno = 0;
17176   const char *__pyx_filename = NULL;
17177   int __pyx_clineno = 0;
17178   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_residual_displacement_field_ssd_2d", 0);
17179   __Pyx_XDECREF(__pyx_r);
17180   if (unlikely(!__pyx_v_delta_field.memview)) { __Pyx_RaiseUnboundLocalError("delta_field"); __PYX_ERR(0, 649, __pyx_L1_error) }
17181   if (unlikely(!__pyx_v_sigmasq_field.memview)) { __Pyx_RaiseUnboundLocalError("sigmasq_field"); __PYX_ERR(0, 649, __pyx_L1_error) }
17182   if (unlikely(!__pyx_v_gradient_field.memview)) { __Pyx_RaiseUnboundLocalError("gradient_field"); __PYX_ERR(0, 649, __pyx_L1_error) }
17183   if (unlikely(!__pyx_v_target.memview)) { __Pyx_RaiseUnboundLocalError("target"); __PYX_ERR(0, 649, __pyx_L1_error) }
17184   if (unlikely(!__pyx_v_d.memview)) { __Pyx_RaiseUnboundLocalError("d"); __PYX_ERR(0, 649, __pyx_L1_error) }
17185   if (unlikely(!__pyx_v_residual.memview)) { __Pyx_RaiseUnboundLocalError("residual"); __PYX_ERR(0, 649, __pyx_L1_error) }
17186   __pyx_t_1 = __pyx_fuse_1__pyx_f_4dipy_5align_9sumsqdiff_compute_residual_displacement_field_ssd_2d(__pyx_v_delta_field, __pyx_v_sigmasq_field, __pyx_v_gradient_field, __pyx_v_target, __pyx_v_lambda_param, __pyx_v_d, __pyx_v_residual, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
17187   __Pyx_GOTREF(__pyx_t_1);
17188   __pyx_r = __pyx_t_1;
17189   __pyx_t_1 = 0;
17190   goto __pyx_L0;
17191 
17192   /* function exit code */
17193   __pyx_L1_error:;
17194   __Pyx_XDECREF(__pyx_t_1);
17195   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fuse_1compute_residual_displacement_field_ssd_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
17196   __pyx_r = NULL;
17197   __pyx_L0:;
17198   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
17199   __PYX_XDEC_MEMVIEW(&__pyx_v_sigmasq_field, 1);
17200   __PYX_XDEC_MEMVIEW(&__pyx_v_gradient_field, 1);
17201   __PYX_XDEC_MEMVIEW(&__pyx_v_target, 1);
17202   __PYX_XDEC_MEMVIEW(&__pyx_v_d, 1);
17203   __PYX_XDEC_MEMVIEW(&__pyx_v_residual, 1);
17204   __Pyx_XGIVEREF(__pyx_r);
17205   __Pyx_RefNannyFinishContext();
17206   return __pyx_r;
17207 }
17208 
17209 /* "dipy/align/sumsqdiff.pyx":752
17210  * @cython.wraparound(False)
17211  * @cython.cdivision(True)
17212  * def compute_ssd_demons_step_2d(floating[:,:] delta_field,             # <<<<<<<<<<<<<<
17213  *                                floating[:,:,:] gradient_moving,
17214  *                                double sigma_sq_x,
17215  */
17216 
17217 /* Python wrapper */
17218 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_17compute_ssd_demons_step_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
17219 static char __pyx_doc_4dipy_5align_9sumsqdiff_16compute_ssd_demons_step_2d[] = "Demons step for 2D SSD-driven registration\n\n    Computes the demons step for SSD-driven registration\n    ( eq. 4 in [Bruhn05] )\n\n    Parameters\n    ----------\n    delta_field : array, shape (R, C)\n        the difference between the static and moving image (the 'derivative\n        w.r.t. time' in the optical flow model)\n    gradient_field : array, shape (R, C, 2)\n        the gradient of the moving image\n    sigma_sq_x : float\n        parameter controlling the amount of regularization. It corresponds to\n        $\\sigma_x^2$ in algorithm 1 of Vercauteren et al.[Vercauteren09]\n    out : array, shape (R, C, 2)\n        if None, a new array will be created to store the demons step. Otherwise\n        the provided array will be used.\n\n    Returns\n    -------\n    demons_step : array, shape (R, C, 2)\n        the demons step to be applied for updating the current displacement\n        field\n    energy : float\n        the current ssd energy (before applying the returned demons_step)\n\n    References\n    ----------\n    [Bruhn05] Andres Bruhn and Joachim Weickert, \"Towards ultimate motion\n              estimation: combining highest accuracy with real-time\n              performance\", 10th IEEE International Conference on Computer\n              Vision, 2005. ICCV 2005.\n    [Vercauteren09] Vercauteren, T., Pennec, X., Perchant, A., & Ayache, N.\n                    (2009). Diffeomorphic demons: efficient non-parametric\n                    image registration. NeuroImage, 45(1 Suppl), S61-72.\n                    doi:10.1016/j.neuroimage.2008.10.040\n    ";
17220 static PyMethodDef __pyx_mdef_4dipy_5align_9sumsqdiff_17compute_ssd_demons_step_2d = {"compute_ssd_demons_step_2d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_17compute_ssd_demons_step_2d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_16compute_ssd_demons_step_2d};
__pyx_pw_4dipy_5align_9sumsqdiff_17compute_ssd_demons_step_2d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)17221 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_17compute_ssd_demons_step_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
17222   PyObject *__pyx_v_signatures = 0;
17223   PyObject *__pyx_v_args = 0;
17224   PyObject *__pyx_v_kwargs = 0;
17225   CYTHON_UNUSED PyObject *__pyx_v_defaults = 0;
17226   int __pyx_lineno = 0;
17227   const char *__pyx_filename = NULL;
17228   int __pyx_clineno = 0;
17229   PyObject *__pyx_r = 0;
17230   __Pyx_RefNannyDeclarations
17231   __Pyx_RefNannySetupContext("__pyx_fused_cpdef (wrapper)", 0);
17232   {
17233     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signatures,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_defaults,0};
17234     PyObject* values[4] = {0,0,0,0};
17235     if (unlikely(__pyx_kwds)) {
17236       Py_ssize_t kw_args;
17237       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
17238       switch (pos_args) {
17239         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
17240         CYTHON_FALLTHROUGH;
17241         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
17242         CYTHON_FALLTHROUGH;
17243         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
17244         CYTHON_FALLTHROUGH;
17245         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
17246         CYTHON_FALLTHROUGH;
17247         case  0: break;
17248         default: goto __pyx_L5_argtuple_error;
17249       }
17250       kw_args = PyDict_Size(__pyx_kwds);
17251       switch (pos_args) {
17252         case  0:
17253         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signatures)) != 0)) kw_args--;
17254         else goto __pyx_L5_argtuple_error;
17255         CYTHON_FALLTHROUGH;
17256         case  1:
17257         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
17258         else {
17259           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 1); __PYX_ERR(0, 752, __pyx_L3_error)
17260         }
17261         CYTHON_FALLTHROUGH;
17262         case  2:
17263         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
17264         else {
17265           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); __PYX_ERR(0, 752, __pyx_L3_error)
17266         }
17267         CYTHON_FALLTHROUGH;
17268         case  3:
17269         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--;
17270         else {
17271           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); __PYX_ERR(0, 752, __pyx_L3_error)
17272         }
17273       }
17274       if (unlikely(kw_args > 0)) {
17275         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) __PYX_ERR(0, 752, __pyx_L3_error)
17276       }
17277     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
17278       goto __pyx_L5_argtuple_error;
17279     } else {
17280       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
17281       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
17282       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
17283       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
17284     }
17285     __pyx_v_signatures = values[0];
17286     __pyx_v_args = values[1];
17287     __pyx_v_kwargs = values[2];
17288     __pyx_v_defaults = values[3];
17289   }
17290   goto __pyx_L4_argument_unpacking_done;
17291   __pyx_L5_argtuple_error:;
17292   __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 752, __pyx_L3_error)
17293   __pyx_L3_error:;
17294   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
17295   __Pyx_RefNannyFinishContext();
17296   return NULL;
17297   __pyx_L4_argument_unpacking_done:;
17298   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_16compute_ssd_demons_step_2d(__pyx_self, __pyx_v_signatures, __pyx_v_args, __pyx_v_kwargs, __pyx_v_defaults);
17299 
17300   /* function exit code */
17301   __Pyx_RefNannyFinishContext();
17302   return __pyx_r;
17303 }
17304 
__pyx_pf_4dipy_5align_9sumsqdiff_16compute_ssd_demons_step_2d(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_signatures,PyObject * __pyx_v_args,PyObject * __pyx_v_kwargs,CYTHON_UNUSED PyObject * __pyx_v_defaults)17305 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_16compute_ssd_demons_step_2d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults) {
17306   PyObject *__pyx_v_dest_sig = NULL;
17307   Py_ssize_t __pyx_v_i;
17308   PyTypeObject *__pyx_v_ndarray = 0;
17309   __Pyx_memviewslice __pyx_v_memslice;
17310   Py_ssize_t __pyx_v_itemsize;
17311   CYTHON_UNUSED int __pyx_v_dtype_signed;
17312   char __pyx_v_kind;
17313   PyObject *__pyx_v_arg = NULL;
17314   PyObject *__pyx_v_dtype = NULL;
17315   PyObject *__pyx_v_arg_base = NULL;
17316   PyObject *__pyx_v_candidates = NULL;
17317   PyObject *__pyx_v_sig = NULL;
17318   int __pyx_v_match_found;
17319   PyObject *__pyx_v_src_sig = NULL;
17320   PyObject *__pyx_v_dst_type = NULL;
17321   PyObject *__pyx_r = NULL;
17322   __Pyx_RefNannyDeclarations
17323   PyObject *__pyx_t_1 = NULL;
17324   int __pyx_t_2;
17325   int __pyx_t_3;
17326   int __pyx_t_4;
17327   Py_ssize_t __pyx_t_5;
17328   PyObject *__pyx_t_6 = NULL;
17329   long __pyx_t_7;
17330   __Pyx_memviewslice __pyx_t_8;
17331   Py_ssize_t __pyx_t_9;
17332   int __pyx_t_10;
17333   int __pyx_t_11;
17334   PyObject *__pyx_t_12 = NULL;
17335   PyObject *__pyx_t_13 = NULL;
17336   PyObject *__pyx_t_14 = NULL;
17337   Py_ssize_t __pyx_t_15;
17338   Py_ssize_t __pyx_t_16;
17339   Py_ssize_t __pyx_t_17;
17340   int __pyx_t_18;
17341   int __pyx_lineno = 0;
17342   const char *__pyx_filename = NULL;
17343   int __pyx_clineno = 0;
17344   __Pyx_RefNannySetupContext("compute_ssd_demons_step_2d", 0);
17345   __Pyx_INCREF(__pyx_v_kwargs);
17346   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
17347   __Pyx_GOTREF(__pyx_t_1);
17348   __Pyx_INCREF(Py_None);
17349   __Pyx_GIVEREF(Py_None);
17350   PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
17351   __pyx_v_dest_sig = ((PyObject*)__pyx_t_1);
17352   __pyx_t_1 = 0;
17353   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
17354   __pyx_t_4 = (__pyx_t_3 != 0);
17355   if (__pyx_t_4) {
17356   } else {
17357     __pyx_t_2 = __pyx_t_4;
17358     goto __pyx_L4_bool_binop_done;
17359   }
17360   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 752, __pyx_L1_error)
17361   __pyx_t_3 = ((!__pyx_t_4) != 0);
17362   __pyx_t_2 = __pyx_t_3;
17363   __pyx_L4_bool_binop_done:;
17364   if (__pyx_t_2) {
17365     __Pyx_INCREF(Py_None);
17366     __Pyx_DECREF_SET(__pyx_v_kwargs, Py_None);
17367   }
17368   __pyx_t_1 = ((PyObject *)__Pyx_ImportNumPyArrayTypeIfAvailable()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
17369   __Pyx_GOTREF(__pyx_t_1);
17370   __pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1);
17371   __pyx_t_1 = 0;
17372   __pyx_v_itemsize = -1L;
17373   if (unlikely(__pyx_v_args == Py_None)) {
17374     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
17375     __PYX_ERR(0, 752, __pyx_L1_error)
17376   }
17377   __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 752, __pyx_L1_error)
17378   __pyx_t_2 = ((0 < __pyx_t_5) != 0);
17379   if (__pyx_t_2) {
17380     if (unlikely(__pyx_v_args == Py_None)) {
17381       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
17382       __PYX_ERR(0, 752, __pyx_L1_error)
17383     }
17384     __pyx_t_1 = PyTuple_GET_ITEM(((PyObject*)__pyx_v_args), 0);
17385     __Pyx_INCREF(__pyx_t_1);
17386     __pyx_v_arg = __pyx_t_1;
17387     __pyx_t_1 = 0;
17388     goto __pyx_L6;
17389   }
17390   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
17391   __pyx_t_4 = (__pyx_t_3 != 0);
17392   if (__pyx_t_4) {
17393   } else {
17394     __pyx_t_2 = __pyx_t_4;
17395     goto __pyx_L7_bool_binop_done;
17396   }
17397   if (unlikely(__pyx_v_kwargs == Py_None)) {
17398     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
17399     __PYX_ERR(0, 752, __pyx_L1_error)
17400   }
17401   __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_delta_field, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 752, __pyx_L1_error)
17402   __pyx_t_3 = (__pyx_t_4 != 0);
17403   __pyx_t_2 = __pyx_t_3;
17404   __pyx_L7_bool_binop_done:;
17405   if (__pyx_t_2) {
17406     if (unlikely(__pyx_v_kwargs == Py_None)) {
17407       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
17408       __PYX_ERR(0, 752, __pyx_L1_error)
17409     }
17410     __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_delta_field); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
17411     __Pyx_GOTREF(__pyx_t_1);
17412     __pyx_v_arg = __pyx_t_1;
17413     __pyx_t_1 = 0;
17414     goto __pyx_L6;
17415   }
17416   /*else*/ {
17417     if (unlikely(__pyx_v_args == Py_None)) {
17418       PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
17419       __PYX_ERR(0, 752, __pyx_L1_error)
17420     }
17421     __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 752, __pyx_L1_error)
17422     __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
17423     __Pyx_GOTREF(__pyx_t_1);
17424     __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17425     __Pyx_GOTREF(__pyx_t_6);
17426     __Pyx_INCREF(__pyx_int_4);
17427     __Pyx_GIVEREF(__pyx_int_4);
17428     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_4);
17429     __Pyx_INCREF(__pyx_n_s_s);
17430     __Pyx_GIVEREF(__pyx_n_s_s);
17431     PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_s);
17432     __Pyx_GIVEREF(__pyx_t_1);
17433     PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
17434     __pyx_t_1 = 0;
17435     __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
17436     __Pyx_GOTREF(__pyx_t_1);
17437     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17438     __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17439     __Pyx_GOTREF(__pyx_t_6);
17440     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17441     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
17442     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17443     __PYX_ERR(0, 752, __pyx_L1_error)
17444   }
17445   __pyx_L6:;
17446   while (1) {
17447     __pyx_t_2 = (__pyx_v_ndarray != ((PyTypeObject*)Py_None));
17448     __pyx_t_3 = (__pyx_t_2 != 0);
17449     if (__pyx_t_3) {
17450       __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray);
17451       __pyx_t_2 = (__pyx_t_3 != 0);
17452       if (__pyx_t_2) {
17453         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17454         __Pyx_GOTREF(__pyx_t_6);
17455         __pyx_v_dtype = __pyx_t_6;
17456         __pyx_t_6 = 0;
17457         goto __pyx_L12;
17458       }
17459       __pyx_t_2 = __pyx_memoryview_check(__pyx_v_arg);
17460       __pyx_t_3 = (__pyx_t_2 != 0);
17461       if (__pyx_t_3) {
17462         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17463         __Pyx_GOTREF(__pyx_t_6);
17464         __pyx_v_arg_base = __pyx_t_6;
17465         __pyx_t_6 = 0;
17466         __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray);
17467         __pyx_t_2 = (__pyx_t_3 != 0);
17468         if (__pyx_t_2) {
17469           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17470           __Pyx_GOTREF(__pyx_t_6);
17471           __pyx_v_dtype = __pyx_t_6;
17472           __pyx_t_6 = 0;
17473           goto __pyx_L13;
17474         }
17475         /*else*/ {
17476           __Pyx_INCREF(Py_None);
17477           __pyx_v_dtype = Py_None;
17478         }
17479         __pyx_L13:;
17480         goto __pyx_L12;
17481       }
17482       /*else*/ {
17483         __Pyx_INCREF(Py_None);
17484         __pyx_v_dtype = Py_None;
17485       }
17486       __pyx_L12:;
17487       __pyx_v_itemsize = -1L;
17488       __pyx_t_2 = (__pyx_v_dtype != Py_None);
17489       __pyx_t_3 = (__pyx_t_2 != 0);
17490       if (__pyx_t_3) {
17491         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17492         __Pyx_GOTREF(__pyx_t_6);
17493         __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 752, __pyx_L1_error)
17494         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17495         __pyx_v_itemsize = __pyx_t_5;
17496         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17497         __Pyx_GOTREF(__pyx_t_6);
17498         __pyx_t_7 = __Pyx_PyObject_Ord(__pyx_t_6); if (unlikely(__pyx_t_7 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 752, __pyx_L1_error)
17499         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17500         __pyx_v_kind = __pyx_t_7;
17501         __pyx_v_dtype_signed = (__pyx_v_kind == 'i');
17502         switch (__pyx_v_kind) {
17503           case 'i':
17504           case 'u':
17505           break;
17506           case 'f':
17507           __pyx_t_2 = (((sizeof(float)) == __pyx_v_itemsize) != 0);
17508           if (__pyx_t_2) {
17509           } else {
17510             __pyx_t_3 = __pyx_t_2;
17511             goto __pyx_L16_bool_binop_done;
17512           }
17513           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17514           __Pyx_GOTREF(__pyx_t_6);
17515           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 752, __pyx_L1_error)
17516           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17517           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 2) != 0);
17518           __pyx_t_3 = __pyx_t_2;
17519           __pyx_L16_bool_binop_done:;
17520           if (__pyx_t_3) {
17521             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 752, __pyx_L1_error)
17522             goto __pyx_L10_break;
17523           }
17524           __pyx_t_2 = (((sizeof(double)) == __pyx_v_itemsize) != 0);
17525           if (__pyx_t_2) {
17526           } else {
17527             __pyx_t_3 = __pyx_t_2;
17528             goto __pyx_L19_bool_binop_done;
17529           }
17530           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17531           __Pyx_GOTREF(__pyx_t_6);
17532           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 752, __pyx_L1_error)
17533           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17534           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 2) != 0);
17535           __pyx_t_3 = __pyx_t_2;
17536           __pyx_L19_bool_binop_done:;
17537           if (__pyx_t_3) {
17538             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 752, __pyx_L1_error)
17539             goto __pyx_L10_break;
17540           }
17541           break;
17542           case 'c':
17543           break;
17544           case 'O':
17545           break;
17546           default: break;
17547         }
17548       }
17549     }
17550     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
17551     if (!__pyx_t_2) {
17552     } else {
17553       __pyx_t_3 = __pyx_t_2;
17554       goto __pyx_L22_bool_binop_done;
17555     }
17556     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(float))) != 0);
17557     __pyx_t_3 = __pyx_t_2;
17558     __pyx_L22_bool_binop_done:;
17559     if (__pyx_t_3) {
17560       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_v_arg, 0);
17561       __pyx_v_memslice = __pyx_t_8;
17562       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
17563       if (__pyx_t_3) {
17564         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
17565         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 752, __pyx_L1_error)
17566         goto __pyx_L10_break;
17567       }
17568       /*else*/ {
17569         PyErr_Clear();
17570       }
17571     }
17572     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
17573     if (!__pyx_t_2) {
17574     } else {
17575       __pyx_t_3 = __pyx_t_2;
17576       goto __pyx_L26_bool_binop_done;
17577     }
17578     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(double))) != 0);
17579     __pyx_t_3 = __pyx_t_2;
17580     __pyx_L26_bool_binop_done:;
17581     if (__pyx_t_3) {
17582       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(__pyx_v_arg, 0);
17583       __pyx_v_memslice = __pyx_t_8;
17584       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
17585       if (__pyx_t_3) {
17586         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
17587         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 752, __pyx_L1_error)
17588         goto __pyx_L10_break;
17589       }
17590       /*else*/ {
17591         PyErr_Clear();
17592       }
17593     }
17594     if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 752, __pyx_L1_error)
17595     goto __pyx_L10_break;
17596   }
17597   __pyx_L10_break:;
17598   __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17599   __Pyx_GOTREF(__pyx_t_6);
17600   __pyx_v_candidates = ((PyObject*)__pyx_t_6);
17601   __pyx_t_6 = 0;
17602   __pyx_t_5 = 0;
17603   if (unlikely(__pyx_v_signatures == Py_None)) {
17604     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
17605     __PYX_ERR(0, 752, __pyx_L1_error)
17606   }
17607   __pyx_t_1 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
17608   __Pyx_GOTREF(__pyx_t_1);
17609   __Pyx_XDECREF(__pyx_t_6);
17610   __pyx_t_6 = __pyx_t_1;
17611   __pyx_t_1 = 0;
17612   while (1) {
17613     __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_5, &__pyx_t_1, NULL, NULL, __pyx_t_10);
17614     if (unlikely(__pyx_t_11 == 0)) break;
17615     if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 752, __pyx_L1_error)
17616     __Pyx_GOTREF(__pyx_t_1);
17617     __Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_1);
17618     __pyx_t_1 = 0;
17619     __pyx_v_match_found = 0;
17620     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 752, __pyx_L1_error)
17621     __Pyx_GOTREF(__pyx_t_13);
17622     __pyx_t_14 = NULL;
17623     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
17624       __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
17625       if (likely(__pyx_t_14)) {
17626         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
17627         __Pyx_INCREF(__pyx_t_14);
17628         __Pyx_INCREF(function);
17629         __Pyx_DECREF_SET(__pyx_t_13, function);
17630       }
17631     }
17632     __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_kp_s__3) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__3);
17633     __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
17634     if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 752, __pyx_L1_error)
17635     __Pyx_GOTREF(__pyx_t_12);
17636     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
17637     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_split); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 752, __pyx_L1_error)
17638     __Pyx_GOTREF(__pyx_t_13);
17639     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
17640     __pyx_t_12 = NULL;
17641     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
17642       __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
17643       if (likely(__pyx_t_12)) {
17644         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
17645         __Pyx_INCREF(__pyx_t_12);
17646         __Pyx_INCREF(function);
17647         __Pyx_DECREF_SET(__pyx_t_13, function);
17648       }
17649     }
17650     __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_kp_s__4) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__4);
17651     __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
17652     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
17653     __Pyx_GOTREF(__pyx_t_1);
17654     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
17655     __Pyx_XDECREF_SET(__pyx_v_src_sig, __pyx_t_1);
17656     __pyx_t_1 = 0;
17657     __pyx_t_15 = PyList_GET_SIZE(__pyx_v_dest_sig); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 752, __pyx_L1_error)
17658     __pyx_t_16 = __pyx_t_15;
17659     for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
17660       __pyx_v_i = __pyx_t_17;
17661       __pyx_t_1 = PyList_GET_ITEM(__pyx_v_dest_sig, __pyx_v_i);
17662       __Pyx_INCREF(__pyx_t_1);
17663       __Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_1);
17664       __pyx_t_1 = 0;
17665       __pyx_t_3 = (__pyx_v_dst_type != Py_None);
17666       __pyx_t_2 = (__pyx_t_3 != 0);
17667       if (__pyx_t_2) {
17668         __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
17669         __Pyx_GOTREF(__pyx_t_1);
17670         __pyx_t_13 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 752, __pyx_L1_error)
17671         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17672         __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 752, __pyx_L1_error)
17673         __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
17674         if (__pyx_t_2) {
17675           __pyx_v_match_found = 1;
17676           goto __pyx_L34;
17677         }
17678         /*else*/ {
17679           __pyx_v_match_found = 0;
17680           goto __pyx_L32_break;
17681         }
17682         __pyx_L34:;
17683       }
17684     }
17685     __pyx_L32_break:;
17686     __pyx_t_2 = (__pyx_v_match_found != 0);
17687     if (__pyx_t_2) {
17688       __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 752, __pyx_L1_error)
17689     }
17690   }
17691   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17692   __pyx_t_2 = (PyList_GET_SIZE(__pyx_v_candidates) != 0);
17693   __pyx_t_3 = ((!__pyx_t_2) != 0);
17694   if (__pyx_t_3) {
17695     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17696     __Pyx_GOTREF(__pyx_t_6);
17697     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
17698     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17699     __PYX_ERR(0, 752, __pyx_L1_error)
17700   }
17701   __pyx_t_9 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 752, __pyx_L1_error)
17702   __pyx_t_3 = ((__pyx_t_9 > 1) != 0);
17703   if (__pyx_t_3) {
17704     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17705     __Pyx_GOTREF(__pyx_t_6);
17706     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
17707     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17708     __PYX_ERR(0, 752, __pyx_L1_error)
17709   }
17710   /*else*/ {
17711     __Pyx_XDECREF(__pyx_r);
17712     if (unlikely(__pyx_v_signatures == Py_None)) {
17713       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
17714       __PYX_ERR(0, 752, __pyx_L1_error)
17715     }
17716     __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), PyList_GET_ITEM(__pyx_v_candidates, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 752, __pyx_L1_error)
17717     __Pyx_GOTREF(__pyx_t_6);
17718     __pyx_r = __pyx_t_6;
17719     __pyx_t_6 = 0;
17720     goto __pyx_L0;
17721   }
17722 
17723   /* function exit code */
17724   __pyx_L1_error:;
17725   __Pyx_XDECREF(__pyx_t_1);
17726   __Pyx_XDECREF(__pyx_t_6);
17727   __Pyx_XDECREF(__pyx_t_12);
17728   __Pyx_XDECREF(__pyx_t_13);
17729   __Pyx_XDECREF(__pyx_t_14);
17730   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
17731   __pyx_r = NULL;
17732   __pyx_L0:;
17733   __Pyx_XDECREF(__pyx_v_dest_sig);
17734   __Pyx_XDECREF(__pyx_v_ndarray);
17735   __Pyx_XDECREF(__pyx_v_arg);
17736   __Pyx_XDECREF(__pyx_v_dtype);
17737   __Pyx_XDECREF(__pyx_v_arg_base);
17738   __Pyx_XDECREF(__pyx_v_candidates);
17739   __Pyx_XDECREF(__pyx_v_sig);
17740   __Pyx_XDECREF(__pyx_v_src_sig);
17741   __Pyx_XDECREF(__pyx_v_dst_type);
17742   __Pyx_XDECREF(__pyx_v_kwargs);
17743   __Pyx_XGIVEREF(__pyx_r);
17744   __Pyx_RefNannyFinishContext();
17745   return __pyx_r;
17746 }
17747 
17748 /* Python wrapper */
17749 static PyObject *__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_57compute_ssd_demons_step_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
17750 static PyMethodDef __pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_57compute_ssd_demons_step_2d = {"__pyx_fuse_0compute_ssd_demons_step_2d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_57compute_ssd_demons_step_2d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_16compute_ssd_demons_step_2d};
__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_57compute_ssd_demons_step_2d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)17751 static PyObject *__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_57compute_ssd_demons_step_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
17752   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
17753   __Pyx_memviewslice __pyx_v_gradient_moving = { 0, 0, { 0 }, { 0 }, { 0 } };
17754   double __pyx_v_sigma_sq_x;
17755   __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
17756   int __pyx_lineno = 0;
17757   const char *__pyx_filename = NULL;
17758   int __pyx_clineno = 0;
17759   PyObject *__pyx_r = 0;
17760   __Pyx_RefNannyDeclarations
17761   __Pyx_RefNannySetupContext("compute_ssd_demons_step_2d (wrapper)", 0);
17762   {
17763     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_gradient_moving,&__pyx_n_s_sigma_sq_x,&__pyx_n_s_out,0};
17764     PyObject* values[4] = {0,0,0,0};
17765     if (unlikely(__pyx_kwds)) {
17766       Py_ssize_t kw_args;
17767       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
17768       switch (pos_args) {
17769         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
17770         CYTHON_FALLTHROUGH;
17771         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
17772         CYTHON_FALLTHROUGH;
17773         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
17774         CYTHON_FALLTHROUGH;
17775         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
17776         CYTHON_FALLTHROUGH;
17777         case  0: break;
17778         default: goto __pyx_L5_argtuple_error;
17779       }
17780       kw_args = PyDict_Size(__pyx_kwds);
17781       switch (pos_args) {
17782         case  0:
17783         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
17784         else goto __pyx_L5_argtuple_error;
17785         CYTHON_FALLTHROUGH;
17786         case  1:
17787         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gradient_moving)) != 0)) kw_args--;
17788         else {
17789           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_2d", 1, 4, 4, 1); __PYX_ERR(0, 752, __pyx_L3_error)
17790         }
17791         CYTHON_FALLTHROUGH;
17792         case  2:
17793         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma_sq_x)) != 0)) kw_args--;
17794         else {
17795           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_2d", 1, 4, 4, 2); __PYX_ERR(0, 752, __pyx_L3_error)
17796         }
17797         CYTHON_FALLTHROUGH;
17798         case  3:
17799         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
17800         else {
17801           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_2d", 1, 4, 4, 3); __PYX_ERR(0, 752, __pyx_L3_error)
17802         }
17803       }
17804       if (unlikely(kw_args > 0)) {
17805         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compute_ssd_demons_step_2d") < 0)) __PYX_ERR(0, 752, __pyx_L3_error)
17806       }
17807     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
17808       goto __pyx_L5_argtuple_error;
17809     } else {
17810       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
17811       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
17812       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
17813       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
17814     }
17815     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 752, __pyx_L3_error)
17816     __pyx_v_gradient_moving = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_gradient_moving.memview)) __PYX_ERR(0, 753, __pyx_L3_error)
17817     __pyx_v_sigma_sq_x = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_sigma_sq_x == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 754, __pyx_L3_error)
17818     __pyx_v_out = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_out.memview)) __PYX_ERR(0, 755, __pyx_L3_error)
17819   }
17820   goto __pyx_L4_argument_unpacking_done;
17821   __pyx_L5_argtuple_error:;
17822   __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_2d", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 752, __pyx_L3_error)
17823   __pyx_L3_error:;
17824   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_ssd_demons_step_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
17825   __Pyx_RefNannyFinishContext();
17826   return NULL;
17827   __pyx_L4_argument_unpacking_done:;
17828   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_56compute_ssd_demons_step_2d(__pyx_self, __pyx_v_delta_field, __pyx_v_gradient_moving, __pyx_v_sigma_sq_x, __pyx_v_out);
17829 
17830   /* function exit code */
17831   __Pyx_RefNannyFinishContext();
17832   return __pyx_r;
17833 }
17834 
__pyx_pf_4dipy_5align_9sumsqdiff_56compute_ssd_demons_step_2d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_gradient_moving,double __pyx_v_sigma_sq_x,__Pyx_memviewslice __pyx_v_out)17835 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_56compute_ssd_demons_step_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_gradient_moving, double __pyx_v_sigma_sq_x, __Pyx_memviewslice __pyx_v_out) {
17836   npy_intp __pyx_v_nr;
17837   npy_intp __pyx_v_nc;
17838   npy_intp __pyx_v_i;
17839   npy_intp __pyx_v_j;
17840   double __pyx_v_delta;
17841   double __pyx_v_delta_2;
17842   double __pyx_v_nrm2;
17843   double __pyx_v_energy;
17844   double __pyx_v_den;
17845   PyObject *__pyx_r = NULL;
17846   __Pyx_RefNannyDeclarations
17847   int __pyx_t_1;
17848   PyObject *__pyx_t_2 = NULL;
17849   PyObject *__pyx_t_3 = NULL;
17850   PyObject *__pyx_t_4 = NULL;
17851   PyObject *__pyx_t_5 = NULL;
17852   PyObject *__pyx_t_6 = NULL;
17853   PyObject *__pyx_t_7 = NULL;
17854   PyObject *__pyx_t_8 = NULL;
17855   __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } };
17856   npy_intp __pyx_t_10;
17857   npy_intp __pyx_t_11;
17858   npy_intp __pyx_t_12;
17859   npy_intp __pyx_t_13;
17860   npy_intp __pyx_t_14;
17861   npy_intp __pyx_t_15;
17862   Py_ssize_t __pyx_t_16;
17863   Py_ssize_t __pyx_t_17;
17864   Py_ssize_t __pyx_t_18;
17865   Py_ssize_t __pyx_t_19;
17866   Py_ssize_t __pyx_t_20;
17867   Py_ssize_t __pyx_t_21;
17868   int __pyx_lineno = 0;
17869   const char *__pyx_filename = NULL;
17870   int __pyx_clineno = 0;
17871   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_ssd_demons_step_2d", 0);
17872 
17873   /* "dipy/align/sumsqdiff.pyx":795
17874  *     """
17875  *     cdef:
17876  *         cnp.npy_intp nr = delta_field.shape[0]             # <<<<<<<<<<<<<<
17877  *         cnp.npy_intp nc = delta_field.shape[1]
17878  *         cnp.npy_intp i, j
17879  */
17880   __pyx_v_nr = (__pyx_v_delta_field.shape[0]);
17881 
17882   /* "dipy/align/sumsqdiff.pyx":796
17883  *     cdef:
17884  *         cnp.npy_intp nr = delta_field.shape[0]
17885  *         cnp.npy_intp nc = delta_field.shape[1]             # <<<<<<<<<<<<<<
17886  *         cnp.npy_intp i, j
17887  *         double delta, delta_2, nrm2, energy, den
17888  */
17889   __pyx_v_nc = (__pyx_v_delta_field.shape[1]);
17890 
17891   /* "dipy/align/sumsqdiff.pyx":800
17892  *         double delta, delta_2, nrm2, energy, den
17893  *
17894  *     if out is None:             # <<<<<<<<<<<<<<
17895  *         out = np.zeros((nr, nc, 2), dtype=np.asarray(delta_field).dtype)
17896  *
17897  */
17898   __pyx_t_1 = ((((PyObject *) __pyx_v_out.memview) == Py_None) != 0);
17899   if (__pyx_t_1) {
17900 
17901     /* "dipy/align/sumsqdiff.pyx":801
17902  *
17903  *     if out is None:
17904  *         out = np.zeros((nr, nc, 2), dtype=np.asarray(delta_field).dtype)             # <<<<<<<<<<<<<<
17905  *
17906  *     with nogil:
17907  */
17908     __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 801, __pyx_L1_error)
17909     __Pyx_GOTREF(__pyx_t_2);
17910     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 801, __pyx_L1_error)
17911     __Pyx_GOTREF(__pyx_t_3);
17912     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17913     __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 801, __pyx_L1_error)
17914     __Pyx_GOTREF(__pyx_t_2);
17915     __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 801, __pyx_L1_error)
17916     __Pyx_GOTREF(__pyx_t_4);
17917     __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 801, __pyx_L1_error)
17918     __Pyx_GOTREF(__pyx_t_5);
17919     __Pyx_GIVEREF(__pyx_t_2);
17920     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
17921     __Pyx_GIVEREF(__pyx_t_4);
17922     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
17923     __Pyx_INCREF(__pyx_int_2);
17924     __Pyx_GIVEREF(__pyx_int_2);
17925     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_int_2);
17926     __pyx_t_2 = 0;
17927     __pyx_t_4 = 0;
17928     __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 801, __pyx_L1_error)
17929     __Pyx_GOTREF(__pyx_t_4);
17930     __Pyx_GIVEREF(__pyx_t_5);
17931     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
17932     __pyx_t_5 = 0;
17933     __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 801, __pyx_L1_error)
17934     __Pyx_GOTREF(__pyx_t_5);
17935     __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 801, __pyx_L1_error)
17936     __Pyx_GOTREF(__pyx_t_6);
17937     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_asarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 801, __pyx_L1_error)
17938     __Pyx_GOTREF(__pyx_t_7);
17939     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17940     __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 801, __pyx_L1_error)
17941     __Pyx_GOTREF(__pyx_t_6);
17942     __pyx_t_8 = NULL;
17943     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
17944       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
17945       if (likely(__pyx_t_8)) {
17946         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
17947         __Pyx_INCREF(__pyx_t_8);
17948         __Pyx_INCREF(function);
17949         __Pyx_DECREF_SET(__pyx_t_7, function);
17950       }
17951     }
17952     __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
17953     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
17954     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
17955     if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 801, __pyx_L1_error)
17956     __Pyx_GOTREF(__pyx_t_2);
17957     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
17958     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 801, __pyx_L1_error)
17959     __Pyx_GOTREF(__pyx_t_7);
17960     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17961     if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 801, __pyx_L1_error)
17962     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
17963     __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 801, __pyx_L1_error)
17964     __Pyx_GOTREF(__pyx_t_7);
17965     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17966     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
17967     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
17968     __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 801, __pyx_L1_error)
17969     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
17970     __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
17971     __pyx_v_out = __pyx_t_9;
17972     __pyx_t_9.memview = NULL;
17973     __pyx_t_9.data = NULL;
17974 
17975     /* "dipy/align/sumsqdiff.pyx":800
17976  *         double delta, delta_2, nrm2, energy, den
17977  *
17978  *     if out is None:             # <<<<<<<<<<<<<<
17979  *         out = np.zeros((nr, nc, 2), dtype=np.asarray(delta_field).dtype)
17980  *
17981  */
17982   }
17983 
17984   /* "dipy/align/sumsqdiff.pyx":803
17985  *         out = np.zeros((nr, nc, 2), dtype=np.asarray(delta_field).dtype)
17986  *
17987  *     with nogil:             # <<<<<<<<<<<<<<
17988  *
17989  *         energy = 0
17990  */
17991   {
17992       #ifdef WITH_THREAD
17993       PyThreadState *_save;
17994       Py_UNBLOCK_THREADS
17995       __Pyx_FastGIL_Remember();
17996       #endif
17997       /*try:*/ {
17998 
17999         /* "dipy/align/sumsqdiff.pyx":805
18000  *     with nogil:
18001  *
18002  *         energy = 0             # <<<<<<<<<<<<<<
18003  *         for i in range(nr):
18004  *             for j in range(nc):
18005  */
18006         __pyx_v_energy = 0.0;
18007 
18008         /* "dipy/align/sumsqdiff.pyx":806
18009  *
18010  *         energy = 0
18011  *         for i in range(nr):             # <<<<<<<<<<<<<<
18012  *             for j in range(nc):
18013  *                 delta = delta_field[i,j]
18014  */
18015         __pyx_t_10 = __pyx_v_nr;
18016         __pyx_t_11 = __pyx_t_10;
18017         for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
18018           __pyx_v_i = __pyx_t_12;
18019 
18020           /* "dipy/align/sumsqdiff.pyx":807
18021  *         energy = 0
18022  *         for i in range(nr):
18023  *             for j in range(nc):             # <<<<<<<<<<<<<<
18024  *                 delta = delta_field[i,j]
18025  *                 delta_2 = delta**2
18026  */
18027           __pyx_t_13 = __pyx_v_nc;
18028           __pyx_t_14 = __pyx_t_13;
18029           for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
18030             __pyx_v_j = __pyx_t_15;
18031 
18032             /* "dipy/align/sumsqdiff.pyx":808
18033  *         for i in range(nr):
18034  *             for j in range(nc):
18035  *                 delta = delta_field[i,j]             # <<<<<<<<<<<<<<
18036  *                 delta_2 = delta**2
18037  *                 energy += delta_2
18038  */
18039             __pyx_t_16 = __pyx_v_i;
18040             __pyx_t_17 = __pyx_v_j;
18041             __pyx_v_delta = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_16 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_17 * __pyx_v_delta_field.strides[1]) )));
18042 
18043             /* "dipy/align/sumsqdiff.pyx":809
18044  *             for j in range(nc):
18045  *                 delta = delta_field[i,j]
18046  *                 delta_2 = delta**2             # <<<<<<<<<<<<<<
18047  *                 energy += delta_2
18048  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2
18049  */
18050             __pyx_v_delta_2 = pow(__pyx_v_delta, 2.0);
18051 
18052             /* "dipy/align/sumsqdiff.pyx":810
18053  *                 delta = delta_field[i,j]
18054  *                 delta_2 = delta**2
18055  *                 energy += delta_2             # <<<<<<<<<<<<<<
18056  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2
18057  *                 den = delta_2/sigma_sq_x + nrm2
18058  */
18059             __pyx_v_energy = (__pyx_v_energy + __pyx_v_delta_2);
18060 
18061             /* "dipy/align/sumsqdiff.pyx":811
18062  *                 delta_2 = delta**2
18063  *                 energy += delta_2
18064  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2             # <<<<<<<<<<<<<<
18065  *                 den = delta_2/sigma_sq_x + nrm2
18066  *                 if den <1e-9:
18067  */
18068             __pyx_t_17 = __pyx_v_i;
18069             __pyx_t_16 = __pyx_v_j;
18070             __pyx_t_18 = 0;
18071             __pyx_t_19 = __pyx_v_i;
18072             __pyx_t_20 = __pyx_v_j;
18073             __pyx_t_21 = 1;
18074             __pyx_v_nrm2 = (powf((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_17 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_16 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_18 * __pyx_v_gradient_moving.strides[2]) ))), 2.0) + powf((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_19 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_20 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_21 * __pyx_v_gradient_moving.strides[2]) ))), 2.0));
18075 
18076             /* "dipy/align/sumsqdiff.pyx":812
18077  *                 energy += delta_2
18078  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2
18079  *                 den = delta_2/sigma_sq_x + nrm2             # <<<<<<<<<<<<<<
18080  *                 if den <1e-9:
18081  *                     out[i, j, 0] = 0
18082  */
18083             __pyx_v_den = ((__pyx_v_delta_2 / __pyx_v_sigma_sq_x) + __pyx_v_nrm2);
18084 
18085             /* "dipy/align/sumsqdiff.pyx":813
18086  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2
18087  *                 den = delta_2/sigma_sq_x + nrm2
18088  *                 if den <1e-9:             # <<<<<<<<<<<<<<
18089  *                     out[i, j, 0] = 0
18090  *                     out[i, j, 1] = 0
18091  */
18092             __pyx_t_1 = ((__pyx_v_den < 1e-9) != 0);
18093             if (__pyx_t_1) {
18094 
18095               /* "dipy/align/sumsqdiff.pyx":814
18096  *                 den = delta_2/sigma_sq_x + nrm2
18097  *                 if den <1e-9:
18098  *                     out[i, j, 0] = 0             # <<<<<<<<<<<<<<
18099  *                     out[i, j, 1] = 0
18100  *                 else:
18101  */
18102               __pyx_t_21 = __pyx_v_i;
18103               __pyx_t_20 = __pyx_v_j;
18104               __pyx_t_19 = 0;
18105               *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_21 * __pyx_v_out.strides[0]) ) + __pyx_t_20 * __pyx_v_out.strides[1]) ) + __pyx_t_19 * __pyx_v_out.strides[2]) )) = 0.0;
18106 
18107               /* "dipy/align/sumsqdiff.pyx":815
18108  *                 if den <1e-9:
18109  *                     out[i, j, 0] = 0
18110  *                     out[i, j, 1] = 0             # <<<<<<<<<<<<<<
18111  *                 else:
18112  *                     out[i, j, 0] = delta * gradient_moving[i, j, 0] / den
18113  */
18114               __pyx_t_19 = __pyx_v_i;
18115               __pyx_t_20 = __pyx_v_j;
18116               __pyx_t_21 = 1;
18117               *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_19 * __pyx_v_out.strides[0]) ) + __pyx_t_20 * __pyx_v_out.strides[1]) ) + __pyx_t_21 * __pyx_v_out.strides[2]) )) = 0.0;
18118 
18119               /* "dipy/align/sumsqdiff.pyx":813
18120  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2
18121  *                 den = delta_2/sigma_sq_x + nrm2
18122  *                 if den <1e-9:             # <<<<<<<<<<<<<<
18123  *                     out[i, j, 0] = 0
18124  *                     out[i, j, 1] = 0
18125  */
18126               goto __pyx_L11;
18127             }
18128 
18129             /* "dipy/align/sumsqdiff.pyx":817
18130  *                     out[i, j, 1] = 0
18131  *                 else:
18132  *                     out[i, j, 0] = delta * gradient_moving[i, j, 0] / den             # <<<<<<<<<<<<<<
18133  *                     out[i, j, 1] = delta * gradient_moving[i, j, 1] / den
18134  *
18135  */
18136             /*else*/ {
18137               __pyx_t_21 = __pyx_v_i;
18138               __pyx_t_20 = __pyx_v_j;
18139               __pyx_t_19 = 0;
18140               __pyx_t_18 = __pyx_v_i;
18141               __pyx_t_16 = __pyx_v_j;
18142               __pyx_t_17 = 0;
18143               *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_18 * __pyx_v_out.strides[0]) ) + __pyx_t_16 * __pyx_v_out.strides[1]) ) + __pyx_t_17 * __pyx_v_out.strides[2]) )) = ((__pyx_v_delta * (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_21 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_20 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_19 * __pyx_v_gradient_moving.strides[2]) )))) / __pyx_v_den);
18144 
18145               /* "dipy/align/sumsqdiff.pyx":818
18146  *                 else:
18147  *                     out[i, j, 0] = delta * gradient_moving[i, j, 0] / den
18148  *                     out[i, j, 1] = delta * gradient_moving[i, j, 1] / den             # <<<<<<<<<<<<<<
18149  *
18150  *     return np.asarray(out), energy
18151  */
18152               __pyx_t_19 = __pyx_v_i;
18153               __pyx_t_20 = __pyx_v_j;
18154               __pyx_t_21 = 1;
18155               __pyx_t_17 = __pyx_v_i;
18156               __pyx_t_16 = __pyx_v_j;
18157               __pyx_t_18 = 1;
18158               *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_17 * __pyx_v_out.strides[0]) ) + __pyx_t_16 * __pyx_v_out.strides[1]) ) + __pyx_t_18 * __pyx_v_out.strides[2]) )) = ((__pyx_v_delta * (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_19 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_20 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_21 * __pyx_v_gradient_moving.strides[2]) )))) / __pyx_v_den);
18159             }
18160             __pyx_L11:;
18161           }
18162         }
18163       }
18164 
18165       /* "dipy/align/sumsqdiff.pyx":803
18166  *         out = np.zeros((nr, nc, 2), dtype=np.asarray(delta_field).dtype)
18167  *
18168  *     with nogil:             # <<<<<<<<<<<<<<
18169  *
18170  *         energy = 0
18171  */
18172       /*finally:*/ {
18173         /*normal exit:*/{
18174           #ifdef WITH_THREAD
18175           __Pyx_FastGIL_Forget();
18176           Py_BLOCK_THREADS
18177           #endif
18178           goto __pyx_L6;
18179         }
18180         __pyx_L6:;
18181       }
18182   }
18183 
18184   /* "dipy/align/sumsqdiff.pyx":820
18185  *                     out[i, j, 1] = delta * gradient_moving[i, j, 1] / den
18186  *
18187  *     return np.asarray(out), energy             # <<<<<<<<<<<<<<
18188  *
18189  *
18190  */
18191   __Pyx_XDECREF(__pyx_r);
18192   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 820, __pyx_L1_error)
18193   __Pyx_GOTREF(__pyx_t_5);
18194   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 820, __pyx_L1_error)
18195   __Pyx_GOTREF(__pyx_t_4);
18196   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
18197   __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_out, 3, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 820, __pyx_L1_error)
18198   __Pyx_GOTREF(__pyx_t_5);
18199   __pyx_t_3 = NULL;
18200   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
18201     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
18202     if (likely(__pyx_t_3)) {
18203       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
18204       __Pyx_INCREF(__pyx_t_3);
18205       __Pyx_INCREF(function);
18206       __Pyx_DECREF_SET(__pyx_t_4, function);
18207     }
18208   }
18209   __pyx_t_7 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
18210   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
18211   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
18212   if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 820, __pyx_L1_error)
18213   __Pyx_GOTREF(__pyx_t_7);
18214   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
18215   __pyx_t_4 = PyFloat_FromDouble(__pyx_v_energy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 820, __pyx_L1_error)
18216   __Pyx_GOTREF(__pyx_t_4);
18217   __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 820, __pyx_L1_error)
18218   __Pyx_GOTREF(__pyx_t_5);
18219   __Pyx_GIVEREF(__pyx_t_7);
18220   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7);
18221   __Pyx_GIVEREF(__pyx_t_4);
18222   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
18223   __pyx_t_7 = 0;
18224   __pyx_t_4 = 0;
18225   __pyx_r = __pyx_t_5;
18226   __pyx_t_5 = 0;
18227   goto __pyx_L0;
18228 
18229   /* "dipy/align/sumsqdiff.pyx":752
18230  * @cython.wraparound(False)
18231  * @cython.cdivision(True)
18232  * def compute_ssd_demons_step_2d(floating[:,:] delta_field,             # <<<<<<<<<<<<<<
18233  *                                floating[:,:,:] gradient_moving,
18234  *                                double sigma_sq_x,
18235  */
18236 
18237   /* function exit code */
18238   __pyx_L1_error:;
18239   __Pyx_XDECREF(__pyx_t_2);
18240   __Pyx_XDECREF(__pyx_t_3);
18241   __Pyx_XDECREF(__pyx_t_4);
18242   __Pyx_XDECREF(__pyx_t_5);
18243   __Pyx_XDECREF(__pyx_t_6);
18244   __Pyx_XDECREF(__pyx_t_7);
18245   __Pyx_XDECREF(__pyx_t_8);
18246   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
18247   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_ssd_demons_step_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
18248   __pyx_r = NULL;
18249   __pyx_L0:;
18250   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
18251   __PYX_XDEC_MEMVIEW(&__pyx_v_gradient_moving, 1);
18252   __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
18253   __Pyx_XGIVEREF(__pyx_r);
18254   __Pyx_RefNannyFinishContext();
18255   return __pyx_r;
18256 }
18257 
18258 /* Python wrapper */
18259 static PyObject *__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_59compute_ssd_demons_step_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
18260 static PyMethodDef __pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_59compute_ssd_demons_step_2d = {"__pyx_fuse_1compute_ssd_demons_step_2d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_59compute_ssd_demons_step_2d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_16compute_ssd_demons_step_2d};
__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_59compute_ssd_demons_step_2d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)18261 static PyObject *__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_59compute_ssd_demons_step_2d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
18262   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
18263   __Pyx_memviewslice __pyx_v_gradient_moving = { 0, 0, { 0 }, { 0 }, { 0 } };
18264   double __pyx_v_sigma_sq_x;
18265   __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
18266   int __pyx_lineno = 0;
18267   const char *__pyx_filename = NULL;
18268   int __pyx_clineno = 0;
18269   PyObject *__pyx_r = 0;
18270   __Pyx_RefNannyDeclarations
18271   __Pyx_RefNannySetupContext("compute_ssd_demons_step_2d (wrapper)", 0);
18272   {
18273     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_gradient_moving,&__pyx_n_s_sigma_sq_x,&__pyx_n_s_out,0};
18274     PyObject* values[4] = {0,0,0,0};
18275     if (unlikely(__pyx_kwds)) {
18276       Py_ssize_t kw_args;
18277       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
18278       switch (pos_args) {
18279         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
18280         CYTHON_FALLTHROUGH;
18281         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
18282         CYTHON_FALLTHROUGH;
18283         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
18284         CYTHON_FALLTHROUGH;
18285         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
18286         CYTHON_FALLTHROUGH;
18287         case  0: break;
18288         default: goto __pyx_L5_argtuple_error;
18289       }
18290       kw_args = PyDict_Size(__pyx_kwds);
18291       switch (pos_args) {
18292         case  0:
18293         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
18294         else goto __pyx_L5_argtuple_error;
18295         CYTHON_FALLTHROUGH;
18296         case  1:
18297         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gradient_moving)) != 0)) kw_args--;
18298         else {
18299           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_2d", 1, 4, 4, 1); __PYX_ERR(0, 752, __pyx_L3_error)
18300         }
18301         CYTHON_FALLTHROUGH;
18302         case  2:
18303         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma_sq_x)) != 0)) kw_args--;
18304         else {
18305           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_2d", 1, 4, 4, 2); __PYX_ERR(0, 752, __pyx_L3_error)
18306         }
18307         CYTHON_FALLTHROUGH;
18308         case  3:
18309         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
18310         else {
18311           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_2d", 1, 4, 4, 3); __PYX_ERR(0, 752, __pyx_L3_error)
18312         }
18313       }
18314       if (unlikely(kw_args > 0)) {
18315         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compute_ssd_demons_step_2d") < 0)) __PYX_ERR(0, 752, __pyx_L3_error)
18316       }
18317     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
18318       goto __pyx_L5_argtuple_error;
18319     } else {
18320       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
18321       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
18322       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
18323       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
18324     }
18325     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsds_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 752, __pyx_L3_error)
18326     __pyx_v_gradient_moving = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_gradient_moving.memview)) __PYX_ERR(0, 753, __pyx_L3_error)
18327     __pyx_v_sigma_sq_x = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_sigma_sq_x == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 754, __pyx_L3_error)
18328     __pyx_v_out = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_out.memview)) __PYX_ERR(0, 755, __pyx_L3_error)
18329   }
18330   goto __pyx_L4_argument_unpacking_done;
18331   __pyx_L5_argtuple_error:;
18332   __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_2d", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 752, __pyx_L3_error)
18333   __pyx_L3_error:;
18334   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_ssd_demons_step_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
18335   __Pyx_RefNannyFinishContext();
18336   return NULL;
18337   __pyx_L4_argument_unpacking_done:;
18338   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_58compute_ssd_demons_step_2d(__pyx_self, __pyx_v_delta_field, __pyx_v_gradient_moving, __pyx_v_sigma_sq_x, __pyx_v_out);
18339 
18340   /* function exit code */
18341   __Pyx_RefNannyFinishContext();
18342   return __pyx_r;
18343 }
18344 
__pyx_pf_4dipy_5align_9sumsqdiff_58compute_ssd_demons_step_2d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_gradient_moving,double __pyx_v_sigma_sq_x,__Pyx_memviewslice __pyx_v_out)18345 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_58compute_ssd_demons_step_2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_gradient_moving, double __pyx_v_sigma_sq_x, __Pyx_memviewslice __pyx_v_out) {
18346   npy_intp __pyx_v_nr;
18347   npy_intp __pyx_v_nc;
18348   npy_intp __pyx_v_i;
18349   npy_intp __pyx_v_j;
18350   double __pyx_v_delta;
18351   double __pyx_v_delta_2;
18352   double __pyx_v_nrm2;
18353   double __pyx_v_energy;
18354   double __pyx_v_den;
18355   PyObject *__pyx_r = NULL;
18356   __Pyx_RefNannyDeclarations
18357   int __pyx_t_1;
18358   PyObject *__pyx_t_2 = NULL;
18359   PyObject *__pyx_t_3 = NULL;
18360   PyObject *__pyx_t_4 = NULL;
18361   PyObject *__pyx_t_5 = NULL;
18362   PyObject *__pyx_t_6 = NULL;
18363   PyObject *__pyx_t_7 = NULL;
18364   PyObject *__pyx_t_8 = NULL;
18365   __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } };
18366   npy_intp __pyx_t_10;
18367   npy_intp __pyx_t_11;
18368   npy_intp __pyx_t_12;
18369   npy_intp __pyx_t_13;
18370   npy_intp __pyx_t_14;
18371   npy_intp __pyx_t_15;
18372   Py_ssize_t __pyx_t_16;
18373   Py_ssize_t __pyx_t_17;
18374   Py_ssize_t __pyx_t_18;
18375   Py_ssize_t __pyx_t_19;
18376   Py_ssize_t __pyx_t_20;
18377   Py_ssize_t __pyx_t_21;
18378   int __pyx_lineno = 0;
18379   const char *__pyx_filename = NULL;
18380   int __pyx_clineno = 0;
18381   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_ssd_demons_step_2d", 0);
18382 
18383   /* "dipy/align/sumsqdiff.pyx":795
18384  *     """
18385  *     cdef:
18386  *         cnp.npy_intp nr = delta_field.shape[0]             # <<<<<<<<<<<<<<
18387  *         cnp.npy_intp nc = delta_field.shape[1]
18388  *         cnp.npy_intp i, j
18389  */
18390   __pyx_v_nr = (__pyx_v_delta_field.shape[0]);
18391 
18392   /* "dipy/align/sumsqdiff.pyx":796
18393  *     cdef:
18394  *         cnp.npy_intp nr = delta_field.shape[0]
18395  *         cnp.npy_intp nc = delta_field.shape[1]             # <<<<<<<<<<<<<<
18396  *         cnp.npy_intp i, j
18397  *         double delta, delta_2, nrm2, energy, den
18398  */
18399   __pyx_v_nc = (__pyx_v_delta_field.shape[1]);
18400 
18401   /* "dipy/align/sumsqdiff.pyx":800
18402  *         double delta, delta_2, nrm2, energy, den
18403  *
18404  *     if out is None:             # <<<<<<<<<<<<<<
18405  *         out = np.zeros((nr, nc, 2), dtype=np.asarray(delta_field).dtype)
18406  *
18407  */
18408   __pyx_t_1 = ((((PyObject *) __pyx_v_out.memview) == Py_None) != 0);
18409   if (__pyx_t_1) {
18410 
18411     /* "dipy/align/sumsqdiff.pyx":801
18412  *
18413  *     if out is None:
18414  *         out = np.zeros((nr, nc, 2), dtype=np.asarray(delta_field).dtype)             # <<<<<<<<<<<<<<
18415  *
18416  *     with nogil:
18417  */
18418     __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 801, __pyx_L1_error)
18419     __Pyx_GOTREF(__pyx_t_2);
18420     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 801, __pyx_L1_error)
18421     __Pyx_GOTREF(__pyx_t_3);
18422     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
18423     __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 801, __pyx_L1_error)
18424     __Pyx_GOTREF(__pyx_t_2);
18425     __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 801, __pyx_L1_error)
18426     __Pyx_GOTREF(__pyx_t_4);
18427     __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 801, __pyx_L1_error)
18428     __Pyx_GOTREF(__pyx_t_5);
18429     __Pyx_GIVEREF(__pyx_t_2);
18430     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
18431     __Pyx_GIVEREF(__pyx_t_4);
18432     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
18433     __Pyx_INCREF(__pyx_int_2);
18434     __Pyx_GIVEREF(__pyx_int_2);
18435     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_int_2);
18436     __pyx_t_2 = 0;
18437     __pyx_t_4 = 0;
18438     __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 801, __pyx_L1_error)
18439     __Pyx_GOTREF(__pyx_t_4);
18440     __Pyx_GIVEREF(__pyx_t_5);
18441     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
18442     __pyx_t_5 = 0;
18443     __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 801, __pyx_L1_error)
18444     __Pyx_GOTREF(__pyx_t_5);
18445     __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 801, __pyx_L1_error)
18446     __Pyx_GOTREF(__pyx_t_6);
18447     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_asarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 801, __pyx_L1_error)
18448     __Pyx_GOTREF(__pyx_t_7);
18449     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18450     __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 801, __pyx_L1_error)
18451     __Pyx_GOTREF(__pyx_t_6);
18452     __pyx_t_8 = NULL;
18453     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
18454       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
18455       if (likely(__pyx_t_8)) {
18456         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
18457         __Pyx_INCREF(__pyx_t_8);
18458         __Pyx_INCREF(function);
18459         __Pyx_DECREF_SET(__pyx_t_7, function);
18460       }
18461     }
18462     __pyx_t_2 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
18463     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
18464     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18465     if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 801, __pyx_L1_error)
18466     __Pyx_GOTREF(__pyx_t_2);
18467     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
18468     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 801, __pyx_L1_error)
18469     __Pyx_GOTREF(__pyx_t_7);
18470     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
18471     if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 801, __pyx_L1_error)
18472     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
18473     __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 801, __pyx_L1_error)
18474     __Pyx_GOTREF(__pyx_t_7);
18475     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
18476     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
18477     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
18478     __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 801, __pyx_L1_error)
18479     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
18480     __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
18481     __pyx_v_out = __pyx_t_9;
18482     __pyx_t_9.memview = NULL;
18483     __pyx_t_9.data = NULL;
18484 
18485     /* "dipy/align/sumsqdiff.pyx":800
18486  *         double delta, delta_2, nrm2, energy, den
18487  *
18488  *     if out is None:             # <<<<<<<<<<<<<<
18489  *         out = np.zeros((nr, nc, 2), dtype=np.asarray(delta_field).dtype)
18490  *
18491  */
18492   }
18493 
18494   /* "dipy/align/sumsqdiff.pyx":803
18495  *         out = np.zeros((nr, nc, 2), dtype=np.asarray(delta_field).dtype)
18496  *
18497  *     with nogil:             # <<<<<<<<<<<<<<
18498  *
18499  *         energy = 0
18500  */
18501   {
18502       #ifdef WITH_THREAD
18503       PyThreadState *_save;
18504       Py_UNBLOCK_THREADS
18505       __Pyx_FastGIL_Remember();
18506       #endif
18507       /*try:*/ {
18508 
18509         /* "dipy/align/sumsqdiff.pyx":805
18510  *     with nogil:
18511  *
18512  *         energy = 0             # <<<<<<<<<<<<<<
18513  *         for i in range(nr):
18514  *             for j in range(nc):
18515  */
18516         __pyx_v_energy = 0.0;
18517 
18518         /* "dipy/align/sumsqdiff.pyx":806
18519  *
18520  *         energy = 0
18521  *         for i in range(nr):             # <<<<<<<<<<<<<<
18522  *             for j in range(nc):
18523  *                 delta = delta_field[i,j]
18524  */
18525         __pyx_t_10 = __pyx_v_nr;
18526         __pyx_t_11 = __pyx_t_10;
18527         for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
18528           __pyx_v_i = __pyx_t_12;
18529 
18530           /* "dipy/align/sumsqdiff.pyx":807
18531  *         energy = 0
18532  *         for i in range(nr):
18533  *             for j in range(nc):             # <<<<<<<<<<<<<<
18534  *                 delta = delta_field[i,j]
18535  *                 delta_2 = delta**2
18536  */
18537           __pyx_t_13 = __pyx_v_nc;
18538           __pyx_t_14 = __pyx_t_13;
18539           for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
18540             __pyx_v_j = __pyx_t_15;
18541 
18542             /* "dipy/align/sumsqdiff.pyx":808
18543  *         for i in range(nr):
18544  *             for j in range(nc):
18545  *                 delta = delta_field[i,j]             # <<<<<<<<<<<<<<
18546  *                 delta_2 = delta**2
18547  *                 energy += delta_2
18548  */
18549             __pyx_t_16 = __pyx_v_i;
18550             __pyx_t_17 = __pyx_v_j;
18551             __pyx_v_delta = (*((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_16 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_17 * __pyx_v_delta_field.strides[1]) )));
18552 
18553             /* "dipy/align/sumsqdiff.pyx":809
18554  *             for j in range(nc):
18555  *                 delta = delta_field[i,j]
18556  *                 delta_2 = delta**2             # <<<<<<<<<<<<<<
18557  *                 energy += delta_2
18558  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2
18559  */
18560             __pyx_v_delta_2 = pow(__pyx_v_delta, 2.0);
18561 
18562             /* "dipy/align/sumsqdiff.pyx":810
18563  *                 delta = delta_field[i,j]
18564  *                 delta_2 = delta**2
18565  *                 energy += delta_2             # <<<<<<<<<<<<<<
18566  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2
18567  *                 den = delta_2/sigma_sq_x + nrm2
18568  */
18569             __pyx_v_energy = (__pyx_v_energy + __pyx_v_delta_2);
18570 
18571             /* "dipy/align/sumsqdiff.pyx":811
18572  *                 delta_2 = delta**2
18573  *                 energy += delta_2
18574  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2             # <<<<<<<<<<<<<<
18575  *                 den = delta_2/sigma_sq_x + nrm2
18576  *                 if den <1e-9:
18577  */
18578             __pyx_t_17 = __pyx_v_i;
18579             __pyx_t_16 = __pyx_v_j;
18580             __pyx_t_18 = 0;
18581             __pyx_t_19 = __pyx_v_i;
18582             __pyx_t_20 = __pyx_v_j;
18583             __pyx_t_21 = 1;
18584             __pyx_v_nrm2 = (pow((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_17 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_16 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_18 * __pyx_v_gradient_moving.strides[2]) ))), 2.0) + pow((*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_19 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_20 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_21 * __pyx_v_gradient_moving.strides[2]) ))), 2.0));
18585 
18586             /* "dipy/align/sumsqdiff.pyx":812
18587  *                 energy += delta_2
18588  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2
18589  *                 den = delta_2/sigma_sq_x + nrm2             # <<<<<<<<<<<<<<
18590  *                 if den <1e-9:
18591  *                     out[i, j, 0] = 0
18592  */
18593             __pyx_v_den = ((__pyx_v_delta_2 / __pyx_v_sigma_sq_x) + __pyx_v_nrm2);
18594 
18595             /* "dipy/align/sumsqdiff.pyx":813
18596  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2
18597  *                 den = delta_2/sigma_sq_x + nrm2
18598  *                 if den <1e-9:             # <<<<<<<<<<<<<<
18599  *                     out[i, j, 0] = 0
18600  *                     out[i, j, 1] = 0
18601  */
18602             __pyx_t_1 = ((__pyx_v_den < 1e-9) != 0);
18603             if (__pyx_t_1) {
18604 
18605               /* "dipy/align/sumsqdiff.pyx":814
18606  *                 den = delta_2/sigma_sq_x + nrm2
18607  *                 if den <1e-9:
18608  *                     out[i, j, 0] = 0             # <<<<<<<<<<<<<<
18609  *                     out[i, j, 1] = 0
18610  *                 else:
18611  */
18612               __pyx_t_21 = __pyx_v_i;
18613               __pyx_t_20 = __pyx_v_j;
18614               __pyx_t_19 = 0;
18615               *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_21 * __pyx_v_out.strides[0]) ) + __pyx_t_20 * __pyx_v_out.strides[1]) ) + __pyx_t_19 * __pyx_v_out.strides[2]) )) = 0.0;
18616 
18617               /* "dipy/align/sumsqdiff.pyx":815
18618  *                 if den <1e-9:
18619  *                     out[i, j, 0] = 0
18620  *                     out[i, j, 1] = 0             # <<<<<<<<<<<<<<
18621  *                 else:
18622  *                     out[i, j, 0] = delta * gradient_moving[i, j, 0] / den
18623  */
18624               __pyx_t_19 = __pyx_v_i;
18625               __pyx_t_20 = __pyx_v_j;
18626               __pyx_t_21 = 1;
18627               *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_19 * __pyx_v_out.strides[0]) ) + __pyx_t_20 * __pyx_v_out.strides[1]) ) + __pyx_t_21 * __pyx_v_out.strides[2]) )) = 0.0;
18628 
18629               /* "dipy/align/sumsqdiff.pyx":813
18630  *                 nrm2 = gradient_moving[i, j, 0]**2 + gradient_moving[i, j, 1]**2
18631  *                 den = delta_2/sigma_sq_x + nrm2
18632  *                 if den <1e-9:             # <<<<<<<<<<<<<<
18633  *                     out[i, j, 0] = 0
18634  *                     out[i, j, 1] = 0
18635  */
18636               goto __pyx_L11;
18637             }
18638 
18639             /* "dipy/align/sumsqdiff.pyx":817
18640  *                     out[i, j, 1] = 0
18641  *                 else:
18642  *                     out[i, j, 0] = delta * gradient_moving[i, j, 0] / den             # <<<<<<<<<<<<<<
18643  *                     out[i, j, 1] = delta * gradient_moving[i, j, 1] / den
18644  *
18645  */
18646             /*else*/ {
18647               __pyx_t_21 = __pyx_v_i;
18648               __pyx_t_20 = __pyx_v_j;
18649               __pyx_t_19 = 0;
18650               __pyx_t_18 = __pyx_v_i;
18651               __pyx_t_16 = __pyx_v_j;
18652               __pyx_t_17 = 0;
18653               *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_18 * __pyx_v_out.strides[0]) ) + __pyx_t_16 * __pyx_v_out.strides[1]) ) + __pyx_t_17 * __pyx_v_out.strides[2]) )) = ((__pyx_v_delta * (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_21 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_20 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_19 * __pyx_v_gradient_moving.strides[2]) )))) / __pyx_v_den);
18654 
18655               /* "dipy/align/sumsqdiff.pyx":818
18656  *                 else:
18657  *                     out[i, j, 0] = delta * gradient_moving[i, j, 0] / den
18658  *                     out[i, j, 1] = delta * gradient_moving[i, j, 1] / den             # <<<<<<<<<<<<<<
18659  *
18660  *     return np.asarray(out), energy
18661  */
18662               __pyx_t_19 = __pyx_v_i;
18663               __pyx_t_20 = __pyx_v_j;
18664               __pyx_t_21 = 1;
18665               __pyx_t_17 = __pyx_v_i;
18666               __pyx_t_16 = __pyx_v_j;
18667               __pyx_t_18 = 1;
18668               *((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_17 * __pyx_v_out.strides[0]) ) + __pyx_t_16 * __pyx_v_out.strides[1]) ) + __pyx_t_18 * __pyx_v_out.strides[2]) )) = ((__pyx_v_delta * (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_19 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_20 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_21 * __pyx_v_gradient_moving.strides[2]) )))) / __pyx_v_den);
18669             }
18670             __pyx_L11:;
18671           }
18672         }
18673       }
18674 
18675       /* "dipy/align/sumsqdiff.pyx":803
18676  *         out = np.zeros((nr, nc, 2), dtype=np.asarray(delta_field).dtype)
18677  *
18678  *     with nogil:             # <<<<<<<<<<<<<<
18679  *
18680  *         energy = 0
18681  */
18682       /*finally:*/ {
18683         /*normal exit:*/{
18684           #ifdef WITH_THREAD
18685           __Pyx_FastGIL_Forget();
18686           Py_BLOCK_THREADS
18687           #endif
18688           goto __pyx_L6;
18689         }
18690         __pyx_L6:;
18691       }
18692   }
18693 
18694   /* "dipy/align/sumsqdiff.pyx":820
18695  *                     out[i, j, 1] = delta * gradient_moving[i, j, 1] / den
18696  *
18697  *     return np.asarray(out), energy             # <<<<<<<<<<<<<<
18698  *
18699  *
18700  */
18701   __Pyx_XDECREF(__pyx_r);
18702   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 820, __pyx_L1_error)
18703   __Pyx_GOTREF(__pyx_t_5);
18704   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 820, __pyx_L1_error)
18705   __Pyx_GOTREF(__pyx_t_4);
18706   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
18707   __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_out, 3, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 820, __pyx_L1_error)
18708   __Pyx_GOTREF(__pyx_t_5);
18709   __pyx_t_3 = NULL;
18710   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
18711     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
18712     if (likely(__pyx_t_3)) {
18713       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
18714       __Pyx_INCREF(__pyx_t_3);
18715       __Pyx_INCREF(function);
18716       __Pyx_DECREF_SET(__pyx_t_4, function);
18717     }
18718   }
18719   __pyx_t_7 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
18720   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
18721   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
18722   if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 820, __pyx_L1_error)
18723   __Pyx_GOTREF(__pyx_t_7);
18724   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
18725   __pyx_t_4 = PyFloat_FromDouble(__pyx_v_energy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 820, __pyx_L1_error)
18726   __Pyx_GOTREF(__pyx_t_4);
18727   __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 820, __pyx_L1_error)
18728   __Pyx_GOTREF(__pyx_t_5);
18729   __Pyx_GIVEREF(__pyx_t_7);
18730   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7);
18731   __Pyx_GIVEREF(__pyx_t_4);
18732   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
18733   __pyx_t_7 = 0;
18734   __pyx_t_4 = 0;
18735   __pyx_r = __pyx_t_5;
18736   __pyx_t_5 = 0;
18737   goto __pyx_L0;
18738 
18739   /* "dipy/align/sumsqdiff.pyx":752
18740  * @cython.wraparound(False)
18741  * @cython.cdivision(True)
18742  * def compute_ssd_demons_step_2d(floating[:,:] delta_field,             # <<<<<<<<<<<<<<
18743  *                                floating[:,:,:] gradient_moving,
18744  *                                double sigma_sq_x,
18745  */
18746 
18747   /* function exit code */
18748   __pyx_L1_error:;
18749   __Pyx_XDECREF(__pyx_t_2);
18750   __Pyx_XDECREF(__pyx_t_3);
18751   __Pyx_XDECREF(__pyx_t_4);
18752   __Pyx_XDECREF(__pyx_t_5);
18753   __Pyx_XDECREF(__pyx_t_6);
18754   __Pyx_XDECREF(__pyx_t_7);
18755   __Pyx_XDECREF(__pyx_t_8);
18756   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
18757   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_ssd_demons_step_2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
18758   __pyx_r = NULL;
18759   __pyx_L0:;
18760   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
18761   __PYX_XDEC_MEMVIEW(&__pyx_v_gradient_moving, 1);
18762   __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
18763   __Pyx_XGIVEREF(__pyx_r);
18764   __Pyx_RefNannyFinishContext();
18765   return __pyx_r;
18766 }
18767 
18768 /* "dipy/align/sumsqdiff.pyx":826
18769  * @cython.wraparound(False)
18770  * @cython.cdivision(True)
18771  * def compute_ssd_demons_step_3d(floating[:,:,:] delta_field,             # <<<<<<<<<<<<<<
18772  *                                floating[:,:,:,:] gradient_moving,
18773  *                                double sigma_sq_x,
18774  */
18775 
18776 /* Python wrapper */
18777 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_19compute_ssd_demons_step_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
18778 static char __pyx_doc_4dipy_5align_9sumsqdiff_18compute_ssd_demons_step_3d[] = "Demons step for 3D SSD-driven registration\n\n    Computes the demons step for SSD-driven registration\n    ( eq. 4 in [Bruhn05] )\n\n    Parameters\n    ----------\n    delta_field : array, shape (S, R, C)\n        the difference between the static and moving image (the 'derivative\n        w.r.t. time' in the optical flow model)\n    gradient_field : array, shape (S, R, C, 2)\n        the gradient of the moving image\n    sigma_sq_x : float\n        parameter controlling the amount of regularization. It corresponds to\n        $\\sigma_x^2$ in algorithm 1 of Vercauteren et al.[Vercauteren09]\n    out : array, shape (S, R, C, 2)\n        if None, a new array will be created to store the demons step. Otherwise\n        the provided array will be used.\n\n    Returns\n    -------\n    demons_step : array, shape (S, R, C, 3)\n        the demons step to be applied for updating the current displacement\n        field\n    energy : float\n        the current ssd energy (before applying the returned demons_step)\n\n    References\n    ----------\n    [Bruhn05] Andres Bruhn and Joachim Weickert, \"Towards ultimate motion\n              estimation: combining highest accuracy with real-time\n              performance\", 10th IEEE International Conference on Computer\n              Vision, 2005. ICCV 2005.\n    [Vercauteren09] Vercauteren, T., Pennec, X., Perchant, A., & Ayache, N.\n                    (2009). Diffeomorphic demons: efficient non-parametric\n                    image registration. NeuroImage, 45(1 Suppl), S61-72.\n                    doi:10.1016/j.neuroimage.2008.10.040\n    ";
18779 static PyMethodDef __pyx_mdef_4dipy_5align_9sumsqdiff_19compute_ssd_demons_step_3d = {"compute_ssd_demons_step_3d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4dipy_5align_9sumsqdiff_19compute_ssd_demons_step_3d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_18compute_ssd_demons_step_3d};
__pyx_pw_4dipy_5align_9sumsqdiff_19compute_ssd_demons_step_3d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)18780 static PyObject *__pyx_pw_4dipy_5align_9sumsqdiff_19compute_ssd_demons_step_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
18781   PyObject *__pyx_v_signatures = 0;
18782   PyObject *__pyx_v_args = 0;
18783   PyObject *__pyx_v_kwargs = 0;
18784   CYTHON_UNUSED PyObject *__pyx_v_defaults = 0;
18785   int __pyx_lineno = 0;
18786   const char *__pyx_filename = NULL;
18787   int __pyx_clineno = 0;
18788   PyObject *__pyx_r = 0;
18789   __Pyx_RefNannyDeclarations
18790   __Pyx_RefNannySetupContext("__pyx_fused_cpdef (wrapper)", 0);
18791   {
18792     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signatures,&__pyx_n_s_args,&__pyx_n_s_kwargs,&__pyx_n_s_defaults,0};
18793     PyObject* values[4] = {0,0,0,0};
18794     if (unlikely(__pyx_kwds)) {
18795       Py_ssize_t kw_args;
18796       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
18797       switch (pos_args) {
18798         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
18799         CYTHON_FALLTHROUGH;
18800         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
18801         CYTHON_FALLTHROUGH;
18802         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
18803         CYTHON_FALLTHROUGH;
18804         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
18805         CYTHON_FALLTHROUGH;
18806         case  0: break;
18807         default: goto __pyx_L5_argtuple_error;
18808       }
18809       kw_args = PyDict_Size(__pyx_kwds);
18810       switch (pos_args) {
18811         case  0:
18812         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_signatures)) != 0)) kw_args--;
18813         else goto __pyx_L5_argtuple_error;
18814         CYTHON_FALLTHROUGH;
18815         case  1:
18816         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_args)) != 0)) kw_args--;
18817         else {
18818           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 1); __PYX_ERR(0, 826, __pyx_L3_error)
18819         }
18820         CYTHON_FALLTHROUGH;
18821         case  2:
18822         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kwargs)) != 0)) kw_args--;
18823         else {
18824           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 2); __PYX_ERR(0, 826, __pyx_L3_error)
18825         }
18826         CYTHON_FALLTHROUGH;
18827         case  3:
18828         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_defaults)) != 0)) kw_args--;
18829         else {
18830           __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, 3); __PYX_ERR(0, 826, __pyx_L3_error)
18831         }
18832       }
18833       if (unlikely(kw_args > 0)) {
18834         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_fused_cpdef") < 0)) __PYX_ERR(0, 826, __pyx_L3_error)
18835       }
18836     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
18837       goto __pyx_L5_argtuple_error;
18838     } else {
18839       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
18840       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
18841       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
18842       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
18843     }
18844     __pyx_v_signatures = values[0];
18845     __pyx_v_args = values[1];
18846     __pyx_v_kwargs = values[2];
18847     __pyx_v_defaults = values[3];
18848   }
18849   goto __pyx_L4_argument_unpacking_done;
18850   __pyx_L5_argtuple_error:;
18851   __Pyx_RaiseArgtupleInvalid("__pyx_fused_cpdef", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 826, __pyx_L3_error)
18852   __pyx_L3_error:;
18853   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
18854   __Pyx_RefNannyFinishContext();
18855   return NULL;
18856   __pyx_L4_argument_unpacking_done:;
18857   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_18compute_ssd_demons_step_3d(__pyx_self, __pyx_v_signatures, __pyx_v_args, __pyx_v_kwargs, __pyx_v_defaults);
18858 
18859   /* function exit code */
18860   __Pyx_RefNannyFinishContext();
18861   return __pyx_r;
18862 }
18863 
__pyx_pf_4dipy_5align_9sumsqdiff_18compute_ssd_demons_step_3d(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_signatures,PyObject * __pyx_v_args,PyObject * __pyx_v_kwargs,CYTHON_UNUSED PyObject * __pyx_v_defaults)18864 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_18compute_ssd_demons_step_3d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_signatures, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs, CYTHON_UNUSED PyObject *__pyx_v_defaults) {
18865   PyObject *__pyx_v_dest_sig = NULL;
18866   Py_ssize_t __pyx_v_i;
18867   PyTypeObject *__pyx_v_ndarray = 0;
18868   __Pyx_memviewslice __pyx_v_memslice;
18869   Py_ssize_t __pyx_v_itemsize;
18870   CYTHON_UNUSED int __pyx_v_dtype_signed;
18871   char __pyx_v_kind;
18872   PyObject *__pyx_v_arg = NULL;
18873   PyObject *__pyx_v_dtype = NULL;
18874   PyObject *__pyx_v_arg_base = NULL;
18875   PyObject *__pyx_v_candidates = NULL;
18876   PyObject *__pyx_v_sig = NULL;
18877   int __pyx_v_match_found;
18878   PyObject *__pyx_v_src_sig = NULL;
18879   PyObject *__pyx_v_dst_type = NULL;
18880   PyObject *__pyx_r = NULL;
18881   __Pyx_RefNannyDeclarations
18882   PyObject *__pyx_t_1 = NULL;
18883   int __pyx_t_2;
18884   int __pyx_t_3;
18885   int __pyx_t_4;
18886   Py_ssize_t __pyx_t_5;
18887   PyObject *__pyx_t_6 = NULL;
18888   long __pyx_t_7;
18889   __Pyx_memviewslice __pyx_t_8;
18890   Py_ssize_t __pyx_t_9;
18891   int __pyx_t_10;
18892   int __pyx_t_11;
18893   PyObject *__pyx_t_12 = NULL;
18894   PyObject *__pyx_t_13 = NULL;
18895   PyObject *__pyx_t_14 = NULL;
18896   Py_ssize_t __pyx_t_15;
18897   Py_ssize_t __pyx_t_16;
18898   Py_ssize_t __pyx_t_17;
18899   int __pyx_t_18;
18900   int __pyx_lineno = 0;
18901   const char *__pyx_filename = NULL;
18902   int __pyx_clineno = 0;
18903   __Pyx_RefNannySetupContext("compute_ssd_demons_step_3d", 0);
18904   __Pyx_INCREF(__pyx_v_kwargs);
18905   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
18906   __Pyx_GOTREF(__pyx_t_1);
18907   __Pyx_INCREF(Py_None);
18908   __Pyx_GIVEREF(Py_None);
18909   PyList_SET_ITEM(__pyx_t_1, 0, Py_None);
18910   __pyx_v_dest_sig = ((PyObject*)__pyx_t_1);
18911   __pyx_t_1 = 0;
18912   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
18913   __pyx_t_4 = (__pyx_t_3 != 0);
18914   if (__pyx_t_4) {
18915   } else {
18916     __pyx_t_2 = __pyx_t_4;
18917     goto __pyx_L4_bool_binop_done;
18918   }
18919   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_kwargs); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 826, __pyx_L1_error)
18920   __pyx_t_3 = ((!__pyx_t_4) != 0);
18921   __pyx_t_2 = __pyx_t_3;
18922   __pyx_L4_bool_binop_done:;
18923   if (__pyx_t_2) {
18924     __Pyx_INCREF(Py_None);
18925     __Pyx_DECREF_SET(__pyx_v_kwargs, Py_None);
18926   }
18927   __pyx_t_1 = ((PyObject *)__Pyx_ImportNumPyArrayTypeIfAvailable()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
18928   __Pyx_GOTREF(__pyx_t_1);
18929   __pyx_v_ndarray = ((PyTypeObject*)__pyx_t_1);
18930   __pyx_t_1 = 0;
18931   __pyx_v_itemsize = -1L;
18932   if (unlikely(__pyx_v_args == Py_None)) {
18933     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
18934     __PYX_ERR(0, 826, __pyx_L1_error)
18935   }
18936   __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 826, __pyx_L1_error)
18937   __pyx_t_2 = ((0 < __pyx_t_5) != 0);
18938   if (__pyx_t_2) {
18939     if (unlikely(__pyx_v_args == Py_None)) {
18940       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
18941       __PYX_ERR(0, 826, __pyx_L1_error)
18942     }
18943     __pyx_t_1 = PyTuple_GET_ITEM(((PyObject*)__pyx_v_args), 0);
18944     __Pyx_INCREF(__pyx_t_1);
18945     __pyx_v_arg = __pyx_t_1;
18946     __pyx_t_1 = 0;
18947     goto __pyx_L6;
18948   }
18949   __pyx_t_3 = (__pyx_v_kwargs != Py_None);
18950   __pyx_t_4 = (__pyx_t_3 != 0);
18951   if (__pyx_t_4) {
18952   } else {
18953     __pyx_t_2 = __pyx_t_4;
18954     goto __pyx_L7_bool_binop_done;
18955   }
18956   if (unlikely(__pyx_v_kwargs == Py_None)) {
18957     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
18958     __PYX_ERR(0, 826, __pyx_L1_error)
18959   }
18960   __pyx_t_4 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_delta_field, ((PyObject*)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 826, __pyx_L1_error)
18961   __pyx_t_3 = (__pyx_t_4 != 0);
18962   __pyx_t_2 = __pyx_t_3;
18963   __pyx_L7_bool_binop_done:;
18964   if (__pyx_t_2) {
18965     if (unlikely(__pyx_v_kwargs == Py_None)) {
18966       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
18967       __PYX_ERR(0, 826, __pyx_L1_error)
18968     }
18969     __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_kwargs), __pyx_n_s_delta_field); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
18970     __Pyx_GOTREF(__pyx_t_1);
18971     __pyx_v_arg = __pyx_t_1;
18972     __pyx_t_1 = 0;
18973     goto __pyx_L6;
18974   }
18975   /*else*/ {
18976     if (unlikely(__pyx_v_args == Py_None)) {
18977       PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
18978       __PYX_ERR(0, 826, __pyx_L1_error)
18979     }
18980     __pyx_t_5 = PyTuple_GET_SIZE(((PyObject*)__pyx_v_args)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 826, __pyx_L1_error)
18981     __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
18982     __Pyx_GOTREF(__pyx_t_1);
18983     __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
18984     __Pyx_GOTREF(__pyx_t_6);
18985     __Pyx_INCREF(__pyx_int_4);
18986     __Pyx_GIVEREF(__pyx_int_4);
18987     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_4);
18988     __Pyx_INCREF(__pyx_n_s_s);
18989     __Pyx_GIVEREF(__pyx_n_s_s);
18990     PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_s);
18991     __Pyx_GIVEREF(__pyx_t_1);
18992     PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1);
18993     __pyx_t_1 = 0;
18994     __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
18995     __Pyx_GOTREF(__pyx_t_1);
18996     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18997     __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
18998     __Pyx_GOTREF(__pyx_t_6);
18999     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19000     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
19001     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19002     __PYX_ERR(0, 826, __pyx_L1_error)
19003   }
19004   __pyx_L6:;
19005   while (1) {
19006     __pyx_t_2 = (__pyx_v_ndarray != ((PyTypeObject*)Py_None));
19007     __pyx_t_3 = (__pyx_t_2 != 0);
19008     if (__pyx_t_3) {
19009       __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg, __pyx_v_ndarray);
19010       __pyx_t_2 = (__pyx_t_3 != 0);
19011       if (__pyx_t_2) {
19012         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
19013         __Pyx_GOTREF(__pyx_t_6);
19014         __pyx_v_dtype = __pyx_t_6;
19015         __pyx_t_6 = 0;
19016         goto __pyx_L12;
19017       }
19018       __pyx_t_2 = __pyx_memoryview_check(__pyx_v_arg);
19019       __pyx_t_3 = (__pyx_t_2 != 0);
19020       if (__pyx_t_3) {
19021         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_base); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
19022         __Pyx_GOTREF(__pyx_t_6);
19023         __pyx_v_arg_base = __pyx_t_6;
19024         __pyx_t_6 = 0;
19025         __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_arg_base, __pyx_v_ndarray);
19026         __pyx_t_2 = (__pyx_t_3 != 0);
19027         if (__pyx_t_2) {
19028           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg_base, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
19029           __Pyx_GOTREF(__pyx_t_6);
19030           __pyx_v_dtype = __pyx_t_6;
19031           __pyx_t_6 = 0;
19032           goto __pyx_L13;
19033         }
19034         /*else*/ {
19035           __Pyx_INCREF(Py_None);
19036           __pyx_v_dtype = Py_None;
19037         }
19038         __pyx_L13:;
19039         goto __pyx_L12;
19040       }
19041       /*else*/ {
19042         __Pyx_INCREF(Py_None);
19043         __pyx_v_dtype = Py_None;
19044       }
19045       __pyx_L12:;
19046       __pyx_v_itemsize = -1L;
19047       __pyx_t_2 = (__pyx_v_dtype != Py_None);
19048       __pyx_t_3 = (__pyx_t_2 != 0);
19049       if (__pyx_t_3) {
19050         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_itemsize); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
19051         __Pyx_GOTREF(__pyx_t_6);
19052         __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 826, __pyx_L1_error)
19053         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19054         __pyx_v_itemsize = __pyx_t_5;
19055         __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_dtype, __pyx_n_s_kind); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
19056         __Pyx_GOTREF(__pyx_t_6);
19057         __pyx_t_7 = __Pyx_PyObject_Ord(__pyx_t_6); if (unlikely(__pyx_t_7 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 826, __pyx_L1_error)
19058         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19059         __pyx_v_kind = __pyx_t_7;
19060         __pyx_v_dtype_signed = (__pyx_v_kind == 'i');
19061         switch (__pyx_v_kind) {
19062           case 'i':
19063           case 'u':
19064           break;
19065           case 'f':
19066           __pyx_t_2 = (((sizeof(float)) == __pyx_v_itemsize) != 0);
19067           if (__pyx_t_2) {
19068           } else {
19069             __pyx_t_3 = __pyx_t_2;
19070             goto __pyx_L16_bool_binop_done;
19071           }
19072           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
19073           __Pyx_GOTREF(__pyx_t_6);
19074           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 826, __pyx_L1_error)
19075           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19076           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0);
19077           __pyx_t_3 = __pyx_t_2;
19078           __pyx_L16_bool_binop_done:;
19079           if (__pyx_t_3) {
19080             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 826, __pyx_L1_error)
19081             goto __pyx_L10_break;
19082           }
19083           __pyx_t_2 = (((sizeof(double)) == __pyx_v_itemsize) != 0);
19084           if (__pyx_t_2) {
19085           } else {
19086             __pyx_t_3 = __pyx_t_2;
19087             goto __pyx_L19_bool_binop_done;
19088           }
19089           __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_arg, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
19090           __Pyx_GOTREF(__pyx_t_6);
19091           __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 826, __pyx_L1_error)
19092           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19093           __pyx_t_2 = ((((Py_ssize_t)__pyx_t_5) == 3) != 0);
19094           __pyx_t_3 = __pyx_t_2;
19095           __pyx_L19_bool_binop_done:;
19096           if (__pyx_t_3) {
19097             if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 826, __pyx_L1_error)
19098             goto __pyx_L10_break;
19099           }
19100           break;
19101           case 'c':
19102           break;
19103           case 'O':
19104           break;
19105           default: break;
19106         }
19107       }
19108     }
19109     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
19110     if (!__pyx_t_2) {
19111     } else {
19112       __pyx_t_3 = __pyx_t_2;
19113       goto __pyx_L22_bool_binop_done;
19114     }
19115     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(float))) != 0);
19116     __pyx_t_3 = __pyx_t_2;
19117     __pyx_L22_bool_binop_done:;
19118     if (__pyx_t_3) {
19119       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(__pyx_v_arg, 0);
19120       __pyx_v_memslice = __pyx_t_8;
19121       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
19122       if (__pyx_t_3) {
19123         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
19124         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_float, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 826, __pyx_L1_error)
19125         goto __pyx_L10_break;
19126       }
19127       /*else*/ {
19128         PyErr_Clear();
19129       }
19130     }
19131     __pyx_t_2 = ((__pyx_v_itemsize == -1L) != 0);
19132     if (!__pyx_t_2) {
19133     } else {
19134       __pyx_t_3 = __pyx_t_2;
19135       goto __pyx_L26_bool_binop_done;
19136     }
19137     __pyx_t_2 = ((__pyx_v_itemsize == (sizeof(double))) != 0);
19138     __pyx_t_3 = __pyx_t_2;
19139     __pyx_L26_bool_binop_done:;
19140     if (__pyx_t_3) {
19141       __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(__pyx_v_arg, 0);
19142       __pyx_v_memslice = __pyx_t_8;
19143       __pyx_t_3 = (__pyx_v_memslice.memview != 0);
19144       if (__pyx_t_3) {
19145         __PYX_XDEC_MEMVIEW((&__pyx_v_memslice), 1);
19146         if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, __pyx_n_s_double, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 826, __pyx_L1_error)
19147         goto __pyx_L10_break;
19148       }
19149       /*else*/ {
19150         PyErr_Clear();
19151       }
19152     }
19153     if (unlikely(__Pyx_SetItemInt(__pyx_v_dest_sig, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 826, __pyx_L1_error)
19154     goto __pyx_L10_break;
19155   }
19156   __pyx_L10_break:;
19157   __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
19158   __Pyx_GOTREF(__pyx_t_6);
19159   __pyx_v_candidates = ((PyObject*)__pyx_t_6);
19160   __pyx_t_6 = 0;
19161   __pyx_t_5 = 0;
19162   if (unlikely(__pyx_v_signatures == Py_None)) {
19163     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
19164     __PYX_ERR(0, 826, __pyx_L1_error)
19165   }
19166   __pyx_t_1 = __Pyx_dict_iterator(((PyObject*)__pyx_v_signatures), 1, ((PyObject *)NULL), (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
19167   __Pyx_GOTREF(__pyx_t_1);
19168   __Pyx_XDECREF(__pyx_t_6);
19169   __pyx_t_6 = __pyx_t_1;
19170   __pyx_t_1 = 0;
19171   while (1) {
19172     __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_9, &__pyx_t_5, &__pyx_t_1, NULL, NULL, __pyx_t_10);
19173     if (unlikely(__pyx_t_11 == 0)) break;
19174     if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 826, __pyx_L1_error)
19175     __Pyx_GOTREF(__pyx_t_1);
19176     __Pyx_XDECREF_SET(__pyx_v_sig, __pyx_t_1);
19177     __pyx_t_1 = 0;
19178     __pyx_v_match_found = 0;
19179     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_sig, __pyx_n_s_strip); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 826, __pyx_L1_error)
19180     __Pyx_GOTREF(__pyx_t_13);
19181     __pyx_t_14 = NULL;
19182     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
19183       __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
19184       if (likely(__pyx_t_14)) {
19185         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
19186         __Pyx_INCREF(__pyx_t_14);
19187         __Pyx_INCREF(function);
19188         __Pyx_DECREF_SET(__pyx_t_13, function);
19189       }
19190     }
19191     __pyx_t_12 = (__pyx_t_14) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_14, __pyx_kp_s__3) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__3);
19192     __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
19193     if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 826, __pyx_L1_error)
19194     __Pyx_GOTREF(__pyx_t_12);
19195     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
19196     __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_split); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 826, __pyx_L1_error)
19197     __Pyx_GOTREF(__pyx_t_13);
19198     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
19199     __pyx_t_12 = NULL;
19200     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) {
19201       __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
19202       if (likely(__pyx_t_12)) {
19203         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
19204         __Pyx_INCREF(__pyx_t_12);
19205         __Pyx_INCREF(function);
19206         __Pyx_DECREF_SET(__pyx_t_13, function);
19207       }
19208     }
19209     __pyx_t_1 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_kp_s__4) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_kp_s__4);
19210     __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
19211     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
19212     __Pyx_GOTREF(__pyx_t_1);
19213     __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
19214     __Pyx_XDECREF_SET(__pyx_v_src_sig, __pyx_t_1);
19215     __pyx_t_1 = 0;
19216     __pyx_t_15 = PyList_GET_SIZE(__pyx_v_dest_sig); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 826, __pyx_L1_error)
19217     __pyx_t_16 = __pyx_t_15;
19218     for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
19219       __pyx_v_i = __pyx_t_17;
19220       __pyx_t_1 = PyList_GET_ITEM(__pyx_v_dest_sig, __pyx_v_i);
19221       __Pyx_INCREF(__pyx_t_1);
19222       __Pyx_XDECREF_SET(__pyx_v_dst_type, __pyx_t_1);
19223       __pyx_t_1 = 0;
19224       __pyx_t_3 = (__pyx_v_dst_type != Py_None);
19225       __pyx_t_2 = (__pyx_t_3 != 0);
19226       if (__pyx_t_2) {
19227         __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_sig, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
19228         __Pyx_GOTREF(__pyx_t_1);
19229         __pyx_t_13 = PyObject_RichCompare(__pyx_t_1, __pyx_v_dst_type, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 826, __pyx_L1_error)
19230         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19231         __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 826, __pyx_L1_error)
19232         __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
19233         if (__pyx_t_2) {
19234           __pyx_v_match_found = 1;
19235           goto __pyx_L34;
19236         }
19237         /*else*/ {
19238           __pyx_v_match_found = 0;
19239           goto __pyx_L32_break;
19240         }
19241         __pyx_L34:;
19242       }
19243     }
19244     __pyx_L32_break:;
19245     __pyx_t_2 = (__pyx_v_match_found != 0);
19246     if (__pyx_t_2) {
19247       __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_candidates, __pyx_v_sig); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 826, __pyx_L1_error)
19248     }
19249   }
19250   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19251   __pyx_t_2 = (PyList_GET_SIZE(__pyx_v_candidates) != 0);
19252   __pyx_t_3 = ((!__pyx_t_2) != 0);
19253   if (__pyx_t_3) {
19254     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
19255     __Pyx_GOTREF(__pyx_t_6);
19256     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
19257     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19258     __PYX_ERR(0, 826, __pyx_L1_error)
19259   }
19260   __pyx_t_9 = PyList_GET_SIZE(__pyx_v_candidates); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 826, __pyx_L1_error)
19261   __pyx_t_3 = ((__pyx_t_9 > 1) != 0);
19262   if (__pyx_t_3) {
19263     __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
19264     __Pyx_GOTREF(__pyx_t_6);
19265     __Pyx_Raise(__pyx_t_6, 0, 0, 0);
19266     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19267     __PYX_ERR(0, 826, __pyx_L1_error)
19268   }
19269   /*else*/ {
19270     __Pyx_XDECREF(__pyx_r);
19271     if (unlikely(__pyx_v_signatures == Py_None)) {
19272       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
19273       __PYX_ERR(0, 826, __pyx_L1_error)
19274     }
19275     __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject*)__pyx_v_signatures), PyList_GET_ITEM(__pyx_v_candidates, 0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 826, __pyx_L1_error)
19276     __Pyx_GOTREF(__pyx_t_6);
19277     __pyx_r = __pyx_t_6;
19278     __pyx_t_6 = 0;
19279     goto __pyx_L0;
19280   }
19281 
19282   /* function exit code */
19283   __pyx_L1_error:;
19284   __Pyx_XDECREF(__pyx_t_1);
19285   __Pyx_XDECREF(__pyx_t_6);
19286   __Pyx_XDECREF(__pyx_t_12);
19287   __Pyx_XDECREF(__pyx_t_13);
19288   __Pyx_XDECREF(__pyx_t_14);
19289   __Pyx_AddTraceback("dipy.align.sumsqdiff.__pyx_fused_cpdef", __pyx_clineno, __pyx_lineno, __pyx_filename);
19290   __pyx_r = NULL;
19291   __pyx_L0:;
19292   __Pyx_XDECREF(__pyx_v_dest_sig);
19293   __Pyx_XDECREF(__pyx_v_ndarray);
19294   __Pyx_XDECREF(__pyx_v_arg);
19295   __Pyx_XDECREF(__pyx_v_dtype);
19296   __Pyx_XDECREF(__pyx_v_arg_base);
19297   __Pyx_XDECREF(__pyx_v_candidates);
19298   __Pyx_XDECREF(__pyx_v_sig);
19299   __Pyx_XDECREF(__pyx_v_src_sig);
19300   __Pyx_XDECREF(__pyx_v_dst_type);
19301   __Pyx_XDECREF(__pyx_v_kwargs);
19302   __Pyx_XGIVEREF(__pyx_r);
19303   __Pyx_RefNannyFinishContext();
19304   return __pyx_r;
19305 }
19306 
19307 /* Python wrapper */
19308 static PyObject *__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_63compute_ssd_demons_step_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
19309 static PyMethodDef __pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_63compute_ssd_demons_step_3d = {"__pyx_fuse_0compute_ssd_demons_step_3d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_63compute_ssd_demons_step_3d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_18compute_ssd_demons_step_3d};
__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_63compute_ssd_demons_step_3d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)19310 static PyObject *__pyx_fuse_0__pyx_pw_4dipy_5align_9sumsqdiff_63compute_ssd_demons_step_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
19311   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
19312   __Pyx_memviewslice __pyx_v_gradient_moving = { 0, 0, { 0 }, { 0 }, { 0 } };
19313   double __pyx_v_sigma_sq_x;
19314   __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
19315   int __pyx_lineno = 0;
19316   const char *__pyx_filename = NULL;
19317   int __pyx_clineno = 0;
19318   PyObject *__pyx_r = 0;
19319   __Pyx_RefNannyDeclarations
19320   __Pyx_RefNannySetupContext("compute_ssd_demons_step_3d (wrapper)", 0);
19321   {
19322     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_gradient_moving,&__pyx_n_s_sigma_sq_x,&__pyx_n_s_out,0};
19323     PyObject* values[4] = {0,0,0,0};
19324     if (unlikely(__pyx_kwds)) {
19325       Py_ssize_t kw_args;
19326       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
19327       switch (pos_args) {
19328         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
19329         CYTHON_FALLTHROUGH;
19330         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
19331         CYTHON_FALLTHROUGH;
19332         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
19333         CYTHON_FALLTHROUGH;
19334         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
19335         CYTHON_FALLTHROUGH;
19336         case  0: break;
19337         default: goto __pyx_L5_argtuple_error;
19338       }
19339       kw_args = PyDict_Size(__pyx_kwds);
19340       switch (pos_args) {
19341         case  0:
19342         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
19343         else goto __pyx_L5_argtuple_error;
19344         CYTHON_FALLTHROUGH;
19345         case  1:
19346         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gradient_moving)) != 0)) kw_args--;
19347         else {
19348           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_3d", 1, 4, 4, 1); __PYX_ERR(0, 826, __pyx_L3_error)
19349         }
19350         CYTHON_FALLTHROUGH;
19351         case  2:
19352         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma_sq_x)) != 0)) kw_args--;
19353         else {
19354           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_3d", 1, 4, 4, 2); __PYX_ERR(0, 826, __pyx_L3_error)
19355         }
19356         CYTHON_FALLTHROUGH;
19357         case  3:
19358         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
19359         else {
19360           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_3d", 1, 4, 4, 3); __PYX_ERR(0, 826, __pyx_L3_error)
19361         }
19362       }
19363       if (unlikely(kw_args > 0)) {
19364         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compute_ssd_demons_step_3d") < 0)) __PYX_ERR(0, 826, __pyx_L3_error)
19365       }
19366     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
19367       goto __pyx_L5_argtuple_error;
19368     } else {
19369       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
19370       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
19371       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
19372       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
19373     }
19374     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 826, __pyx_L3_error)
19375     __pyx_v_gradient_moving = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_gradient_moving.memview)) __PYX_ERR(0, 827, __pyx_L3_error)
19376     __pyx_v_sigma_sq_x = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_sigma_sq_x == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 828, __pyx_L3_error)
19377     __pyx_v_out = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_out.memview)) __PYX_ERR(0, 829, __pyx_L3_error)
19378   }
19379   goto __pyx_L4_argument_unpacking_done;
19380   __pyx_L5_argtuple_error:;
19381   __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_3d", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 826, __pyx_L3_error)
19382   __pyx_L3_error:;
19383   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_ssd_demons_step_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
19384   __Pyx_RefNannyFinishContext();
19385   return NULL;
19386   __pyx_L4_argument_unpacking_done:;
19387   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_62compute_ssd_demons_step_3d(__pyx_self, __pyx_v_delta_field, __pyx_v_gradient_moving, __pyx_v_sigma_sq_x, __pyx_v_out);
19388 
19389   /* function exit code */
19390   __Pyx_RefNannyFinishContext();
19391   return __pyx_r;
19392 }
19393 
__pyx_pf_4dipy_5align_9sumsqdiff_62compute_ssd_demons_step_3d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_gradient_moving,double __pyx_v_sigma_sq_x,__Pyx_memviewslice __pyx_v_out)19394 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_62compute_ssd_demons_step_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_gradient_moving, double __pyx_v_sigma_sq_x, __Pyx_memviewslice __pyx_v_out) {
19395   npy_intp __pyx_v_ns;
19396   npy_intp __pyx_v_nr;
19397   npy_intp __pyx_v_nc;
19398   npy_intp __pyx_v_i;
19399   npy_intp __pyx_v_j;
19400   npy_intp __pyx_v_k;
19401   double __pyx_v_delta;
19402   double __pyx_v_delta_2;
19403   double __pyx_v_nrm2;
19404   double __pyx_v_energy;
19405   double __pyx_v_den;
19406   PyObject *__pyx_r = NULL;
19407   __Pyx_RefNannyDeclarations
19408   int __pyx_t_1;
19409   PyObject *__pyx_t_2 = NULL;
19410   PyObject *__pyx_t_3 = NULL;
19411   PyObject *__pyx_t_4 = NULL;
19412   PyObject *__pyx_t_5 = NULL;
19413   PyObject *__pyx_t_6 = NULL;
19414   PyObject *__pyx_t_7 = NULL;
19415   PyObject *__pyx_t_8 = NULL;
19416   __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } };
19417   npy_intp __pyx_t_10;
19418   npy_intp __pyx_t_11;
19419   npy_intp __pyx_t_12;
19420   npy_intp __pyx_t_13;
19421   npy_intp __pyx_t_14;
19422   npy_intp __pyx_t_15;
19423   npy_intp __pyx_t_16;
19424   npy_intp __pyx_t_17;
19425   npy_intp __pyx_t_18;
19426   Py_ssize_t __pyx_t_19;
19427   Py_ssize_t __pyx_t_20;
19428   Py_ssize_t __pyx_t_21;
19429   Py_ssize_t __pyx_t_22;
19430   Py_ssize_t __pyx_t_23;
19431   Py_ssize_t __pyx_t_24;
19432   Py_ssize_t __pyx_t_25;
19433   Py_ssize_t __pyx_t_26;
19434   Py_ssize_t __pyx_t_27;
19435   Py_ssize_t __pyx_t_28;
19436   Py_ssize_t __pyx_t_29;
19437   Py_ssize_t __pyx_t_30;
19438   int __pyx_lineno = 0;
19439   const char *__pyx_filename = NULL;
19440   int __pyx_clineno = 0;
19441   __Pyx_RefNannySetupContext("__pyx_fuse_0compute_ssd_demons_step_3d", 0);
19442 
19443   /* "dipy/align/sumsqdiff.pyx":869
19444  *     """
19445  *     cdef:
19446  *         cnp.npy_intp ns = delta_field.shape[0]             # <<<<<<<<<<<<<<
19447  *         cnp.npy_intp nr = delta_field.shape[1]
19448  *         cnp.npy_intp nc = delta_field.shape[2]
19449  */
19450   __pyx_v_ns = (__pyx_v_delta_field.shape[0]);
19451 
19452   /* "dipy/align/sumsqdiff.pyx":870
19453  *     cdef:
19454  *         cnp.npy_intp ns = delta_field.shape[0]
19455  *         cnp.npy_intp nr = delta_field.shape[1]             # <<<<<<<<<<<<<<
19456  *         cnp.npy_intp nc = delta_field.shape[2]
19457  *         cnp.npy_intp i, j, k
19458  */
19459   __pyx_v_nr = (__pyx_v_delta_field.shape[1]);
19460 
19461   /* "dipy/align/sumsqdiff.pyx":871
19462  *         cnp.npy_intp ns = delta_field.shape[0]
19463  *         cnp.npy_intp nr = delta_field.shape[1]
19464  *         cnp.npy_intp nc = delta_field.shape[2]             # <<<<<<<<<<<<<<
19465  *         cnp.npy_intp i, j, k
19466  *         double delta, delta_2, nrm2, energy, den
19467  */
19468   __pyx_v_nc = (__pyx_v_delta_field.shape[2]);
19469 
19470   /* "dipy/align/sumsqdiff.pyx":875
19471  *         double delta, delta_2, nrm2, energy, den
19472  *
19473  *     if out is None:             # <<<<<<<<<<<<<<
19474  *         out = np.zeros((ns, nr, nc, 3), dtype=np.asarray(delta_field).dtype)
19475  *
19476  */
19477   __pyx_t_1 = ((((PyObject *) __pyx_v_out.memview) == Py_None) != 0);
19478   if (__pyx_t_1) {
19479 
19480     /* "dipy/align/sumsqdiff.pyx":876
19481  *
19482  *     if out is None:
19483  *         out = np.zeros((ns, nr, nc, 3), dtype=np.asarray(delta_field).dtype)             # <<<<<<<<<<<<<<
19484  *
19485  *     with nogil:
19486  */
19487     __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
19488     __Pyx_GOTREF(__pyx_t_2);
19489     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 876, __pyx_L1_error)
19490     __Pyx_GOTREF(__pyx_t_3);
19491     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19492     __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_ns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
19493     __Pyx_GOTREF(__pyx_t_2);
19494     __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 876, __pyx_L1_error)
19495     __Pyx_GOTREF(__pyx_t_4);
19496     __pyx_t_5 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 876, __pyx_L1_error)
19497     __Pyx_GOTREF(__pyx_t_5);
19498     __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 876, __pyx_L1_error)
19499     __Pyx_GOTREF(__pyx_t_6);
19500     __Pyx_GIVEREF(__pyx_t_2);
19501     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
19502     __Pyx_GIVEREF(__pyx_t_4);
19503     PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
19504     __Pyx_GIVEREF(__pyx_t_5);
19505     PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
19506     __Pyx_INCREF(__pyx_int_3);
19507     __Pyx_GIVEREF(__pyx_int_3);
19508     PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_3);
19509     __pyx_t_2 = 0;
19510     __pyx_t_4 = 0;
19511     __pyx_t_5 = 0;
19512     __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 876, __pyx_L1_error)
19513     __Pyx_GOTREF(__pyx_t_5);
19514     __Pyx_GIVEREF(__pyx_t_6);
19515     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
19516     __pyx_t_6 = 0;
19517     __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 876, __pyx_L1_error)
19518     __Pyx_GOTREF(__pyx_t_6);
19519     __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
19520     __Pyx_GOTREF(__pyx_t_2);
19521     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 876, __pyx_L1_error)
19522     __Pyx_GOTREF(__pyx_t_7);
19523     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19524     __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 3, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
19525     __Pyx_GOTREF(__pyx_t_2);
19526     __pyx_t_8 = NULL;
19527     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
19528       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
19529       if (likely(__pyx_t_8)) {
19530         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
19531         __Pyx_INCREF(__pyx_t_8);
19532         __Pyx_INCREF(function);
19533         __Pyx_DECREF_SET(__pyx_t_7, function);
19534       }
19535     }
19536     __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2);
19537     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
19538     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19539     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 876, __pyx_L1_error)
19540     __Pyx_GOTREF(__pyx_t_4);
19541     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
19542     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 876, __pyx_L1_error)
19543     __Pyx_GOTREF(__pyx_t_7);
19544     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
19545     if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 876, __pyx_L1_error)
19546     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
19547     __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 876, __pyx_L1_error)
19548     __Pyx_GOTREF(__pyx_t_7);
19549     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19550     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
19551     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19552     __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 876, __pyx_L1_error)
19553     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
19554     __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
19555     __pyx_v_out = __pyx_t_9;
19556     __pyx_t_9.memview = NULL;
19557     __pyx_t_9.data = NULL;
19558 
19559     /* "dipy/align/sumsqdiff.pyx":875
19560  *         double delta, delta_2, nrm2, energy, den
19561  *
19562  *     if out is None:             # <<<<<<<<<<<<<<
19563  *         out = np.zeros((ns, nr, nc, 3), dtype=np.asarray(delta_field).dtype)
19564  *
19565  */
19566   }
19567 
19568   /* "dipy/align/sumsqdiff.pyx":878
19569  *         out = np.zeros((ns, nr, nc, 3), dtype=np.asarray(delta_field).dtype)
19570  *
19571  *     with nogil:             # <<<<<<<<<<<<<<
19572  *
19573  *         energy = 0
19574  */
19575   {
19576       #ifdef WITH_THREAD
19577       PyThreadState *_save;
19578       Py_UNBLOCK_THREADS
19579       __Pyx_FastGIL_Remember();
19580       #endif
19581       /*try:*/ {
19582 
19583         /* "dipy/align/sumsqdiff.pyx":880
19584  *     with nogil:
19585  *
19586  *         energy = 0             # <<<<<<<<<<<<<<
19587  *         for k in range(ns):
19588  *             for i in range(nr):
19589  */
19590         __pyx_v_energy = 0.0;
19591 
19592         /* "dipy/align/sumsqdiff.pyx":881
19593  *
19594  *         energy = 0
19595  *         for k in range(ns):             # <<<<<<<<<<<<<<
19596  *             for i in range(nr):
19597  *                 for j in range(nc):
19598  */
19599         __pyx_t_10 = __pyx_v_ns;
19600         __pyx_t_11 = __pyx_t_10;
19601         for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
19602           __pyx_v_k = __pyx_t_12;
19603 
19604           /* "dipy/align/sumsqdiff.pyx":882
19605  *         energy = 0
19606  *         for k in range(ns):
19607  *             for i in range(nr):             # <<<<<<<<<<<<<<
19608  *                 for j in range(nc):
19609  *                     delta = delta_field[k,i,j]
19610  */
19611           __pyx_t_13 = __pyx_v_nr;
19612           __pyx_t_14 = __pyx_t_13;
19613           for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
19614             __pyx_v_i = __pyx_t_15;
19615 
19616             /* "dipy/align/sumsqdiff.pyx":883
19617  *         for k in range(ns):
19618  *             for i in range(nr):
19619  *                 for j in range(nc):             # <<<<<<<<<<<<<<
19620  *                     delta = delta_field[k,i,j]
19621  *                     delta_2 = delta**2
19622  */
19623             __pyx_t_16 = __pyx_v_nc;
19624             __pyx_t_17 = __pyx_t_16;
19625             for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
19626               __pyx_v_j = __pyx_t_18;
19627 
19628               /* "dipy/align/sumsqdiff.pyx":884
19629  *             for i in range(nr):
19630  *                 for j in range(nc):
19631  *                     delta = delta_field[k,i,j]             # <<<<<<<<<<<<<<
19632  *                     delta_2 = delta**2
19633  *                     energy += delta_2
19634  */
19635               __pyx_t_19 = __pyx_v_k;
19636               __pyx_t_20 = __pyx_v_i;
19637               __pyx_t_21 = __pyx_v_j;
19638               __pyx_v_delta = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_19 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_20 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_21 * __pyx_v_delta_field.strides[2]) )));
19639 
19640               /* "dipy/align/sumsqdiff.pyx":885
19641  *                 for j in range(nc):
19642  *                     delta = delta_field[k,i,j]
19643  *                     delta_2 = delta**2             # <<<<<<<<<<<<<<
19644  *                     energy += delta_2
19645  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +
19646  */
19647               __pyx_v_delta_2 = pow(__pyx_v_delta, 2.0);
19648 
19649               /* "dipy/align/sumsqdiff.pyx":886
19650  *                     delta = delta_field[k,i,j]
19651  *                     delta_2 = delta**2
19652  *                     energy += delta_2             # <<<<<<<<<<<<<<
19653  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +
19654  *                             gradient_moving[k, i, j, 1]**2 +
19655  */
19656               __pyx_v_energy = (__pyx_v_energy + __pyx_v_delta_2);
19657 
19658               /* "dipy/align/sumsqdiff.pyx":887
19659  *                     delta_2 = delta**2
19660  *                     energy += delta_2
19661  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +             # <<<<<<<<<<<<<<
19662  *                             gradient_moving[k, i, j, 1]**2 +
19663  *                             gradient_moving[k, i, j, 2]**2)
19664  */
19665               __pyx_t_21 = __pyx_v_k;
19666               __pyx_t_20 = __pyx_v_i;
19667               __pyx_t_19 = __pyx_v_j;
19668               __pyx_t_22 = 0;
19669 
19670               /* "dipy/align/sumsqdiff.pyx":888
19671  *                     energy += delta_2
19672  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +
19673  *                             gradient_moving[k, i, j, 1]**2 +             # <<<<<<<<<<<<<<
19674  *                             gradient_moving[k, i, j, 2]**2)
19675  *                     den = delta_2/sigma_sq_x + nrm2
19676  */
19677               __pyx_t_23 = __pyx_v_k;
19678               __pyx_t_24 = __pyx_v_i;
19679               __pyx_t_25 = __pyx_v_j;
19680               __pyx_t_26 = 1;
19681 
19682               /* "dipy/align/sumsqdiff.pyx":889
19683  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +
19684  *                             gradient_moving[k, i, j, 1]**2 +
19685  *                             gradient_moving[k, i, j, 2]**2)             # <<<<<<<<<<<<<<
19686  *                     den = delta_2/sigma_sq_x + nrm2
19687  *                     if den < 1e-9:
19688  */
19689               __pyx_t_27 = __pyx_v_k;
19690               __pyx_t_28 = __pyx_v_i;
19691               __pyx_t_29 = __pyx_v_j;
19692               __pyx_t_30 = 2;
19693 
19694               /* "dipy/align/sumsqdiff.pyx":888
19695  *                     energy += delta_2
19696  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +
19697  *                             gradient_moving[k, i, j, 1]**2 +             # <<<<<<<<<<<<<<
19698  *                             gradient_moving[k, i, j, 2]**2)
19699  *                     den = delta_2/sigma_sq_x + nrm2
19700  */
19701               __pyx_v_nrm2 = ((powf((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_21 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_20 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_19 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_22 * __pyx_v_gradient_moving.strides[3]) ))), 2.0) + powf((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_23 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_24 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_25 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_26 * __pyx_v_gradient_moving.strides[3]) ))), 2.0)) + powf((*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_27 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_28 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_29 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_30 * __pyx_v_gradient_moving.strides[3]) ))), 2.0));
19702 
19703               /* "dipy/align/sumsqdiff.pyx":890
19704  *                             gradient_moving[k, i, j, 1]**2 +
19705  *                             gradient_moving[k, i, j, 2]**2)
19706  *                     den = delta_2/sigma_sq_x + nrm2             # <<<<<<<<<<<<<<
19707  *                     if den < 1e-9:
19708  *                         out[k, i, j, 0] = 0
19709  */
19710               __pyx_v_den = ((__pyx_v_delta_2 / __pyx_v_sigma_sq_x) + __pyx_v_nrm2);
19711 
19712               /* "dipy/align/sumsqdiff.pyx":891
19713  *                             gradient_moving[k, i, j, 2]**2)
19714  *                     den = delta_2/sigma_sq_x + nrm2
19715  *                     if den < 1e-9:             # <<<<<<<<<<<<<<
19716  *                         out[k, i, j, 0] = 0
19717  *                         out[k, i, j, 1] = 0
19718  */
19719               __pyx_t_1 = ((__pyx_v_den < 1e-9) != 0);
19720               if (__pyx_t_1) {
19721 
19722                 /* "dipy/align/sumsqdiff.pyx":892
19723  *                     den = delta_2/sigma_sq_x + nrm2
19724  *                     if den < 1e-9:
19725  *                         out[k, i, j, 0] = 0             # <<<<<<<<<<<<<<
19726  *                         out[k, i, j, 1] = 0
19727  *                         out[k, i, j, 2] = 0
19728  */
19729                 __pyx_t_30 = __pyx_v_k;
19730                 __pyx_t_29 = __pyx_v_i;
19731                 __pyx_t_28 = __pyx_v_j;
19732                 __pyx_t_27 = 0;
19733                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_30 * __pyx_v_out.strides[0]) ) + __pyx_t_29 * __pyx_v_out.strides[1]) ) + __pyx_t_28 * __pyx_v_out.strides[2]) ) + __pyx_t_27 * __pyx_v_out.strides[3]) )) = 0.0;
19734 
19735                 /* "dipy/align/sumsqdiff.pyx":893
19736  *                     if den < 1e-9:
19737  *                         out[k, i, j, 0] = 0
19738  *                         out[k, i, j, 1] = 0             # <<<<<<<<<<<<<<
19739  *                         out[k, i, j, 2] = 0
19740  *                     else:
19741  */
19742                 __pyx_t_27 = __pyx_v_k;
19743                 __pyx_t_28 = __pyx_v_i;
19744                 __pyx_t_29 = __pyx_v_j;
19745                 __pyx_t_30 = 1;
19746                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_27 * __pyx_v_out.strides[0]) ) + __pyx_t_28 * __pyx_v_out.strides[1]) ) + __pyx_t_29 * __pyx_v_out.strides[2]) ) + __pyx_t_30 * __pyx_v_out.strides[3]) )) = 0.0;
19747 
19748                 /* "dipy/align/sumsqdiff.pyx":894
19749  *                         out[k, i, j, 0] = 0
19750  *                         out[k, i, j, 1] = 0
19751  *                         out[k, i, j, 2] = 0             # <<<<<<<<<<<<<<
19752  *                     else:
19753  *                         out[k, i, j, 0] = (delta *
19754  */
19755                 __pyx_t_30 = __pyx_v_k;
19756                 __pyx_t_29 = __pyx_v_i;
19757                 __pyx_t_28 = __pyx_v_j;
19758                 __pyx_t_27 = 2;
19759                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_30 * __pyx_v_out.strides[0]) ) + __pyx_t_29 * __pyx_v_out.strides[1]) ) + __pyx_t_28 * __pyx_v_out.strides[2]) ) + __pyx_t_27 * __pyx_v_out.strides[3]) )) = 0.0;
19760 
19761                 /* "dipy/align/sumsqdiff.pyx":891
19762  *                             gradient_moving[k, i, j, 2]**2)
19763  *                     den = delta_2/sigma_sq_x + nrm2
19764  *                     if den < 1e-9:             # <<<<<<<<<<<<<<
19765  *                         out[k, i, j, 0] = 0
19766  *                         out[k, i, j, 1] = 0
19767  */
19768                 goto __pyx_L13;
19769               }
19770 
19771               /* "dipy/align/sumsqdiff.pyx":896
19772  *                         out[k, i, j, 2] = 0
19773  *                     else:
19774  *                         out[k, i, j, 0] = (delta *             # <<<<<<<<<<<<<<
19775  *                                            gradient_moving[k, i, j, 0] / den)
19776  *                         out[k, i, j, 1] = (delta *
19777  */
19778               /*else*/ {
19779 
19780                 /* "dipy/align/sumsqdiff.pyx":897
19781  *                     else:
19782  *                         out[k, i, j, 0] = (delta *
19783  *                                            gradient_moving[k, i, j, 0] / den)             # <<<<<<<<<<<<<<
19784  *                         out[k, i, j, 1] = (delta *
19785  *                                            gradient_moving[k, i, j, 1] / den)
19786  */
19787                 __pyx_t_27 = __pyx_v_k;
19788                 __pyx_t_28 = __pyx_v_i;
19789                 __pyx_t_29 = __pyx_v_j;
19790                 __pyx_t_30 = 0;
19791 
19792                 /* "dipy/align/sumsqdiff.pyx":896
19793  *                         out[k, i, j, 2] = 0
19794  *                     else:
19795  *                         out[k, i, j, 0] = (delta *             # <<<<<<<<<<<<<<
19796  *                                            gradient_moving[k, i, j, 0] / den)
19797  *                         out[k, i, j, 1] = (delta *
19798  */
19799                 __pyx_t_26 = __pyx_v_k;
19800                 __pyx_t_25 = __pyx_v_i;
19801                 __pyx_t_24 = __pyx_v_j;
19802                 __pyx_t_23 = 0;
19803                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_26 * __pyx_v_out.strides[0]) ) + __pyx_t_25 * __pyx_v_out.strides[1]) ) + __pyx_t_24 * __pyx_v_out.strides[2]) ) + __pyx_t_23 * __pyx_v_out.strides[3]) )) = ((__pyx_v_delta * (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_27 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_28 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_29 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_30 * __pyx_v_gradient_moving.strides[3]) )))) / __pyx_v_den);
19804 
19805                 /* "dipy/align/sumsqdiff.pyx":899
19806  *                                            gradient_moving[k, i, j, 0] / den)
19807  *                         out[k, i, j, 1] = (delta *
19808  *                                            gradient_moving[k, i, j, 1] / den)             # <<<<<<<<<<<<<<
19809  *                         out[k, i, j, 2] = (delta *
19810  *                                            gradient_moving[k, i, j, 2] / den)
19811  */
19812                 __pyx_t_30 = __pyx_v_k;
19813                 __pyx_t_29 = __pyx_v_i;
19814                 __pyx_t_28 = __pyx_v_j;
19815                 __pyx_t_27 = 1;
19816 
19817                 /* "dipy/align/sumsqdiff.pyx":898
19818  *                         out[k, i, j, 0] = (delta *
19819  *                                            gradient_moving[k, i, j, 0] / den)
19820  *                         out[k, i, j, 1] = (delta *             # <<<<<<<<<<<<<<
19821  *                                            gradient_moving[k, i, j, 1] / den)
19822  *                         out[k, i, j, 2] = (delta *
19823  */
19824                 __pyx_t_23 = __pyx_v_k;
19825                 __pyx_t_24 = __pyx_v_i;
19826                 __pyx_t_25 = __pyx_v_j;
19827                 __pyx_t_26 = 1;
19828                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_23 * __pyx_v_out.strides[0]) ) + __pyx_t_24 * __pyx_v_out.strides[1]) ) + __pyx_t_25 * __pyx_v_out.strides[2]) ) + __pyx_t_26 * __pyx_v_out.strides[3]) )) = ((__pyx_v_delta * (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_30 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_29 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_28 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_27 * __pyx_v_gradient_moving.strides[3]) )))) / __pyx_v_den);
19829 
19830                 /* "dipy/align/sumsqdiff.pyx":901
19831  *                                            gradient_moving[k, i, j, 1] / den)
19832  *                         out[k, i, j, 2] = (delta *
19833  *                                            gradient_moving[k, i, j, 2] / den)             # <<<<<<<<<<<<<<
19834  *     return np.asarray(out), energy
19835  */
19836                 __pyx_t_27 = __pyx_v_k;
19837                 __pyx_t_28 = __pyx_v_i;
19838                 __pyx_t_29 = __pyx_v_j;
19839                 __pyx_t_30 = 2;
19840 
19841                 /* "dipy/align/sumsqdiff.pyx":900
19842  *                         out[k, i, j, 1] = (delta *
19843  *                                            gradient_moving[k, i, j, 1] / den)
19844  *                         out[k, i, j, 2] = (delta *             # <<<<<<<<<<<<<<
19845  *                                            gradient_moving[k, i, j, 2] / den)
19846  *     return np.asarray(out), energy
19847  */
19848                 __pyx_t_26 = __pyx_v_k;
19849                 __pyx_t_25 = __pyx_v_i;
19850                 __pyx_t_24 = __pyx_v_j;
19851                 __pyx_t_23 = 2;
19852                 *((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_26 * __pyx_v_out.strides[0]) ) + __pyx_t_25 * __pyx_v_out.strides[1]) ) + __pyx_t_24 * __pyx_v_out.strides[2]) ) + __pyx_t_23 * __pyx_v_out.strides[3]) )) = ((__pyx_v_delta * (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_27 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_28 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_29 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_30 * __pyx_v_gradient_moving.strides[3]) )))) / __pyx_v_den);
19853               }
19854               __pyx_L13:;
19855             }
19856           }
19857         }
19858       }
19859 
19860       /* "dipy/align/sumsqdiff.pyx":878
19861  *         out = np.zeros((ns, nr, nc, 3), dtype=np.asarray(delta_field).dtype)
19862  *
19863  *     with nogil:             # <<<<<<<<<<<<<<
19864  *
19865  *         energy = 0
19866  */
19867       /*finally:*/ {
19868         /*normal exit:*/{
19869           #ifdef WITH_THREAD
19870           __Pyx_FastGIL_Forget();
19871           Py_BLOCK_THREADS
19872           #endif
19873           goto __pyx_L6;
19874         }
19875         __pyx_L6:;
19876       }
19877   }
19878 
19879   /* "dipy/align/sumsqdiff.pyx":902
19880  *                         out[k, i, j, 2] = (delta *
19881  *                                            gradient_moving[k, i, j, 2] / den)
19882  *     return np.asarray(out), energy             # <<<<<<<<<<<<<<
19883  */
19884   __Pyx_XDECREF(__pyx_r);
19885   __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 902, __pyx_L1_error)
19886   __Pyx_GOTREF(__pyx_t_6);
19887   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 902, __pyx_L1_error)
19888   __Pyx_GOTREF(__pyx_t_5);
19889   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19890   __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_out, 4, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 902, __pyx_L1_error)
19891   __Pyx_GOTREF(__pyx_t_6);
19892   __pyx_t_3 = NULL;
19893   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
19894     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
19895     if (likely(__pyx_t_3)) {
19896       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
19897       __Pyx_INCREF(__pyx_t_3);
19898       __Pyx_INCREF(function);
19899       __Pyx_DECREF_SET(__pyx_t_5, function);
19900     }
19901   }
19902   __pyx_t_7 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
19903   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
19904   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
19905   if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 902, __pyx_L1_error)
19906   __Pyx_GOTREF(__pyx_t_7);
19907   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
19908   __pyx_t_5 = PyFloat_FromDouble(__pyx_v_energy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 902, __pyx_L1_error)
19909   __Pyx_GOTREF(__pyx_t_5);
19910   __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 902, __pyx_L1_error)
19911   __Pyx_GOTREF(__pyx_t_6);
19912   __Pyx_GIVEREF(__pyx_t_7);
19913   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
19914   __Pyx_GIVEREF(__pyx_t_5);
19915   PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
19916   __pyx_t_7 = 0;
19917   __pyx_t_5 = 0;
19918   __pyx_r = __pyx_t_6;
19919   __pyx_t_6 = 0;
19920   goto __pyx_L0;
19921 
19922   /* "dipy/align/sumsqdiff.pyx":826
19923  * @cython.wraparound(False)
19924  * @cython.cdivision(True)
19925  * def compute_ssd_demons_step_3d(floating[:,:,:] delta_field,             # <<<<<<<<<<<<<<
19926  *                                floating[:,:,:,:] gradient_moving,
19927  *                                double sigma_sq_x,
19928  */
19929 
19930   /* function exit code */
19931   __pyx_L1_error:;
19932   __Pyx_XDECREF(__pyx_t_2);
19933   __Pyx_XDECREF(__pyx_t_3);
19934   __Pyx_XDECREF(__pyx_t_4);
19935   __Pyx_XDECREF(__pyx_t_5);
19936   __Pyx_XDECREF(__pyx_t_6);
19937   __Pyx_XDECREF(__pyx_t_7);
19938   __Pyx_XDECREF(__pyx_t_8);
19939   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
19940   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_ssd_demons_step_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
19941   __pyx_r = NULL;
19942   __pyx_L0:;
19943   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
19944   __PYX_XDEC_MEMVIEW(&__pyx_v_gradient_moving, 1);
19945   __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
19946   __Pyx_XGIVEREF(__pyx_r);
19947   __Pyx_RefNannyFinishContext();
19948   return __pyx_r;
19949 }
19950 
19951 /* Python wrapper */
19952 static PyObject *__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_65compute_ssd_demons_step_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
19953 static PyMethodDef __pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_65compute_ssd_demons_step_3d = {"__pyx_fuse_1compute_ssd_demons_step_3d", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_65compute_ssd_demons_step_3d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4dipy_5align_9sumsqdiff_18compute_ssd_demons_step_3d};
__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_65compute_ssd_demons_step_3d(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)19954 static PyObject *__pyx_fuse_1__pyx_pw_4dipy_5align_9sumsqdiff_65compute_ssd_demons_step_3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
19955   __Pyx_memviewslice __pyx_v_delta_field = { 0, 0, { 0 }, { 0 }, { 0 } };
19956   __Pyx_memviewslice __pyx_v_gradient_moving = { 0, 0, { 0 }, { 0 }, { 0 } };
19957   double __pyx_v_sigma_sq_x;
19958   __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
19959   int __pyx_lineno = 0;
19960   const char *__pyx_filename = NULL;
19961   int __pyx_clineno = 0;
19962   PyObject *__pyx_r = 0;
19963   __Pyx_RefNannyDeclarations
19964   __Pyx_RefNannySetupContext("compute_ssd_demons_step_3d (wrapper)", 0);
19965   {
19966     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_delta_field,&__pyx_n_s_gradient_moving,&__pyx_n_s_sigma_sq_x,&__pyx_n_s_out,0};
19967     PyObject* values[4] = {0,0,0,0};
19968     if (unlikely(__pyx_kwds)) {
19969       Py_ssize_t kw_args;
19970       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
19971       switch (pos_args) {
19972         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
19973         CYTHON_FALLTHROUGH;
19974         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
19975         CYTHON_FALLTHROUGH;
19976         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
19977         CYTHON_FALLTHROUGH;
19978         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
19979         CYTHON_FALLTHROUGH;
19980         case  0: break;
19981         default: goto __pyx_L5_argtuple_error;
19982       }
19983       kw_args = PyDict_Size(__pyx_kwds);
19984       switch (pos_args) {
19985         case  0:
19986         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_delta_field)) != 0)) kw_args--;
19987         else goto __pyx_L5_argtuple_error;
19988         CYTHON_FALLTHROUGH;
19989         case  1:
19990         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gradient_moving)) != 0)) kw_args--;
19991         else {
19992           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_3d", 1, 4, 4, 1); __PYX_ERR(0, 826, __pyx_L3_error)
19993         }
19994         CYTHON_FALLTHROUGH;
19995         case  2:
19996         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma_sq_x)) != 0)) kw_args--;
19997         else {
19998           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_3d", 1, 4, 4, 2); __PYX_ERR(0, 826, __pyx_L3_error)
19999         }
20000         CYTHON_FALLTHROUGH;
20001         case  3:
20002         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
20003         else {
20004           __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_3d", 1, 4, 4, 3); __PYX_ERR(0, 826, __pyx_L3_error)
20005         }
20006       }
20007       if (unlikely(kw_args > 0)) {
20008         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compute_ssd_demons_step_3d") < 0)) __PYX_ERR(0, 826, __pyx_L3_error)
20009       }
20010     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
20011       goto __pyx_L5_argtuple_error;
20012     } else {
20013       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
20014       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
20015       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
20016       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
20017     }
20018     __pyx_v_delta_field = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_delta_field.memview)) __PYX_ERR(0, 826, __pyx_L3_error)
20019     __pyx_v_gradient_moving = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_gradient_moving.memview)) __PYX_ERR(0, 827, __pyx_L3_error)
20020     __pyx_v_sigma_sq_x = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_sigma_sq_x == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 828, __pyx_L3_error)
20021     __pyx_v_out = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_out.memview)) __PYX_ERR(0, 829, __pyx_L3_error)
20022   }
20023   goto __pyx_L4_argument_unpacking_done;
20024   __pyx_L5_argtuple_error:;
20025   __Pyx_RaiseArgtupleInvalid("compute_ssd_demons_step_3d", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 826, __pyx_L3_error)
20026   __pyx_L3_error:;
20027   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_ssd_demons_step_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
20028   __Pyx_RefNannyFinishContext();
20029   return NULL;
20030   __pyx_L4_argument_unpacking_done:;
20031   __pyx_r = __pyx_pf_4dipy_5align_9sumsqdiff_64compute_ssd_demons_step_3d(__pyx_self, __pyx_v_delta_field, __pyx_v_gradient_moving, __pyx_v_sigma_sq_x, __pyx_v_out);
20032 
20033   /* function exit code */
20034   __Pyx_RefNannyFinishContext();
20035   return __pyx_r;
20036 }
20037 
__pyx_pf_4dipy_5align_9sumsqdiff_64compute_ssd_demons_step_3d(CYTHON_UNUSED PyObject * __pyx_self,__Pyx_memviewslice __pyx_v_delta_field,__Pyx_memviewslice __pyx_v_gradient_moving,double __pyx_v_sigma_sq_x,__Pyx_memviewslice __pyx_v_out)20038 static PyObject *__pyx_pf_4dipy_5align_9sumsqdiff_64compute_ssd_demons_step_3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_delta_field, __Pyx_memviewslice __pyx_v_gradient_moving, double __pyx_v_sigma_sq_x, __Pyx_memviewslice __pyx_v_out) {
20039   npy_intp __pyx_v_ns;
20040   npy_intp __pyx_v_nr;
20041   npy_intp __pyx_v_nc;
20042   npy_intp __pyx_v_i;
20043   npy_intp __pyx_v_j;
20044   npy_intp __pyx_v_k;
20045   double __pyx_v_delta;
20046   double __pyx_v_delta_2;
20047   double __pyx_v_nrm2;
20048   double __pyx_v_energy;
20049   double __pyx_v_den;
20050   PyObject *__pyx_r = NULL;
20051   __Pyx_RefNannyDeclarations
20052   int __pyx_t_1;
20053   PyObject *__pyx_t_2 = NULL;
20054   PyObject *__pyx_t_3 = NULL;
20055   PyObject *__pyx_t_4 = NULL;
20056   PyObject *__pyx_t_5 = NULL;
20057   PyObject *__pyx_t_6 = NULL;
20058   PyObject *__pyx_t_7 = NULL;
20059   PyObject *__pyx_t_8 = NULL;
20060   __Pyx_memviewslice __pyx_t_9 = { 0, 0, { 0 }, { 0 }, { 0 } };
20061   npy_intp __pyx_t_10;
20062   npy_intp __pyx_t_11;
20063   npy_intp __pyx_t_12;
20064   npy_intp __pyx_t_13;
20065   npy_intp __pyx_t_14;
20066   npy_intp __pyx_t_15;
20067   npy_intp __pyx_t_16;
20068   npy_intp __pyx_t_17;
20069   npy_intp __pyx_t_18;
20070   Py_ssize_t __pyx_t_19;
20071   Py_ssize_t __pyx_t_20;
20072   Py_ssize_t __pyx_t_21;
20073   Py_ssize_t __pyx_t_22;
20074   Py_ssize_t __pyx_t_23;
20075   Py_ssize_t __pyx_t_24;
20076   Py_ssize_t __pyx_t_25;
20077   Py_ssize_t __pyx_t_26;
20078   Py_ssize_t __pyx_t_27;
20079   Py_ssize_t __pyx_t_28;
20080   Py_ssize_t __pyx_t_29;
20081   Py_ssize_t __pyx_t_30;
20082   int __pyx_lineno = 0;
20083   const char *__pyx_filename = NULL;
20084   int __pyx_clineno = 0;
20085   __Pyx_RefNannySetupContext("__pyx_fuse_1compute_ssd_demons_step_3d", 0);
20086 
20087   /* "dipy/align/sumsqdiff.pyx":869
20088  *     """
20089  *     cdef:
20090  *         cnp.npy_intp ns = delta_field.shape[0]             # <<<<<<<<<<<<<<
20091  *         cnp.npy_intp nr = delta_field.shape[1]
20092  *         cnp.npy_intp nc = delta_field.shape[2]
20093  */
20094   __pyx_v_ns = (__pyx_v_delta_field.shape[0]);
20095 
20096   /* "dipy/align/sumsqdiff.pyx":870
20097  *     cdef:
20098  *         cnp.npy_intp ns = delta_field.shape[0]
20099  *         cnp.npy_intp nr = delta_field.shape[1]             # <<<<<<<<<<<<<<
20100  *         cnp.npy_intp nc = delta_field.shape[2]
20101  *         cnp.npy_intp i, j, k
20102  */
20103   __pyx_v_nr = (__pyx_v_delta_field.shape[1]);
20104 
20105   /* "dipy/align/sumsqdiff.pyx":871
20106  *         cnp.npy_intp ns = delta_field.shape[0]
20107  *         cnp.npy_intp nr = delta_field.shape[1]
20108  *         cnp.npy_intp nc = delta_field.shape[2]             # <<<<<<<<<<<<<<
20109  *         cnp.npy_intp i, j, k
20110  *         double delta, delta_2, nrm2, energy, den
20111  */
20112   __pyx_v_nc = (__pyx_v_delta_field.shape[2]);
20113 
20114   /* "dipy/align/sumsqdiff.pyx":875
20115  *         double delta, delta_2, nrm2, energy, den
20116  *
20117  *     if out is None:             # <<<<<<<<<<<<<<
20118  *         out = np.zeros((ns, nr, nc, 3), dtype=np.asarray(delta_field).dtype)
20119  *
20120  */
20121   __pyx_t_1 = ((((PyObject *) __pyx_v_out.memview) == Py_None) != 0);
20122   if (__pyx_t_1) {
20123 
20124     /* "dipy/align/sumsqdiff.pyx":876
20125  *
20126  *     if out is None:
20127  *         out = np.zeros((ns, nr, nc, 3), dtype=np.asarray(delta_field).dtype)             # <<<<<<<<<<<<<<
20128  *
20129  *     with nogil:
20130  */
20131     __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
20132     __Pyx_GOTREF(__pyx_t_2);
20133     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 876, __pyx_L1_error)
20134     __Pyx_GOTREF(__pyx_t_3);
20135     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20136     __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_ns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
20137     __Pyx_GOTREF(__pyx_t_2);
20138     __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 876, __pyx_L1_error)
20139     __Pyx_GOTREF(__pyx_t_4);
20140     __pyx_t_5 = __Pyx_PyInt_From_Py_intptr_t(__pyx_v_nc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 876, __pyx_L1_error)
20141     __Pyx_GOTREF(__pyx_t_5);
20142     __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 876, __pyx_L1_error)
20143     __Pyx_GOTREF(__pyx_t_6);
20144     __Pyx_GIVEREF(__pyx_t_2);
20145     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
20146     __Pyx_GIVEREF(__pyx_t_4);
20147     PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
20148     __Pyx_GIVEREF(__pyx_t_5);
20149     PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
20150     __Pyx_INCREF(__pyx_int_3);
20151     __Pyx_GIVEREF(__pyx_int_3);
20152     PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_3);
20153     __pyx_t_2 = 0;
20154     __pyx_t_4 = 0;
20155     __pyx_t_5 = 0;
20156     __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 876, __pyx_L1_error)
20157     __Pyx_GOTREF(__pyx_t_5);
20158     __Pyx_GIVEREF(__pyx_t_6);
20159     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
20160     __pyx_t_6 = 0;
20161     __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 876, __pyx_L1_error)
20162     __Pyx_GOTREF(__pyx_t_6);
20163     __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
20164     __Pyx_GOTREF(__pyx_t_2);
20165     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 876, __pyx_L1_error)
20166     __Pyx_GOTREF(__pyx_t_7);
20167     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20168     __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_delta_field, 3, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 876, __pyx_L1_error)
20169     __Pyx_GOTREF(__pyx_t_2);
20170     __pyx_t_8 = NULL;
20171     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
20172       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
20173       if (likely(__pyx_t_8)) {
20174         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
20175         __Pyx_INCREF(__pyx_t_8);
20176         __Pyx_INCREF(function);
20177         __Pyx_DECREF_SET(__pyx_t_7, function);
20178       }
20179     }
20180     __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2);
20181     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
20182     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20183     if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 876, __pyx_L1_error)
20184     __Pyx_GOTREF(__pyx_t_4);
20185     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20186     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 876, __pyx_L1_error)
20187     __Pyx_GOTREF(__pyx_t_7);
20188     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20189     if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 876, __pyx_L1_error)
20190     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20191     __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 876, __pyx_L1_error)
20192     __Pyx_GOTREF(__pyx_t_7);
20193     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20194     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
20195     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20196     __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 876, __pyx_L1_error)
20197     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20198     __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
20199     __pyx_v_out = __pyx_t_9;
20200     __pyx_t_9.memview = NULL;
20201     __pyx_t_9.data = NULL;
20202 
20203     /* "dipy/align/sumsqdiff.pyx":875
20204  *         double delta, delta_2, nrm2, energy, den
20205  *
20206  *     if out is None:             # <<<<<<<<<<<<<<
20207  *         out = np.zeros((ns, nr, nc, 3), dtype=np.asarray(delta_field).dtype)
20208  *
20209  */
20210   }
20211 
20212   /* "dipy/align/sumsqdiff.pyx":878
20213  *         out = np.zeros((ns, nr, nc, 3), dtype=np.asarray(delta_field).dtype)
20214  *
20215  *     with nogil:             # <<<<<<<<<<<<<<
20216  *
20217  *         energy = 0
20218  */
20219   {
20220       #ifdef WITH_THREAD
20221       PyThreadState *_save;
20222       Py_UNBLOCK_THREADS
20223       __Pyx_FastGIL_Remember();
20224       #endif
20225       /*try:*/ {
20226 
20227         /* "dipy/align/sumsqdiff.pyx":880
20228  *     with nogil:
20229  *
20230  *         energy = 0             # <<<<<<<<<<<<<<
20231  *         for k in range(ns):
20232  *             for i in range(nr):
20233  */
20234         __pyx_v_energy = 0.0;
20235 
20236         /* "dipy/align/sumsqdiff.pyx":881
20237  *
20238  *         energy = 0
20239  *         for k in range(ns):             # <<<<<<<<<<<<<<
20240  *             for i in range(nr):
20241  *                 for j in range(nc):
20242  */
20243         __pyx_t_10 = __pyx_v_ns;
20244         __pyx_t_11 = __pyx_t_10;
20245         for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
20246           __pyx_v_k = __pyx_t_12;
20247 
20248           /* "dipy/align/sumsqdiff.pyx":882
20249  *         energy = 0
20250  *         for k in range(ns):
20251  *             for i in range(nr):             # <<<<<<<<<<<<<<
20252  *                 for j in range(nc):
20253  *                     delta = delta_field[k,i,j]
20254  */
20255           __pyx_t_13 = __pyx_v_nr;
20256           __pyx_t_14 = __pyx_t_13;
20257           for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
20258             __pyx_v_i = __pyx_t_15;
20259 
20260             /* "dipy/align/sumsqdiff.pyx":883
20261  *         for k in range(ns):
20262  *             for i in range(nr):
20263  *                 for j in range(nc):             # <<<<<<<<<<<<<<
20264  *                     delta = delta_field[k,i,j]
20265  *                     delta_2 = delta**2
20266  */
20267             __pyx_t_16 = __pyx_v_nc;
20268             __pyx_t_17 = __pyx_t_16;
20269             for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
20270               __pyx_v_j = __pyx_t_18;
20271 
20272               /* "dipy/align/sumsqdiff.pyx":884
20273  *             for i in range(nr):
20274  *                 for j in range(nc):
20275  *                     delta = delta_field[k,i,j]             # <<<<<<<<<<<<<<
20276  *                     delta_2 = delta**2
20277  *                     energy += delta_2
20278  */
20279               __pyx_t_19 = __pyx_v_k;
20280               __pyx_t_20 = __pyx_v_i;
20281               __pyx_t_21 = __pyx_v_j;
20282               __pyx_v_delta = (*((double *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_delta_field.data + __pyx_t_19 * __pyx_v_delta_field.strides[0]) ) + __pyx_t_20 * __pyx_v_delta_field.strides[1]) ) + __pyx_t_21 * __pyx_v_delta_field.strides[2]) )));
20283 
20284               /* "dipy/align/sumsqdiff.pyx":885
20285  *                 for j in range(nc):
20286  *                     delta = delta_field[k,i,j]
20287  *                     delta_2 = delta**2             # <<<<<<<<<<<<<<
20288  *                     energy += delta_2
20289  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +
20290  */
20291               __pyx_v_delta_2 = pow(__pyx_v_delta, 2.0);
20292 
20293               /* "dipy/align/sumsqdiff.pyx":886
20294  *                     delta = delta_field[k,i,j]
20295  *                     delta_2 = delta**2
20296  *                     energy += delta_2             # <<<<<<<<<<<<<<
20297  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +
20298  *                             gradient_moving[k, i, j, 1]**2 +
20299  */
20300               __pyx_v_energy = (__pyx_v_energy + __pyx_v_delta_2);
20301 
20302               /* "dipy/align/sumsqdiff.pyx":887
20303  *                     delta_2 = delta**2
20304  *                     energy += delta_2
20305  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +             # <<<<<<<<<<<<<<
20306  *                             gradient_moving[k, i, j, 1]**2 +
20307  *                             gradient_moving[k, i, j, 2]**2)
20308  */
20309               __pyx_t_21 = __pyx_v_k;
20310               __pyx_t_20 = __pyx_v_i;
20311               __pyx_t_19 = __pyx_v_j;
20312               __pyx_t_22 = 0;
20313 
20314               /* "dipy/align/sumsqdiff.pyx":888
20315  *                     energy += delta_2
20316  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +
20317  *                             gradient_moving[k, i, j, 1]**2 +             # <<<<<<<<<<<<<<
20318  *                             gradient_moving[k, i, j, 2]**2)
20319  *                     den = delta_2/sigma_sq_x + nrm2
20320  */
20321               __pyx_t_23 = __pyx_v_k;
20322               __pyx_t_24 = __pyx_v_i;
20323               __pyx_t_25 = __pyx_v_j;
20324               __pyx_t_26 = 1;
20325 
20326               /* "dipy/align/sumsqdiff.pyx":889
20327  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +
20328  *                             gradient_moving[k, i, j, 1]**2 +
20329  *                             gradient_moving[k, i, j, 2]**2)             # <<<<<<<<<<<<<<
20330  *                     den = delta_2/sigma_sq_x + nrm2
20331  *                     if den < 1e-9:
20332  */
20333               __pyx_t_27 = __pyx_v_k;
20334               __pyx_t_28 = __pyx_v_i;
20335               __pyx_t_29 = __pyx_v_j;
20336               __pyx_t_30 = 2;
20337 
20338               /* "dipy/align/sumsqdiff.pyx":888
20339  *                     energy += delta_2
20340  *                     nrm2 = (gradient_moving[k, i, j, 0]**2 +
20341  *                             gradient_moving[k, i, j, 1]**2 +             # <<<<<<<<<<<<<<
20342  *                             gradient_moving[k, i, j, 2]**2)
20343  *                     den = delta_2/sigma_sq_x + nrm2
20344  */
20345               __pyx_v_nrm2 = ((pow((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_21 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_20 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_19 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_22 * __pyx_v_gradient_moving.strides[3]) ))), 2.0) + pow((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_23 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_24 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_25 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_26 * __pyx_v_gradient_moving.strides[3]) ))), 2.0)) + pow((*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_27 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_28 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_29 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_30 * __pyx_v_gradient_moving.strides[3]) ))), 2.0));
20346 
20347               /* "dipy/align/sumsqdiff.pyx":890
20348  *                             gradient_moving[k, i, j, 1]**2 +
20349  *                             gradient_moving[k, i, j, 2]**2)
20350  *                     den = delta_2/sigma_sq_x + nrm2             # <<<<<<<<<<<<<<
20351  *                     if den < 1e-9:
20352  *                         out[k, i, j, 0] = 0
20353  */
20354               __pyx_v_den = ((__pyx_v_delta_2 / __pyx_v_sigma_sq_x) + __pyx_v_nrm2);
20355 
20356               /* "dipy/align/sumsqdiff.pyx":891
20357  *                             gradient_moving[k, i, j, 2]**2)
20358  *                     den = delta_2/sigma_sq_x + nrm2
20359  *                     if den < 1e-9:             # <<<<<<<<<<<<<<
20360  *                         out[k, i, j, 0] = 0
20361  *                         out[k, i, j, 1] = 0
20362  */
20363               __pyx_t_1 = ((__pyx_v_den < 1e-9) != 0);
20364               if (__pyx_t_1) {
20365 
20366                 /* "dipy/align/sumsqdiff.pyx":892
20367  *                     den = delta_2/sigma_sq_x + nrm2
20368  *                     if den < 1e-9:
20369  *                         out[k, i, j, 0] = 0             # <<<<<<<<<<<<<<
20370  *                         out[k, i, j, 1] = 0
20371  *                         out[k, i, j, 2] = 0
20372  */
20373                 __pyx_t_30 = __pyx_v_k;
20374                 __pyx_t_29 = __pyx_v_i;
20375                 __pyx_t_28 = __pyx_v_j;
20376                 __pyx_t_27 = 0;
20377                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_30 * __pyx_v_out.strides[0]) ) + __pyx_t_29 * __pyx_v_out.strides[1]) ) + __pyx_t_28 * __pyx_v_out.strides[2]) ) + __pyx_t_27 * __pyx_v_out.strides[3]) )) = 0.0;
20378 
20379                 /* "dipy/align/sumsqdiff.pyx":893
20380  *                     if den < 1e-9:
20381  *                         out[k, i, j, 0] = 0
20382  *                         out[k, i, j, 1] = 0             # <<<<<<<<<<<<<<
20383  *                         out[k, i, j, 2] = 0
20384  *                     else:
20385  */
20386                 __pyx_t_27 = __pyx_v_k;
20387                 __pyx_t_28 = __pyx_v_i;
20388                 __pyx_t_29 = __pyx_v_j;
20389                 __pyx_t_30 = 1;
20390                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_27 * __pyx_v_out.strides[0]) ) + __pyx_t_28 * __pyx_v_out.strides[1]) ) + __pyx_t_29 * __pyx_v_out.strides[2]) ) + __pyx_t_30 * __pyx_v_out.strides[3]) )) = 0.0;
20391 
20392                 /* "dipy/align/sumsqdiff.pyx":894
20393  *                         out[k, i, j, 0] = 0
20394  *                         out[k, i, j, 1] = 0
20395  *                         out[k, i, j, 2] = 0             # <<<<<<<<<<<<<<
20396  *                     else:
20397  *                         out[k, i, j, 0] = (delta *
20398  */
20399                 __pyx_t_30 = __pyx_v_k;
20400                 __pyx_t_29 = __pyx_v_i;
20401                 __pyx_t_28 = __pyx_v_j;
20402                 __pyx_t_27 = 2;
20403                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_30 * __pyx_v_out.strides[0]) ) + __pyx_t_29 * __pyx_v_out.strides[1]) ) + __pyx_t_28 * __pyx_v_out.strides[2]) ) + __pyx_t_27 * __pyx_v_out.strides[3]) )) = 0.0;
20404 
20405                 /* "dipy/align/sumsqdiff.pyx":891
20406  *                             gradient_moving[k, i, j, 2]**2)
20407  *                     den = delta_2/sigma_sq_x + nrm2
20408  *                     if den < 1e-9:             # <<<<<<<<<<<<<<
20409  *                         out[k, i, j, 0] = 0
20410  *                         out[k, i, j, 1] = 0
20411  */
20412                 goto __pyx_L13;
20413               }
20414 
20415               /* "dipy/align/sumsqdiff.pyx":896
20416  *                         out[k, i, j, 2] = 0
20417  *                     else:
20418  *                         out[k, i, j, 0] = (delta *             # <<<<<<<<<<<<<<
20419  *                                            gradient_moving[k, i, j, 0] / den)
20420  *                         out[k, i, j, 1] = (delta *
20421  */
20422               /*else*/ {
20423 
20424                 /* "dipy/align/sumsqdiff.pyx":897
20425  *                     else:
20426  *                         out[k, i, j, 0] = (delta *
20427  *                                            gradient_moving[k, i, j, 0] / den)             # <<<<<<<<<<<<<<
20428  *                         out[k, i, j, 1] = (delta *
20429  *                                            gradient_moving[k, i, j, 1] / den)
20430  */
20431                 __pyx_t_27 = __pyx_v_k;
20432                 __pyx_t_28 = __pyx_v_i;
20433                 __pyx_t_29 = __pyx_v_j;
20434                 __pyx_t_30 = 0;
20435 
20436                 /* "dipy/align/sumsqdiff.pyx":896
20437  *                         out[k, i, j, 2] = 0
20438  *                     else:
20439  *                         out[k, i, j, 0] = (delta *             # <<<<<<<<<<<<<<
20440  *                                            gradient_moving[k, i, j, 0] / den)
20441  *                         out[k, i, j, 1] = (delta *
20442  */
20443                 __pyx_t_26 = __pyx_v_k;
20444                 __pyx_t_25 = __pyx_v_i;
20445                 __pyx_t_24 = __pyx_v_j;
20446                 __pyx_t_23 = 0;
20447                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_26 * __pyx_v_out.strides[0]) ) + __pyx_t_25 * __pyx_v_out.strides[1]) ) + __pyx_t_24 * __pyx_v_out.strides[2]) ) + __pyx_t_23 * __pyx_v_out.strides[3]) )) = ((__pyx_v_delta * (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_27 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_28 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_29 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_30 * __pyx_v_gradient_moving.strides[3]) )))) / __pyx_v_den);
20448 
20449                 /* "dipy/align/sumsqdiff.pyx":899
20450  *                                            gradient_moving[k, i, j, 0] / den)
20451  *                         out[k, i, j, 1] = (delta *
20452  *                                            gradient_moving[k, i, j, 1] / den)             # <<<<<<<<<<<<<<
20453  *                         out[k, i, j, 2] = (delta *
20454  *                                            gradient_moving[k, i, j, 2] / den)
20455  */
20456                 __pyx_t_30 = __pyx_v_k;
20457                 __pyx_t_29 = __pyx_v_i;
20458                 __pyx_t_28 = __pyx_v_j;
20459                 __pyx_t_27 = 1;
20460 
20461                 /* "dipy/align/sumsqdiff.pyx":898
20462  *                         out[k, i, j, 0] = (delta *
20463  *                                            gradient_moving[k, i, j, 0] / den)
20464  *                         out[k, i, j, 1] = (delta *             # <<<<<<<<<<<<<<
20465  *                                            gradient_moving[k, i, j, 1] / den)
20466  *                         out[k, i, j, 2] = (delta *
20467  */
20468                 __pyx_t_23 = __pyx_v_k;
20469                 __pyx_t_24 = __pyx_v_i;
20470                 __pyx_t_25 = __pyx_v_j;
20471                 __pyx_t_26 = 1;
20472                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_23 * __pyx_v_out.strides[0]) ) + __pyx_t_24 * __pyx_v_out.strides[1]) ) + __pyx_t_25 * __pyx_v_out.strides[2]) ) + __pyx_t_26 * __pyx_v_out.strides[3]) )) = ((__pyx_v_delta * (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_30 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_29 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_28 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_27 * __pyx_v_gradient_moving.strides[3]) )))) / __pyx_v_den);
20473 
20474                 /* "dipy/align/sumsqdiff.pyx":901
20475  *                                            gradient_moving[k, i, j, 1] / den)
20476  *                         out[k, i, j, 2] = (delta *
20477  *                                            gradient_moving[k, i, j, 2] / den)             # <<<<<<<<<<<<<<
20478  *     return np.asarray(out), energy
20479  */
20480                 __pyx_t_27 = __pyx_v_k;
20481                 __pyx_t_28 = __pyx_v_i;
20482                 __pyx_t_29 = __pyx_v_j;
20483                 __pyx_t_30 = 2;
20484 
20485                 /* "dipy/align/sumsqdiff.pyx":900
20486  *                         out[k, i, j, 1] = (delta *
20487  *                                            gradient_moving[k, i, j, 1] / den)
20488  *                         out[k, i, j, 2] = (delta *             # <<<<<<<<<<<<<<
20489  *                                            gradient_moving[k, i, j, 2] / den)
20490  *     return np.asarray(out), energy
20491  */
20492                 __pyx_t_26 = __pyx_v_k;
20493                 __pyx_t_25 = __pyx_v_i;
20494                 __pyx_t_24 = __pyx_v_j;
20495                 __pyx_t_23 = 2;
20496                 *((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_26 * __pyx_v_out.strides[0]) ) + __pyx_t_25 * __pyx_v_out.strides[1]) ) + __pyx_t_24 * __pyx_v_out.strides[2]) ) + __pyx_t_23 * __pyx_v_out.strides[3]) )) = ((__pyx_v_delta * (*((double *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_gradient_moving.data + __pyx_t_27 * __pyx_v_gradient_moving.strides[0]) ) + __pyx_t_28 * __pyx_v_gradient_moving.strides[1]) ) + __pyx_t_29 * __pyx_v_gradient_moving.strides[2]) ) + __pyx_t_30 * __pyx_v_gradient_moving.strides[3]) )))) / __pyx_v_den);
20497               }
20498               __pyx_L13:;
20499             }
20500           }
20501         }
20502       }
20503 
20504       /* "dipy/align/sumsqdiff.pyx":878
20505  *         out = np.zeros((ns, nr, nc, 3), dtype=np.asarray(delta_field).dtype)
20506  *
20507  *     with nogil:             # <<<<<<<<<<<<<<
20508  *
20509  *         energy = 0
20510  */
20511       /*finally:*/ {
20512         /*normal exit:*/{
20513           #ifdef WITH_THREAD
20514           __Pyx_FastGIL_Forget();
20515           Py_BLOCK_THREADS
20516           #endif
20517           goto __pyx_L6;
20518         }
20519         __pyx_L6:;
20520       }
20521   }
20522 
20523   /* "dipy/align/sumsqdiff.pyx":902
20524  *                         out[k, i, j, 2] = (delta *
20525  *                                            gradient_moving[k, i, j, 2] / den)
20526  *     return np.asarray(out), energy             # <<<<<<<<<<<<<<
20527  */
20528   __Pyx_XDECREF(__pyx_r);
20529   __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 902, __pyx_L1_error)
20530   __Pyx_GOTREF(__pyx_t_6);
20531   __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 902, __pyx_L1_error)
20532   __Pyx_GOTREF(__pyx_t_5);
20533   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20534   __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_out, 4, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 902, __pyx_L1_error)
20535   __Pyx_GOTREF(__pyx_t_6);
20536   __pyx_t_3 = NULL;
20537   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
20538     __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
20539     if (likely(__pyx_t_3)) {
20540       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
20541       __Pyx_INCREF(__pyx_t_3);
20542       __Pyx_INCREF(function);
20543       __Pyx_DECREF_SET(__pyx_t_5, function);
20544     }
20545   }
20546   __pyx_t_7 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
20547   __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
20548   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20549   if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 902, __pyx_L1_error)
20550   __Pyx_GOTREF(__pyx_t_7);
20551   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
20552   __pyx_t_5 = PyFloat_FromDouble(__pyx_v_energy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 902, __pyx_L1_error)
20553   __Pyx_GOTREF(__pyx_t_5);
20554   __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 902, __pyx_L1_error)
20555   __Pyx_GOTREF(__pyx_t_6);
20556   __Pyx_GIVEREF(__pyx_t_7);
20557   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
20558   __Pyx_GIVEREF(__pyx_t_5);
20559   PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
20560   __pyx_t_7 = 0;
20561   __pyx_t_5 = 0;
20562   __pyx_r = __pyx_t_6;
20563   __pyx_t_6 = 0;
20564   goto __pyx_L0;
20565 
20566   /* "dipy/align/sumsqdiff.pyx":826
20567  * @cython.wraparound(False)
20568  * @cython.cdivision(True)
20569  * def compute_ssd_demons_step_3d(floating[:,:,:] delta_field,             # <<<<<<<<<<<<<<
20570  *                                floating[:,:,:,:] gradient_moving,
20571  *                                double sigma_sq_x,
20572  */
20573 
20574   /* function exit code */
20575   __pyx_L1_error:;
20576   __Pyx_XDECREF(__pyx_t_2);
20577   __Pyx_XDECREF(__pyx_t_3);
20578   __Pyx_XDECREF(__pyx_t_4);
20579   __Pyx_XDECREF(__pyx_t_5);
20580   __Pyx_XDECREF(__pyx_t_6);
20581   __Pyx_XDECREF(__pyx_t_7);
20582   __Pyx_XDECREF(__pyx_t_8);
20583   __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
20584   __Pyx_AddTraceback("dipy.align.sumsqdiff.compute_ssd_demons_step_3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
20585   __pyx_r = NULL;
20586   __pyx_L0:;
20587   __PYX_XDEC_MEMVIEW(&__pyx_v_delta_field, 1);
20588   __PYX_XDEC_MEMVIEW(&__pyx_v_gradient_moving, 1);
20589   __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1);
20590   __Pyx_XGIVEREF(__pyx_r);
20591   __Pyx_RefNannyFinishContext();
20592   return __pyx_r;
20593 }
20594 
20595 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":735
20596  * ctypedef npy_cdouble     complex_t
20597  *
20598  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
20599  *     return PyArray_MultiIterNew(1, <void*>a)
20600  *
20601  */
20602 
__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject * __pyx_v_a)20603 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
20604   PyObject *__pyx_r = NULL;
20605   __Pyx_RefNannyDeclarations
20606   PyObject *__pyx_t_1 = NULL;
20607   int __pyx_lineno = 0;
20608   const char *__pyx_filename = NULL;
20609   int __pyx_clineno = 0;
20610   __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
20611 
20612   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":736
20613  *
20614  * cdef inline object PyArray_MultiIterNew1(a):
20615  *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
20616  *
20617  * cdef inline object PyArray_MultiIterNew2(a, b):
20618  */
20619   __Pyx_XDECREF(__pyx_r);
20620   __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 736, __pyx_L1_error)
20621   __Pyx_GOTREF(__pyx_t_1);
20622   __pyx_r = __pyx_t_1;
20623   __pyx_t_1 = 0;
20624   goto __pyx_L0;
20625 
20626   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":735
20627  * ctypedef npy_cdouble     complex_t
20628  *
20629  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
20630  *     return PyArray_MultiIterNew(1, <void*>a)
20631  *
20632  */
20633 
20634   /* function exit code */
20635   __pyx_L1_error:;
20636   __Pyx_XDECREF(__pyx_t_1);
20637   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
20638   __pyx_r = 0;
20639   __pyx_L0:;
20640   __Pyx_XGIVEREF(__pyx_r);
20641   __Pyx_RefNannyFinishContext();
20642   return __pyx_r;
20643 }
20644 
20645 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":738
20646  *     return PyArray_MultiIterNew(1, <void*>a)
20647  *
20648  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
20649  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
20650  *
20651  */
20652 
__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject * __pyx_v_a,PyObject * __pyx_v_b)20653 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
20654   PyObject *__pyx_r = NULL;
20655   __Pyx_RefNannyDeclarations
20656   PyObject *__pyx_t_1 = NULL;
20657   int __pyx_lineno = 0;
20658   const char *__pyx_filename = NULL;
20659   int __pyx_clineno = 0;
20660   __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
20661 
20662   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":739
20663  *
20664  * cdef inline object PyArray_MultiIterNew2(a, b):
20665  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
20666  *
20667  * cdef inline object PyArray_MultiIterNew3(a, b, c):
20668  */
20669   __Pyx_XDECREF(__pyx_r);
20670   __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 739, __pyx_L1_error)
20671   __Pyx_GOTREF(__pyx_t_1);
20672   __pyx_r = __pyx_t_1;
20673   __pyx_t_1 = 0;
20674   goto __pyx_L0;
20675 
20676   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":738
20677  *     return PyArray_MultiIterNew(1, <void*>a)
20678  *
20679  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
20680  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
20681  *
20682  */
20683 
20684   /* function exit code */
20685   __pyx_L1_error:;
20686   __Pyx_XDECREF(__pyx_t_1);
20687   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
20688   __pyx_r = 0;
20689   __pyx_L0:;
20690   __Pyx_XGIVEREF(__pyx_r);
20691   __Pyx_RefNannyFinishContext();
20692   return __pyx_r;
20693 }
20694 
20695 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":741
20696  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
20697  *
20698  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
20699  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
20700  *
20701  */
20702 
__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c)20703 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
20704   PyObject *__pyx_r = NULL;
20705   __Pyx_RefNannyDeclarations
20706   PyObject *__pyx_t_1 = NULL;
20707   int __pyx_lineno = 0;
20708   const char *__pyx_filename = NULL;
20709   int __pyx_clineno = 0;
20710   __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
20711 
20712   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":742
20713  *
20714  * cdef inline object PyArray_MultiIterNew3(a, b, c):
20715  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
20716  *
20717  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
20718  */
20719   __Pyx_XDECREF(__pyx_r);
20720   __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, 742, __pyx_L1_error)
20721   __Pyx_GOTREF(__pyx_t_1);
20722   __pyx_r = __pyx_t_1;
20723   __pyx_t_1 = 0;
20724   goto __pyx_L0;
20725 
20726   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":741
20727  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
20728  *
20729  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
20730  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
20731  *
20732  */
20733 
20734   /* function exit code */
20735   __pyx_L1_error:;
20736   __Pyx_XDECREF(__pyx_t_1);
20737   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
20738   __pyx_r = 0;
20739   __pyx_L0:;
20740   __Pyx_XGIVEREF(__pyx_r);
20741   __Pyx_RefNannyFinishContext();
20742   return __pyx_r;
20743 }
20744 
20745 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":744
20746  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
20747  *
20748  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
20749  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
20750  *
20751  */
20752 
__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c,PyObject * __pyx_v_d)20753 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) {
20754   PyObject *__pyx_r = NULL;
20755   __Pyx_RefNannyDeclarations
20756   PyObject *__pyx_t_1 = NULL;
20757   int __pyx_lineno = 0;
20758   const char *__pyx_filename = NULL;
20759   int __pyx_clineno = 0;
20760   __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
20761 
20762   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":745
20763  *
20764  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
20765  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
20766  *
20767  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
20768  */
20769   __Pyx_XDECREF(__pyx_r);
20770   __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, 745, __pyx_L1_error)
20771   __Pyx_GOTREF(__pyx_t_1);
20772   __pyx_r = __pyx_t_1;
20773   __pyx_t_1 = 0;
20774   goto __pyx_L0;
20775 
20776   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":744
20777  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
20778  *
20779  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
20780  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
20781  *
20782  */
20783 
20784   /* function exit code */
20785   __pyx_L1_error:;
20786   __Pyx_XDECREF(__pyx_t_1);
20787   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
20788   __pyx_r = 0;
20789   __pyx_L0:;
20790   __Pyx_XGIVEREF(__pyx_r);
20791   __Pyx_RefNannyFinishContext();
20792   return __pyx_r;
20793 }
20794 
20795 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":747
20796  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
20797  *
20798  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
20799  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
20800  *
20801  */
20802 
__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)20803 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) {
20804   PyObject *__pyx_r = NULL;
20805   __Pyx_RefNannyDeclarations
20806   PyObject *__pyx_t_1 = NULL;
20807   int __pyx_lineno = 0;
20808   const char *__pyx_filename = NULL;
20809   int __pyx_clineno = 0;
20810   __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
20811 
20812   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":748
20813  *
20814  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
20815  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
20816  *
20817  * cdef inline tuple PyDataType_SHAPE(dtype d):
20818  */
20819   __Pyx_XDECREF(__pyx_r);
20820   __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, 748, __pyx_L1_error)
20821   __Pyx_GOTREF(__pyx_t_1);
20822   __pyx_r = __pyx_t_1;
20823   __pyx_t_1 = 0;
20824   goto __pyx_L0;
20825 
20826   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":747
20827  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
20828  *
20829  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
20830  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
20831  *
20832  */
20833 
20834   /* function exit code */
20835   __pyx_L1_error:;
20836   __Pyx_XDECREF(__pyx_t_1);
20837   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
20838   __pyx_r = 0;
20839   __pyx_L0:;
20840   __Pyx_XGIVEREF(__pyx_r);
20841   __Pyx_RefNannyFinishContext();
20842   return __pyx_r;
20843 }
20844 
20845 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":750
20846  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
20847  *
20848  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
20849  *     if PyDataType_HASSUBARRAY(d):
20850  *         return <tuple>d.subarray.shape
20851  */
20852 
__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr * __pyx_v_d)20853 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
20854   PyObject *__pyx_r = NULL;
20855   __Pyx_RefNannyDeclarations
20856   int __pyx_t_1;
20857   __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
20858 
20859   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":751
20860  *
20861  * cdef inline tuple PyDataType_SHAPE(dtype d):
20862  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
20863  *         return <tuple>d.subarray.shape
20864  *     else:
20865  */
20866   __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
20867   if (__pyx_t_1) {
20868 
20869     /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":752
20870  * cdef inline tuple PyDataType_SHAPE(dtype d):
20871  *     if PyDataType_HASSUBARRAY(d):
20872  *         return <tuple>d.subarray.shape             # <<<<<<<<<<<<<<
20873  *     else:
20874  *         return ()
20875  */
20876     __Pyx_XDECREF(__pyx_r);
20877     __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
20878     __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
20879     goto __pyx_L0;
20880 
20881     /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":751
20882  *
20883  * cdef inline tuple PyDataType_SHAPE(dtype d):
20884  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
20885  *         return <tuple>d.subarray.shape
20886  *     else:
20887  */
20888   }
20889 
20890   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":754
20891  *         return <tuple>d.subarray.shape
20892  *     else:
20893  *         return ()             # <<<<<<<<<<<<<<
20894  *
20895  *
20896  */
20897   /*else*/ {
20898     __Pyx_XDECREF(__pyx_r);
20899     __Pyx_INCREF(__pyx_empty_tuple);
20900     __pyx_r = __pyx_empty_tuple;
20901     goto __pyx_L0;
20902   }
20903 
20904   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":750
20905  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
20906  *
20907  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
20908  *     if PyDataType_HASSUBARRAY(d):
20909  *         return <tuple>d.subarray.shape
20910  */
20911 
20912   /* function exit code */
20913   __pyx_L0:;
20914   __Pyx_XGIVEREF(__pyx_r);
20915   __Pyx_RefNannyFinishContext();
20916   return __pyx_r;
20917 }
20918 
20919 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":931
20920  *     int _import_umath() except -1
20921  *
20922  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
20923  *     Py_INCREF(base) # important to do this before stealing the reference below!
20924  *     PyArray_SetBaseObject(arr, base)
20925  */
20926 
__pyx_f_5numpy_set_array_base(PyArrayObject * __pyx_v_arr,PyObject * __pyx_v_base)20927 static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
20928   __Pyx_RefNannyDeclarations
20929   __Pyx_RefNannySetupContext("set_array_base", 0);
20930 
20931   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":932
20932  *
20933  * cdef inline void set_array_base(ndarray arr, object base):
20934  *     Py_INCREF(base) # important to do this before stealing the reference below!             # <<<<<<<<<<<<<<
20935  *     PyArray_SetBaseObject(arr, base)
20936  *
20937  */
20938   Py_INCREF(__pyx_v_base);
20939 
20940   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":933
20941  * cdef inline void set_array_base(ndarray arr, object base):
20942  *     Py_INCREF(base) # important to do this before stealing the reference below!
20943  *     PyArray_SetBaseObject(arr, base)             # <<<<<<<<<<<<<<
20944  *
20945  * cdef inline object get_array_base(ndarray arr):
20946  */
20947   (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));
20948 
20949   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":931
20950  *     int _import_umath() except -1
20951  *
20952  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
20953  *     Py_INCREF(base) # important to do this before stealing the reference below!
20954  *     PyArray_SetBaseObject(arr, base)
20955  */
20956 
20957   /* function exit code */
20958   __Pyx_RefNannyFinishContext();
20959 }
20960 
20961 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":935
20962  *     PyArray_SetBaseObject(arr, base)
20963  *
20964  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
20965  *     base = PyArray_BASE(arr)
20966  *     if base is NULL:
20967  */
20968 
__pyx_f_5numpy_get_array_base(PyArrayObject * __pyx_v_arr)20969 static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
20970   PyObject *__pyx_v_base;
20971   PyObject *__pyx_r = NULL;
20972   __Pyx_RefNannyDeclarations
20973   int __pyx_t_1;
20974   __Pyx_RefNannySetupContext("get_array_base", 0);
20975 
20976   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":936
20977  *
20978  * cdef inline object get_array_base(ndarray arr):
20979  *     base = PyArray_BASE(arr)             # <<<<<<<<<<<<<<
20980  *     if base is NULL:
20981  *         return None
20982  */
20983   __pyx_v_base = PyArray_BASE(__pyx_v_arr);
20984 
20985   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":937
20986  * cdef inline object get_array_base(ndarray arr):
20987  *     base = PyArray_BASE(arr)
20988  *     if base is NULL:             # <<<<<<<<<<<<<<
20989  *         return None
20990  *     return <object>base
20991  */
20992   __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
20993   if (__pyx_t_1) {
20994 
20995     /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":938
20996  *     base = PyArray_BASE(arr)
20997  *     if base is NULL:
20998  *         return None             # <<<<<<<<<<<<<<
20999  *     return <object>base
21000  *
21001  */
21002     __Pyx_XDECREF(__pyx_r);
21003     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21004     goto __pyx_L0;
21005 
21006     /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":937
21007  * cdef inline object get_array_base(ndarray arr):
21008  *     base = PyArray_BASE(arr)
21009  *     if base is NULL:             # <<<<<<<<<<<<<<
21010  *         return None
21011  *     return <object>base
21012  */
21013   }
21014 
21015   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":939
21016  *     if base is NULL:
21017  *         return None
21018  *     return <object>base             # <<<<<<<<<<<<<<
21019  *
21020  * # Versions of the import_* functions which are more suitable for
21021  */
21022   __Pyx_XDECREF(__pyx_r);
21023   __Pyx_INCREF(((PyObject *)__pyx_v_base));
21024   __pyx_r = ((PyObject *)__pyx_v_base);
21025   goto __pyx_L0;
21026 
21027   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":935
21028  *     PyArray_SetBaseObject(arr, base)
21029  *
21030  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
21031  *     base = PyArray_BASE(arr)
21032  *     if base is NULL:
21033  */
21034 
21035   /* function exit code */
21036   __pyx_L0:;
21037   __Pyx_XGIVEREF(__pyx_r);
21038   __Pyx_RefNannyFinishContext();
21039   return __pyx_r;
21040 }
21041 
21042 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":943
21043  * # Versions of the import_* functions which are more suitable for
21044  * # Cython code.
21045  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
21046  *     try:
21047  *         __pyx_import_array()
21048  */
21049 
__pyx_f_5numpy_import_array(void)21050 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
21051   int __pyx_r;
21052   __Pyx_RefNannyDeclarations
21053   PyObject *__pyx_t_1 = NULL;
21054   PyObject *__pyx_t_2 = NULL;
21055   PyObject *__pyx_t_3 = NULL;
21056   int __pyx_t_4;
21057   PyObject *__pyx_t_5 = NULL;
21058   PyObject *__pyx_t_6 = NULL;
21059   PyObject *__pyx_t_7 = NULL;
21060   PyObject *__pyx_t_8 = NULL;
21061   int __pyx_lineno = 0;
21062   const char *__pyx_filename = NULL;
21063   int __pyx_clineno = 0;
21064   __Pyx_RefNannySetupContext("import_array", 0);
21065 
21066   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":944
21067  * # Cython code.
21068  * cdef inline int import_array() except -1:
21069  *     try:             # <<<<<<<<<<<<<<
21070  *         __pyx_import_array()
21071  *     except Exception:
21072  */
21073   {
21074     __Pyx_PyThreadState_declare
21075     __Pyx_PyThreadState_assign
21076     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
21077     __Pyx_XGOTREF(__pyx_t_1);
21078     __Pyx_XGOTREF(__pyx_t_2);
21079     __Pyx_XGOTREF(__pyx_t_3);
21080     /*try:*/ {
21081 
21082       /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":945
21083  * cdef inline int import_array() except -1:
21084  *     try:
21085  *         __pyx_import_array()             # <<<<<<<<<<<<<<
21086  *     except Exception:
21087  *         raise ImportError("numpy.core.multiarray failed to import")
21088  */
21089       __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 945, __pyx_L3_error)
21090 
21091       /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":944
21092  * # Cython code.
21093  * cdef inline int import_array() except -1:
21094  *     try:             # <<<<<<<<<<<<<<
21095  *         __pyx_import_array()
21096  *     except Exception:
21097  */
21098     }
21099     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
21100     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
21101     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
21102     goto __pyx_L8_try_end;
21103     __pyx_L3_error:;
21104 
21105     /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":946
21106  *     try:
21107  *         __pyx_import_array()
21108  *     except Exception:             # <<<<<<<<<<<<<<
21109  *         raise ImportError("numpy.core.multiarray failed to import")
21110  *
21111  */
21112     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
21113     if (__pyx_t_4) {
21114       __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
21115       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 946, __pyx_L5_except_error)
21116       __Pyx_GOTREF(__pyx_t_5);
21117       __Pyx_GOTREF(__pyx_t_6);
21118       __Pyx_GOTREF(__pyx_t_7);
21119 
21120       /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":947
21121  *         __pyx_import_array()
21122  *     except Exception:
21123  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
21124  *
21125  * cdef inline int import_umath() except -1:
21126  */
21127       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 947, __pyx_L5_except_error)
21128       __Pyx_GOTREF(__pyx_t_8);
21129       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
21130       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
21131       __PYX_ERR(1, 947, __pyx_L5_except_error)
21132     }
21133     goto __pyx_L5_except_error;
21134     __pyx_L5_except_error:;
21135 
21136     /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":944
21137  * # Cython code.
21138  * cdef inline int import_array() except -1:
21139  *     try:             # <<<<<<<<<<<<<<
21140  *         __pyx_import_array()
21141  *     except Exception:
21142  */
21143     __Pyx_XGIVEREF(__pyx_t_1);
21144     __Pyx_XGIVEREF(__pyx_t_2);
21145     __Pyx_XGIVEREF(__pyx_t_3);
21146     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
21147     goto __pyx_L1_error;
21148     __pyx_L8_try_end:;
21149   }
21150 
21151   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":943
21152  * # Versions of the import_* functions which are more suitable for
21153  * # Cython code.
21154  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
21155  *     try:
21156  *         __pyx_import_array()
21157  */
21158 
21159   /* function exit code */
21160   __pyx_r = 0;
21161   goto __pyx_L0;
21162   __pyx_L1_error:;
21163   __Pyx_XDECREF(__pyx_t_5);
21164   __Pyx_XDECREF(__pyx_t_6);
21165   __Pyx_XDECREF(__pyx_t_7);
21166   __Pyx_XDECREF(__pyx_t_8);
21167   __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
21168   __pyx_r = -1;
21169   __pyx_L0:;
21170   __Pyx_RefNannyFinishContext();
21171   return __pyx_r;
21172 }
21173 
21174 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":949
21175  *         raise ImportError("numpy.core.multiarray failed to import")
21176  *
21177  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
21178  *     try:
21179  *         _import_umath()
21180  */
21181 
__pyx_f_5numpy_import_umath(void)21182 static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
21183   int __pyx_r;
21184   __Pyx_RefNannyDeclarations
21185   PyObject *__pyx_t_1 = NULL;
21186   PyObject *__pyx_t_2 = NULL;
21187   PyObject *__pyx_t_3 = NULL;
21188   int __pyx_t_4;
21189   PyObject *__pyx_t_5 = NULL;
21190   PyObject *__pyx_t_6 = NULL;
21191   PyObject *__pyx_t_7 = NULL;
21192   PyObject *__pyx_t_8 = NULL;
21193   int __pyx_lineno = 0;
21194   const char *__pyx_filename = NULL;
21195   int __pyx_clineno = 0;
21196   __Pyx_RefNannySetupContext("import_umath", 0);
21197 
21198   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":950
21199  *
21200  * cdef inline int import_umath() except -1:
21201  *     try:             # <<<<<<<<<<<<<<
21202  *         _import_umath()
21203  *     except Exception:
21204  */
21205   {
21206     __Pyx_PyThreadState_declare
21207     __Pyx_PyThreadState_assign
21208     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
21209     __Pyx_XGOTREF(__pyx_t_1);
21210     __Pyx_XGOTREF(__pyx_t_2);
21211     __Pyx_XGOTREF(__pyx_t_3);
21212     /*try:*/ {
21213 
21214       /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":951
21215  * cdef inline int import_umath() except -1:
21216  *     try:
21217  *         _import_umath()             # <<<<<<<<<<<<<<
21218  *     except Exception:
21219  *         raise ImportError("numpy.core.umath failed to import")
21220  */
21221       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 951, __pyx_L3_error)
21222 
21223       /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":950
21224  *
21225  * cdef inline int import_umath() except -1:
21226  *     try:             # <<<<<<<<<<<<<<
21227  *         _import_umath()
21228  *     except Exception:
21229  */
21230     }
21231     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
21232     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
21233     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
21234     goto __pyx_L8_try_end;
21235     __pyx_L3_error:;
21236 
21237     /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":952
21238  *     try:
21239  *         _import_umath()
21240  *     except Exception:             # <<<<<<<<<<<<<<
21241  *         raise ImportError("numpy.core.umath failed to import")
21242  *
21243  */
21244     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
21245     if (__pyx_t_4) {
21246       __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
21247       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 952, __pyx_L5_except_error)
21248       __Pyx_GOTREF(__pyx_t_5);
21249       __Pyx_GOTREF(__pyx_t_6);
21250       __Pyx_GOTREF(__pyx_t_7);
21251 
21252       /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":953
21253  *         _import_umath()
21254  *     except Exception:
21255  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
21256  *
21257  * cdef inline int import_ufunc() except -1:
21258  */
21259       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 953, __pyx_L5_except_error)
21260       __Pyx_GOTREF(__pyx_t_8);
21261       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
21262       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
21263       __PYX_ERR(1, 953, __pyx_L5_except_error)
21264     }
21265     goto __pyx_L5_except_error;
21266     __pyx_L5_except_error:;
21267 
21268     /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":950
21269  *
21270  * cdef inline int import_umath() except -1:
21271  *     try:             # <<<<<<<<<<<<<<
21272  *         _import_umath()
21273  *     except Exception:
21274  */
21275     __Pyx_XGIVEREF(__pyx_t_1);
21276     __Pyx_XGIVEREF(__pyx_t_2);
21277     __Pyx_XGIVEREF(__pyx_t_3);
21278     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
21279     goto __pyx_L1_error;
21280     __pyx_L8_try_end:;
21281   }
21282 
21283   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":949
21284  *         raise ImportError("numpy.core.multiarray failed to import")
21285  *
21286  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
21287  *     try:
21288  *         _import_umath()
21289  */
21290 
21291   /* function exit code */
21292   __pyx_r = 0;
21293   goto __pyx_L0;
21294   __pyx_L1_error:;
21295   __Pyx_XDECREF(__pyx_t_5);
21296   __Pyx_XDECREF(__pyx_t_6);
21297   __Pyx_XDECREF(__pyx_t_7);
21298   __Pyx_XDECREF(__pyx_t_8);
21299   __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
21300   __pyx_r = -1;
21301   __pyx_L0:;
21302   __Pyx_RefNannyFinishContext();
21303   return __pyx_r;
21304 }
21305 
21306 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":955
21307  *         raise ImportError("numpy.core.umath failed to import")
21308  *
21309  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
21310  *     try:
21311  *         _import_umath()
21312  */
21313 
__pyx_f_5numpy_import_ufunc(void)21314 static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
21315   int __pyx_r;
21316   __Pyx_RefNannyDeclarations
21317   PyObject *__pyx_t_1 = NULL;
21318   PyObject *__pyx_t_2 = NULL;
21319   PyObject *__pyx_t_3 = NULL;
21320   int __pyx_t_4;
21321   PyObject *__pyx_t_5 = NULL;
21322   PyObject *__pyx_t_6 = NULL;
21323   PyObject *__pyx_t_7 = NULL;
21324   PyObject *__pyx_t_8 = NULL;
21325   int __pyx_lineno = 0;
21326   const char *__pyx_filename = NULL;
21327   int __pyx_clineno = 0;
21328   __Pyx_RefNannySetupContext("import_ufunc", 0);
21329 
21330   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":956
21331  *
21332  * cdef inline int import_ufunc() except -1:
21333  *     try:             # <<<<<<<<<<<<<<
21334  *         _import_umath()
21335  *     except Exception:
21336  */
21337   {
21338     __Pyx_PyThreadState_declare
21339     __Pyx_PyThreadState_assign
21340     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
21341     __Pyx_XGOTREF(__pyx_t_1);
21342     __Pyx_XGOTREF(__pyx_t_2);
21343     __Pyx_XGOTREF(__pyx_t_3);
21344     /*try:*/ {
21345 
21346       /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":957
21347  * cdef inline int import_ufunc() except -1:
21348  *     try:
21349  *         _import_umath()             # <<<<<<<<<<<<<<
21350  *     except Exception:
21351  *         raise ImportError("numpy.core.umath failed to import")
21352  */
21353       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 957, __pyx_L3_error)
21354 
21355       /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":956
21356  *
21357  * cdef inline int import_ufunc() except -1:
21358  *     try:             # <<<<<<<<<<<<<<
21359  *         _import_umath()
21360  *     except Exception:
21361  */
21362     }
21363     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
21364     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
21365     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
21366     goto __pyx_L8_try_end;
21367     __pyx_L3_error:;
21368 
21369     /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":958
21370  *     try:
21371  *         _import_umath()
21372  *     except Exception:             # <<<<<<<<<<<<<<
21373  *         raise ImportError("numpy.core.umath failed to import")
21374  *
21375  */
21376     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
21377     if (__pyx_t_4) {
21378       __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
21379       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 958, __pyx_L5_except_error)
21380       __Pyx_GOTREF(__pyx_t_5);
21381       __Pyx_GOTREF(__pyx_t_6);
21382       __Pyx_GOTREF(__pyx_t_7);
21383 
21384       /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":959
21385  *         _import_umath()
21386  *     except Exception:
21387  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
21388  *
21389  * cdef extern from *:
21390  */
21391       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 959, __pyx_L5_except_error)
21392       __Pyx_GOTREF(__pyx_t_8);
21393       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
21394       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
21395       __PYX_ERR(1, 959, __pyx_L5_except_error)
21396     }
21397     goto __pyx_L5_except_error;
21398     __pyx_L5_except_error:;
21399 
21400     /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":956
21401  *
21402  * cdef inline int import_ufunc() except -1:
21403  *     try:             # <<<<<<<<<<<<<<
21404  *         _import_umath()
21405  *     except Exception:
21406  */
21407     __Pyx_XGIVEREF(__pyx_t_1);
21408     __Pyx_XGIVEREF(__pyx_t_2);
21409     __Pyx_XGIVEREF(__pyx_t_3);
21410     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
21411     goto __pyx_L1_error;
21412     __pyx_L8_try_end:;
21413   }
21414 
21415   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":955
21416  *         raise ImportError("numpy.core.umath failed to import")
21417  *
21418  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
21419  *     try:
21420  *         _import_umath()
21421  */
21422 
21423   /* function exit code */
21424   __pyx_r = 0;
21425   goto __pyx_L0;
21426   __pyx_L1_error:;
21427   __Pyx_XDECREF(__pyx_t_5);
21428   __Pyx_XDECREF(__pyx_t_6);
21429   __Pyx_XDECREF(__pyx_t_7);
21430   __Pyx_XDECREF(__pyx_t_8);
21431   __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
21432   __pyx_r = -1;
21433   __pyx_L0:;
21434   __Pyx_RefNannyFinishContext();
21435   return __pyx_r;
21436 }
21437 
21438 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":969
21439  *
21440  *
21441  * cdef inline bint is_timedelta64_object(object obj):             # <<<<<<<<<<<<<<
21442  *     """
21443  *     Cython equivalent of `isinstance(obj, np.timedelta64)`
21444  */
21445 
__pyx_f_5numpy_is_timedelta64_object(PyObject * __pyx_v_obj)21446 static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_obj) {
21447   int __pyx_r;
21448   __Pyx_RefNannyDeclarations
21449   __Pyx_RefNannySetupContext("is_timedelta64_object", 0);
21450 
21451   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":981
21452  *     bool
21453  *     """
21454  *     return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type)             # <<<<<<<<<<<<<<
21455  *
21456  *
21457  */
21458   __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyTimedeltaArrType_Type));
21459   goto __pyx_L0;
21460 
21461   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":969
21462  *
21463  *
21464  * cdef inline bint is_timedelta64_object(object obj):             # <<<<<<<<<<<<<<
21465  *     """
21466  *     Cython equivalent of `isinstance(obj, np.timedelta64)`
21467  */
21468 
21469   /* function exit code */
21470   __pyx_L0:;
21471   __Pyx_RefNannyFinishContext();
21472   return __pyx_r;
21473 }
21474 
21475 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":984
21476  *
21477  *
21478  * cdef inline bint is_datetime64_object(object obj):             # <<<<<<<<<<<<<<
21479  *     """
21480  *     Cython equivalent of `isinstance(obj, np.datetime64)`
21481  */
21482 
__pyx_f_5numpy_is_datetime64_object(PyObject * __pyx_v_obj)21483 static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_obj) {
21484   int __pyx_r;
21485   __Pyx_RefNannyDeclarations
21486   __Pyx_RefNannySetupContext("is_datetime64_object", 0);
21487 
21488   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":996
21489  *     bool
21490  *     """
21491  *     return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type)             # <<<<<<<<<<<<<<
21492  *
21493  *
21494  */
21495   __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyDatetimeArrType_Type));
21496   goto __pyx_L0;
21497 
21498   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":984
21499  *
21500  *
21501  * cdef inline bint is_datetime64_object(object obj):             # <<<<<<<<<<<<<<
21502  *     """
21503  *     Cython equivalent of `isinstance(obj, np.datetime64)`
21504  */
21505 
21506   /* function exit code */
21507   __pyx_L0:;
21508   __Pyx_RefNannyFinishContext();
21509   return __pyx_r;
21510 }
21511 
21512 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":999
21513  *
21514  *
21515  * cdef inline npy_datetime get_datetime64_value(object obj) nogil:             # <<<<<<<<<<<<<<
21516  *     """
21517  *     returns the int64 value underlying scalar numpy datetime64 object
21518  */
21519 
__pyx_f_5numpy_get_datetime64_value(PyObject * __pyx_v_obj)21520 static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject *__pyx_v_obj) {
21521   npy_datetime __pyx_r;
21522 
21523   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":1006
21524  *     also needed.  That can be found using `get_datetime64_unit`.
21525  *     """
21526  *     return (<PyDatetimeScalarObject*>obj).obval             # <<<<<<<<<<<<<<
21527  *
21528  *
21529  */
21530   __pyx_r = ((PyDatetimeScalarObject *)__pyx_v_obj)->obval;
21531   goto __pyx_L0;
21532 
21533   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":999
21534  *
21535  *
21536  * cdef inline npy_datetime get_datetime64_value(object obj) nogil:             # <<<<<<<<<<<<<<
21537  *     """
21538  *     returns the int64 value underlying scalar numpy datetime64 object
21539  */
21540 
21541   /* function exit code */
21542   __pyx_L0:;
21543   return __pyx_r;
21544 }
21545 
21546 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":1009
21547  *
21548  *
21549  * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil:             # <<<<<<<<<<<<<<
21550  *     """
21551  *     returns the int64 value underlying scalar numpy timedelta64 object
21552  */
21553 
__pyx_f_5numpy_get_timedelta64_value(PyObject * __pyx_v_obj)21554 static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject *__pyx_v_obj) {
21555   npy_timedelta __pyx_r;
21556 
21557   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":1013
21558  *     returns the int64 value underlying scalar numpy timedelta64 object
21559  *     """
21560  *     return (<PyTimedeltaScalarObject*>obj).obval             # <<<<<<<<<<<<<<
21561  *
21562  *
21563  */
21564   __pyx_r = ((PyTimedeltaScalarObject *)__pyx_v_obj)->obval;
21565   goto __pyx_L0;
21566 
21567   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":1009
21568  *
21569  *
21570  * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil:             # <<<<<<<<<<<<<<
21571  *     """
21572  *     returns the int64 value underlying scalar numpy timedelta64 object
21573  */
21574 
21575   /* function exit code */
21576   __pyx_L0:;
21577   return __pyx_r;
21578 }
21579 
21580 /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":1016
21581  *
21582  *
21583  * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:             # <<<<<<<<<<<<<<
21584  *     """
21585  *     returns the unit part of the dtype for a numpy datetime64 object.
21586  */
21587 
__pyx_f_5numpy_get_datetime64_unit(PyObject * __pyx_v_obj)21588 static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObject *__pyx_v_obj) {
21589   NPY_DATETIMEUNIT __pyx_r;
21590 
21591   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":1020
21592  *     returns the unit part of the dtype for a numpy datetime64 object.
21593  *     """
21594  *     return <NPY_DATETIMEUNIT>(<PyDatetimeScalarObject*>obj).obmeta.base             # <<<<<<<<<<<<<<
21595  */
21596   __pyx_r = ((NPY_DATETIMEUNIT)((PyDatetimeScalarObject *)__pyx_v_obj)->obmeta.base);
21597   goto __pyx_L0;
21598 
21599   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":1016
21600  *
21601  *
21602  * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:             # <<<<<<<<<<<<<<
21603  *     """
21604  *     returns the unit part of the dtype for a numpy datetime64 object.
21605  */
21606 
21607   /* function exit code */
21608   __pyx_L0:;
21609   return __pyx_r;
21610 }
21611 
21612 /* "View.MemoryView":122
21613  *         cdef bint dtype_is_object
21614  *
21615  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
21616  *                   mode="c", bint allocate_buffer=True):
21617  *
21618  */
21619 
21620 /* Python wrapper */
21621 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)21622 static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
21623   PyObject *__pyx_v_shape = 0;
21624   Py_ssize_t __pyx_v_itemsize;
21625   PyObject *__pyx_v_format = 0;
21626   PyObject *__pyx_v_mode = 0;
21627   int __pyx_v_allocate_buffer;
21628   int __pyx_lineno = 0;
21629   const char *__pyx_filename = NULL;
21630   int __pyx_clineno = 0;
21631   int __pyx_r;
21632   __Pyx_RefNannyDeclarations
21633   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
21634   {
21635     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};
21636     PyObject* values[5] = {0,0,0,0,0};
21637     values[3] = ((PyObject *)__pyx_n_s_c);
21638     if (unlikely(__pyx_kwds)) {
21639       Py_ssize_t kw_args;
21640       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
21641       switch (pos_args) {
21642         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
21643         CYTHON_FALLTHROUGH;
21644         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
21645         CYTHON_FALLTHROUGH;
21646         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
21647         CYTHON_FALLTHROUGH;
21648         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
21649         CYTHON_FALLTHROUGH;
21650         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
21651         CYTHON_FALLTHROUGH;
21652         case  0: break;
21653         default: goto __pyx_L5_argtuple_error;
21654       }
21655       kw_args = PyDict_Size(__pyx_kwds);
21656       switch (pos_args) {
21657         case  0:
21658         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
21659         else goto __pyx_L5_argtuple_error;
21660         CYTHON_FALLTHROUGH;
21661         case  1:
21662         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
21663         else {
21664           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(2, 122, __pyx_L3_error)
21665         }
21666         CYTHON_FALLTHROUGH;
21667         case  2:
21668         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
21669         else {
21670           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(2, 122, __pyx_L3_error)
21671         }
21672         CYTHON_FALLTHROUGH;
21673         case  3:
21674         if (kw_args > 0) {
21675           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
21676           if (value) { values[3] = value; kw_args--; }
21677         }
21678         CYTHON_FALLTHROUGH;
21679         case  4:
21680         if (kw_args > 0) {
21681           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allocate_buffer);
21682           if (value) { values[4] = value; kw_args--; }
21683         }
21684       }
21685       if (unlikely(kw_args > 0)) {
21686         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 122, __pyx_L3_error)
21687       }
21688     } else {
21689       switch (PyTuple_GET_SIZE(__pyx_args)) {
21690         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
21691         CYTHON_FALLTHROUGH;
21692         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
21693         CYTHON_FALLTHROUGH;
21694         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
21695         values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
21696         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
21697         break;
21698         default: goto __pyx_L5_argtuple_error;
21699       }
21700     }
21701     __pyx_v_shape = ((PyObject*)values[0]);
21702     __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)
21703     __pyx_v_format = values[2];
21704     __pyx_v_mode = values[3];
21705     if (values[4]) {
21706       __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)
21707     } else {
21708 
21709       /* "View.MemoryView":123
21710  *
21711  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,
21712  *                   mode="c", bint allocate_buffer=True):             # <<<<<<<<<<<<<<
21713  *
21714  *         cdef int idx
21715  */
21716       __pyx_v_allocate_buffer = ((int)1);
21717     }
21718   }
21719   goto __pyx_L4_argument_unpacking_done;
21720   __pyx_L5_argtuple_error:;
21721   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 122, __pyx_L3_error)
21722   __pyx_L3_error:;
21723   __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
21724   __Pyx_RefNannyFinishContext();
21725   return -1;
21726   __pyx_L4_argument_unpacking_done:;
21727   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(2, 122, __pyx_L1_error)
21728   if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
21729     PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(2, 122, __pyx_L1_error)
21730   }
21731   __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);
21732 
21733   /* "View.MemoryView":122
21734  *         cdef bint dtype_is_object
21735  *
21736  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
21737  *                   mode="c", bint allocate_buffer=True):
21738  *
21739  */
21740 
21741   /* function exit code */
21742   goto __pyx_L0;
21743   __pyx_L1_error:;
21744   __pyx_r = -1;
21745   __pyx_L0:;
21746   __Pyx_RefNannyFinishContext();
21747   return __pyx_r;
21748 }
21749 
__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)21750 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) {
21751   int __pyx_v_idx;
21752   Py_ssize_t __pyx_v_i;
21753   Py_ssize_t __pyx_v_dim;
21754   PyObject **__pyx_v_p;
21755   char __pyx_v_order;
21756   int __pyx_r;
21757   __Pyx_RefNannyDeclarations
21758   Py_ssize_t __pyx_t_1;
21759   int __pyx_t_2;
21760   PyObject *__pyx_t_3 = NULL;
21761   int __pyx_t_4;
21762   PyObject *__pyx_t_5 = NULL;
21763   PyObject *__pyx_t_6 = NULL;
21764   char *__pyx_t_7;
21765   int __pyx_t_8;
21766   Py_ssize_t __pyx_t_9;
21767   PyObject *__pyx_t_10 = NULL;
21768   Py_ssize_t __pyx_t_11;
21769   int __pyx_lineno = 0;
21770   const char *__pyx_filename = NULL;
21771   int __pyx_clineno = 0;
21772   __Pyx_RefNannySetupContext("__cinit__", 0);
21773   __Pyx_INCREF(__pyx_v_format);
21774 
21775   /* "View.MemoryView":129
21776  *         cdef PyObject **p
21777  *
21778  *         self.ndim = <int> len(shape)             # <<<<<<<<<<<<<<
21779  *         self.itemsize = itemsize
21780  *
21781  */
21782   if (unlikely(__pyx_v_shape == Py_None)) {
21783     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
21784     __PYX_ERR(2, 129, __pyx_L1_error)
21785   }
21786   __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)
21787   __pyx_v_self->ndim = ((int)__pyx_t_1);
21788 
21789   /* "View.MemoryView":130
21790  *
21791  *         self.ndim = <int> len(shape)
21792  *         self.itemsize = itemsize             # <<<<<<<<<<<<<<
21793  *
21794  *         if not self.ndim:
21795  */
21796   __pyx_v_self->itemsize = __pyx_v_itemsize;
21797 
21798   /* "View.MemoryView":132
21799  *         self.itemsize = itemsize
21800  *
21801  *         if not self.ndim:             # <<<<<<<<<<<<<<
21802  *             raise ValueError("Empty shape tuple for cython.array")
21803  *
21804  */
21805   __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0);
21806   if (unlikely(__pyx_t_2)) {
21807 
21808     /* "View.MemoryView":133
21809  *
21810  *         if not self.ndim:
21811  *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
21812  *
21813  *         if itemsize <= 0:
21814  */
21815     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 133, __pyx_L1_error)
21816     __Pyx_GOTREF(__pyx_t_3);
21817     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
21818     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
21819     __PYX_ERR(2, 133, __pyx_L1_error)
21820 
21821     /* "View.MemoryView":132
21822  *         self.itemsize = itemsize
21823  *
21824  *         if not self.ndim:             # <<<<<<<<<<<<<<
21825  *             raise ValueError("Empty shape tuple for cython.array")
21826  *
21827  */
21828   }
21829 
21830   /* "View.MemoryView":135
21831  *             raise ValueError("Empty shape tuple for cython.array")
21832  *
21833  *         if itemsize <= 0:             # <<<<<<<<<<<<<<
21834  *             raise ValueError("itemsize <= 0 for cython.array")
21835  *
21836  */
21837   __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0);
21838   if (unlikely(__pyx_t_2)) {
21839 
21840     /* "View.MemoryView":136
21841  *
21842  *         if itemsize <= 0:
21843  *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
21844  *
21845  *         if not isinstance(format, bytes):
21846  */
21847     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 136, __pyx_L1_error)
21848     __Pyx_GOTREF(__pyx_t_3);
21849     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
21850     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
21851     __PYX_ERR(2, 136, __pyx_L1_error)
21852 
21853     /* "View.MemoryView":135
21854  *             raise ValueError("Empty shape tuple for cython.array")
21855  *
21856  *         if itemsize <= 0:             # <<<<<<<<<<<<<<
21857  *             raise ValueError("itemsize <= 0 for cython.array")
21858  *
21859  */
21860   }
21861 
21862   /* "View.MemoryView":138
21863  *             raise ValueError("itemsize <= 0 for cython.array")
21864  *
21865  *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
21866  *             format = format.encode('ASCII')
21867  *         self._format = format  # keep a reference to the byte string
21868  */
21869   __pyx_t_2 = PyBytes_Check(__pyx_v_format);
21870   __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0);
21871   if (__pyx_t_4) {
21872 
21873     /* "View.MemoryView":139
21874  *
21875  *         if not isinstance(format, bytes):
21876  *             format = format.encode('ASCII')             # <<<<<<<<<<<<<<
21877  *         self._format = format  # keep a reference to the byte string
21878  *         self.format = self._format
21879  */
21880     __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)
21881     __Pyx_GOTREF(__pyx_t_5);
21882     __pyx_t_6 = NULL;
21883     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
21884       __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
21885       if (likely(__pyx_t_6)) {
21886         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
21887         __Pyx_INCREF(__pyx_t_6);
21888         __Pyx_INCREF(function);
21889         __Pyx_DECREF_SET(__pyx_t_5, function);
21890       }
21891     }
21892     __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);
21893     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
21894     if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 139, __pyx_L1_error)
21895     __Pyx_GOTREF(__pyx_t_3);
21896     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
21897     __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_3);
21898     __pyx_t_3 = 0;
21899 
21900     /* "View.MemoryView":138
21901  *             raise ValueError("itemsize <= 0 for cython.array")
21902  *
21903  *         if not isinstance(format, bytes):             # <<<<<<<<<<<<<<
21904  *             format = format.encode('ASCII')
21905  *         self._format = format  # keep a reference to the byte string
21906  */
21907   }
21908 
21909   /* "View.MemoryView":140
21910  *         if not isinstance(format, bytes):
21911  *             format = format.encode('ASCII')
21912  *         self._format = format  # keep a reference to the byte string             # <<<<<<<<<<<<<<
21913  *         self.format = self._format
21914  *
21915  */
21916   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)
21917   __pyx_t_3 = __pyx_v_format;
21918   __Pyx_INCREF(__pyx_t_3);
21919   __Pyx_GIVEREF(__pyx_t_3);
21920   __Pyx_GOTREF(__pyx_v_self->_format);
21921   __Pyx_DECREF(__pyx_v_self->_format);
21922   __pyx_v_self->_format = ((PyObject*)__pyx_t_3);
21923   __pyx_t_3 = 0;
21924 
21925   /* "View.MemoryView":141
21926  *             format = format.encode('ASCII')
21927  *         self._format = format  # keep a reference to the byte string
21928  *         self.format = self._format             # <<<<<<<<<<<<<<
21929  *
21930  *
21931  */
21932   if (unlikely(__pyx_v_self->_format == Py_None)) {
21933     PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
21934     __PYX_ERR(2, 141, __pyx_L1_error)
21935   }
21936   __pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(2, 141, __pyx_L1_error)
21937   __pyx_v_self->format = __pyx_t_7;
21938 
21939   /* "View.MemoryView":144
21940  *
21941  *
21942  *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)             # <<<<<<<<<<<<<<
21943  *         self._strides = self._shape + self.ndim
21944  *
21945  */
21946   __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));
21947 
21948   /* "View.MemoryView":145
21949  *
21950  *         self._shape = <Py_ssize_t *> PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)
21951  *         self._strides = self._shape + self.ndim             # <<<<<<<<<<<<<<
21952  *
21953  *         if not self._shape:
21954  */
21955   __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim);
21956 
21957   /* "View.MemoryView":147
21958  *         self._strides = self._shape + self.ndim
21959  *
21960  *         if not self._shape:             # <<<<<<<<<<<<<<
21961  *             raise MemoryError("unable to allocate shape and strides.")
21962  *
21963  */
21964   __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0);
21965   if (unlikely(__pyx_t_4)) {
21966 
21967     /* "View.MemoryView":148
21968  *
21969  *         if not self._shape:
21970  *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
21971  *
21972  *
21973  */
21974     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 148, __pyx_L1_error)
21975     __Pyx_GOTREF(__pyx_t_3);
21976     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
21977     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
21978     __PYX_ERR(2, 148, __pyx_L1_error)
21979 
21980     /* "View.MemoryView":147
21981  *         self._strides = self._shape + self.ndim
21982  *
21983  *         if not self._shape:             # <<<<<<<<<<<<<<
21984  *             raise MemoryError("unable to allocate shape and strides.")
21985  *
21986  */
21987   }
21988 
21989   /* "View.MemoryView":151
21990  *
21991  *
21992  *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
21993  *             if dim <= 0:
21994  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
21995  */
21996   __pyx_t_8 = 0;
21997   __pyx_t_3 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
21998   for (;;) {
21999     if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
22000     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
22001     __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)
22002     #else
22003     __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)
22004     __Pyx_GOTREF(__pyx_t_5);
22005     #endif
22006     __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)
22007     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
22008     __pyx_v_dim = __pyx_t_9;
22009     __pyx_v_idx = __pyx_t_8;
22010     __pyx_t_8 = (__pyx_t_8 + 1);
22011 
22012     /* "View.MemoryView":152
22013  *
22014  *         for idx, dim in enumerate(shape):
22015  *             if dim <= 0:             # <<<<<<<<<<<<<<
22016  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
22017  *             self._shape[idx] = dim
22018  */
22019     __pyx_t_4 = ((__pyx_v_dim <= 0) != 0);
22020     if (unlikely(__pyx_t_4)) {
22021 
22022       /* "View.MemoryView":153
22023  *         for idx, dim in enumerate(shape):
22024  *             if dim <= 0:
22025  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))             # <<<<<<<<<<<<<<
22026  *             self._shape[idx] = dim
22027  *
22028  */
22029       __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 153, __pyx_L1_error)
22030       __Pyx_GOTREF(__pyx_t_5);
22031       __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 153, __pyx_L1_error)
22032       __Pyx_GOTREF(__pyx_t_6);
22033       __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 153, __pyx_L1_error)
22034       __Pyx_GOTREF(__pyx_t_10);
22035       __Pyx_GIVEREF(__pyx_t_5);
22036       PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
22037       __Pyx_GIVEREF(__pyx_t_6);
22038       PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6);
22039       __pyx_t_5 = 0;
22040       __pyx_t_6 = 0;
22041       __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)
22042       __Pyx_GOTREF(__pyx_t_6);
22043       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
22044       __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 153, __pyx_L1_error)
22045       __Pyx_GOTREF(__pyx_t_10);
22046       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
22047       __Pyx_Raise(__pyx_t_10, 0, 0, 0);
22048       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
22049       __PYX_ERR(2, 153, __pyx_L1_error)
22050 
22051       /* "View.MemoryView":152
22052  *
22053  *         for idx, dim in enumerate(shape):
22054  *             if dim <= 0:             # <<<<<<<<<<<<<<
22055  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
22056  *             self._shape[idx] = dim
22057  */
22058     }
22059 
22060     /* "View.MemoryView":154
22061  *             if dim <= 0:
22062  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
22063  *             self._shape[idx] = dim             # <<<<<<<<<<<<<<
22064  *
22065  *         cdef char order
22066  */
22067     (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim;
22068 
22069     /* "View.MemoryView":151
22070  *
22071  *
22072  *         for idx, dim in enumerate(shape):             # <<<<<<<<<<<<<<
22073  *             if dim <= 0:
22074  *                 raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
22075  */
22076   }
22077   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22078 
22079   /* "View.MemoryView":157
22080  *
22081  *         cdef char order
22082  *         if mode == 'fortran':             # <<<<<<<<<<<<<<
22083  *             order = b'F'
22084  *             self.mode = u'fortran'
22085  */
22086   __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)
22087   if (__pyx_t_4) {
22088 
22089     /* "View.MemoryView":158
22090  *         cdef char order
22091  *         if mode == 'fortran':
22092  *             order = b'F'             # <<<<<<<<<<<<<<
22093  *             self.mode = u'fortran'
22094  *         elif mode == 'c':
22095  */
22096     __pyx_v_order = 'F';
22097 
22098     /* "View.MemoryView":159
22099  *         if mode == 'fortran':
22100  *             order = b'F'
22101  *             self.mode = u'fortran'             # <<<<<<<<<<<<<<
22102  *         elif mode == 'c':
22103  *             order = b'C'
22104  */
22105     __Pyx_INCREF(__pyx_n_u_fortran);
22106     __Pyx_GIVEREF(__pyx_n_u_fortran);
22107     __Pyx_GOTREF(__pyx_v_self->mode);
22108     __Pyx_DECREF(__pyx_v_self->mode);
22109     __pyx_v_self->mode = __pyx_n_u_fortran;
22110 
22111     /* "View.MemoryView":157
22112  *
22113  *         cdef char order
22114  *         if mode == 'fortran':             # <<<<<<<<<<<<<<
22115  *             order = b'F'
22116  *             self.mode = u'fortran'
22117  */
22118     goto __pyx_L10;
22119   }
22120 
22121   /* "View.MemoryView":160
22122  *             order = b'F'
22123  *             self.mode = u'fortran'
22124  *         elif mode == 'c':             # <<<<<<<<<<<<<<
22125  *             order = b'C'
22126  *             self.mode = u'c'
22127  */
22128   __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)
22129   if (likely(__pyx_t_4)) {
22130 
22131     /* "View.MemoryView":161
22132  *             self.mode = u'fortran'
22133  *         elif mode == 'c':
22134  *             order = b'C'             # <<<<<<<<<<<<<<
22135  *             self.mode = u'c'
22136  *         else:
22137  */
22138     __pyx_v_order = 'C';
22139 
22140     /* "View.MemoryView":162
22141  *         elif mode == 'c':
22142  *             order = b'C'
22143  *             self.mode = u'c'             # <<<<<<<<<<<<<<
22144  *         else:
22145  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
22146  */
22147     __Pyx_INCREF(__pyx_n_u_c);
22148     __Pyx_GIVEREF(__pyx_n_u_c);
22149     __Pyx_GOTREF(__pyx_v_self->mode);
22150     __Pyx_DECREF(__pyx_v_self->mode);
22151     __pyx_v_self->mode = __pyx_n_u_c;
22152 
22153     /* "View.MemoryView":160
22154  *             order = b'F'
22155  *             self.mode = u'fortran'
22156  *         elif mode == 'c':             # <<<<<<<<<<<<<<
22157  *             order = b'C'
22158  *             self.mode = u'c'
22159  */
22160     goto __pyx_L10;
22161   }
22162 
22163   /* "View.MemoryView":164
22164  *             self.mode = u'c'
22165  *         else:
22166  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)             # <<<<<<<<<<<<<<
22167  *
22168  *         self.len = fill_contig_strides_array(self._shape, self._strides,
22169  */
22170   /*else*/ {
22171     __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)
22172     __Pyx_GOTREF(__pyx_t_3);
22173     __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 164, __pyx_L1_error)
22174     __Pyx_GOTREF(__pyx_t_10);
22175     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22176     __Pyx_Raise(__pyx_t_10, 0, 0, 0);
22177     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
22178     __PYX_ERR(2, 164, __pyx_L1_error)
22179   }
22180   __pyx_L10:;
22181 
22182   /* "View.MemoryView":166
22183  *             raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
22184  *
22185  *         self.len = fill_contig_strides_array(self._shape, self._strides,             # <<<<<<<<<<<<<<
22186  *                                              itemsize, self.ndim, order)
22187  *
22188  */
22189   __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);
22190 
22191   /* "View.MemoryView":169
22192  *                                              itemsize, self.ndim, order)
22193  *
22194  *         self.free_data = allocate_buffer             # <<<<<<<<<<<<<<
22195  *         self.dtype_is_object = format == b'O'
22196  *         if allocate_buffer:
22197  */
22198   __pyx_v_self->free_data = __pyx_v_allocate_buffer;
22199 
22200   /* "View.MemoryView":170
22201  *
22202  *         self.free_data = allocate_buffer
22203  *         self.dtype_is_object = format == b'O'             # <<<<<<<<<<<<<<
22204  *         if allocate_buffer:
22205  *
22206  */
22207   __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)
22208   __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)
22209   __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
22210   __pyx_v_self->dtype_is_object = __pyx_t_4;
22211 
22212   /* "View.MemoryView":171
22213  *         self.free_data = allocate_buffer
22214  *         self.dtype_is_object = format == b'O'
22215  *         if allocate_buffer:             # <<<<<<<<<<<<<<
22216  *
22217  *
22218  */
22219   __pyx_t_4 = (__pyx_v_allocate_buffer != 0);
22220   if (__pyx_t_4) {
22221 
22222     /* "View.MemoryView":174
22223  *
22224  *
22225  *             self.data = <char *>malloc(self.len)             # <<<<<<<<<<<<<<
22226  *             if not self.data:
22227  *                 raise MemoryError("unable to allocate array data.")
22228  */
22229     __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len));
22230 
22231     /* "View.MemoryView":175
22232  *
22233  *             self.data = <char *>malloc(self.len)
22234  *             if not self.data:             # <<<<<<<<<<<<<<
22235  *                 raise MemoryError("unable to allocate array data.")
22236  *
22237  */
22238     __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0);
22239     if (unlikely(__pyx_t_4)) {
22240 
22241       /* "View.MemoryView":176
22242  *             self.data = <char *>malloc(self.len)
22243  *             if not self.data:
22244  *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
22245  *
22246  *             if self.dtype_is_object:
22247  */
22248       __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 176, __pyx_L1_error)
22249       __Pyx_GOTREF(__pyx_t_10);
22250       __Pyx_Raise(__pyx_t_10, 0, 0, 0);
22251       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
22252       __PYX_ERR(2, 176, __pyx_L1_error)
22253 
22254       /* "View.MemoryView":175
22255  *
22256  *             self.data = <char *>malloc(self.len)
22257  *             if not self.data:             # <<<<<<<<<<<<<<
22258  *                 raise MemoryError("unable to allocate array data.")
22259  *
22260  */
22261     }
22262 
22263     /* "View.MemoryView":178
22264  *                 raise MemoryError("unable to allocate array data.")
22265  *
22266  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
22267  *                 p = <PyObject **> self.data
22268  *                 for i in range(self.len / itemsize):
22269  */
22270     __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0);
22271     if (__pyx_t_4) {
22272 
22273       /* "View.MemoryView":179
22274  *
22275  *             if self.dtype_is_object:
22276  *                 p = <PyObject **> self.data             # <<<<<<<<<<<<<<
22277  *                 for i in range(self.len / itemsize):
22278  *                     p[i] = Py_None
22279  */
22280       __pyx_v_p = ((PyObject **)__pyx_v_self->data);
22281 
22282       /* "View.MemoryView":180
22283  *             if self.dtype_is_object:
22284  *                 p = <PyObject **> self.data
22285  *                 for i in range(self.len / itemsize):             # <<<<<<<<<<<<<<
22286  *                     p[i] = Py_None
22287  *                     Py_INCREF(Py_None)
22288  */
22289       if (unlikely(__pyx_v_itemsize == 0)) {
22290         PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
22291         __PYX_ERR(2, 180, __pyx_L1_error)
22292       }
22293       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))) {
22294         PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
22295         __PYX_ERR(2, 180, __pyx_L1_error)
22296       }
22297       __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
22298       __pyx_t_9 = __pyx_t_1;
22299       for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_9; __pyx_t_11+=1) {
22300         __pyx_v_i = __pyx_t_11;
22301 
22302         /* "View.MemoryView":181
22303  *                 p = <PyObject **> self.data
22304  *                 for i in range(self.len / itemsize):
22305  *                     p[i] = Py_None             # <<<<<<<<<<<<<<
22306  *                     Py_INCREF(Py_None)
22307  *
22308  */
22309         (__pyx_v_p[__pyx_v_i]) = Py_None;
22310 
22311         /* "View.MemoryView":182
22312  *                 for i in range(self.len / itemsize):
22313  *                     p[i] = Py_None
22314  *                     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
22315  *
22316  *     @cname('getbuffer')
22317  */
22318         Py_INCREF(Py_None);
22319       }
22320 
22321       /* "View.MemoryView":178
22322  *                 raise MemoryError("unable to allocate array data.")
22323  *
22324  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
22325  *                 p = <PyObject **> self.data
22326  *                 for i in range(self.len / itemsize):
22327  */
22328     }
22329 
22330     /* "View.MemoryView":171
22331  *         self.free_data = allocate_buffer
22332  *         self.dtype_is_object = format == b'O'
22333  *         if allocate_buffer:             # <<<<<<<<<<<<<<
22334  *
22335  *
22336  */
22337   }
22338 
22339   /* "View.MemoryView":122
22340  *         cdef bint dtype_is_object
22341  *
22342  *     def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,             # <<<<<<<<<<<<<<
22343  *                   mode="c", bint allocate_buffer=True):
22344  *
22345  */
22346 
22347   /* function exit code */
22348   __pyx_r = 0;
22349   goto __pyx_L0;
22350   __pyx_L1_error:;
22351   __Pyx_XDECREF(__pyx_t_3);
22352   __Pyx_XDECREF(__pyx_t_5);
22353   __Pyx_XDECREF(__pyx_t_6);
22354   __Pyx_XDECREF(__pyx_t_10);
22355   __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
22356   __pyx_r = -1;
22357   __pyx_L0:;
22358   __Pyx_XDECREF(__pyx_v_format);
22359   __Pyx_RefNannyFinishContext();
22360   return __pyx_r;
22361 }
22362 
22363 /* "View.MemoryView":185
22364  *
22365  *     @cname('getbuffer')
22366  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
22367  *         cdef int bufmode = -1
22368  *         if self.mode == u"c":
22369  */
22370 
22371 /* Python wrapper */
22372 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)22373 static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
22374   int __pyx_r;
22375   __Pyx_RefNannyDeclarations
22376   __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
22377   __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));
22378 
22379   /* function exit code */
22380   __Pyx_RefNannyFinishContext();
22381   return __pyx_r;
22382 }
22383 
__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)22384 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) {
22385   int __pyx_v_bufmode;
22386   int __pyx_r;
22387   __Pyx_RefNannyDeclarations
22388   int __pyx_t_1;
22389   int __pyx_t_2;
22390   PyObject *__pyx_t_3 = NULL;
22391   char *__pyx_t_4;
22392   Py_ssize_t __pyx_t_5;
22393   int __pyx_t_6;
22394   Py_ssize_t *__pyx_t_7;
22395   int __pyx_lineno = 0;
22396   const char *__pyx_filename = NULL;
22397   int __pyx_clineno = 0;
22398   if (__pyx_v_info == NULL) {
22399     PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
22400     return -1;
22401   }
22402   __Pyx_RefNannySetupContext("__getbuffer__", 0);
22403   __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
22404   __Pyx_GIVEREF(__pyx_v_info->obj);
22405 
22406   /* "View.MemoryView":186
22407  *     @cname('getbuffer')
22408  *     def __getbuffer__(self, Py_buffer *info, int flags):
22409  *         cdef int bufmode = -1             # <<<<<<<<<<<<<<
22410  *         if self.mode == u"c":
22411  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22412  */
22413   __pyx_v_bufmode = -1;
22414 
22415   /* "View.MemoryView":187
22416  *     def __getbuffer__(self, Py_buffer *info, int flags):
22417  *         cdef int bufmode = -1
22418  *         if self.mode == u"c":             # <<<<<<<<<<<<<<
22419  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22420  *         elif self.mode == u"fortran":
22421  */
22422   __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)
22423   __pyx_t_2 = (__pyx_t_1 != 0);
22424   if (__pyx_t_2) {
22425 
22426     /* "View.MemoryView":188
22427  *         cdef int bufmode = -1
22428  *         if self.mode == u"c":
22429  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
22430  *         elif self.mode == u"fortran":
22431  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22432  */
22433     __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
22434 
22435     /* "View.MemoryView":187
22436  *     def __getbuffer__(self, Py_buffer *info, int flags):
22437  *         cdef int bufmode = -1
22438  *         if self.mode == u"c":             # <<<<<<<<<<<<<<
22439  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22440  *         elif self.mode == u"fortran":
22441  */
22442     goto __pyx_L3;
22443   }
22444 
22445   /* "View.MemoryView":189
22446  *         if self.mode == u"c":
22447  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22448  *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
22449  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22450  *         if not (flags & bufmode):
22451  */
22452   __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)
22453   __pyx_t_1 = (__pyx_t_2 != 0);
22454   if (__pyx_t_1) {
22455 
22456     /* "View.MemoryView":190
22457  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22458  *         elif self.mode == u"fortran":
22459  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
22460  *         if not (flags & bufmode):
22461  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
22462  */
22463     __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
22464 
22465     /* "View.MemoryView":189
22466  *         if self.mode == u"c":
22467  *             bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22468  *         elif self.mode == u"fortran":             # <<<<<<<<<<<<<<
22469  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22470  *         if not (flags & bufmode):
22471  */
22472   }
22473   __pyx_L3:;
22474 
22475   /* "View.MemoryView":191
22476  *         elif self.mode == u"fortran":
22477  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22478  *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
22479  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
22480  *         info.buf = self.data
22481  */
22482   __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0);
22483   if (unlikely(__pyx_t_1)) {
22484 
22485     /* "View.MemoryView":192
22486  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22487  *         if not (flags & bufmode):
22488  *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
22489  *         info.buf = self.data
22490  *         info.len = self.len
22491  */
22492     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 192, __pyx_L1_error)
22493     __Pyx_GOTREF(__pyx_t_3);
22494     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
22495     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22496     __PYX_ERR(2, 192, __pyx_L1_error)
22497 
22498     /* "View.MemoryView":191
22499  *         elif self.mode == u"fortran":
22500  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
22501  *         if not (flags & bufmode):             # <<<<<<<<<<<<<<
22502  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
22503  *         info.buf = self.data
22504  */
22505   }
22506 
22507   /* "View.MemoryView":193
22508  *         if not (flags & bufmode):
22509  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
22510  *         info.buf = self.data             # <<<<<<<<<<<<<<
22511  *         info.len = self.len
22512  *         info.ndim = self.ndim
22513  */
22514   __pyx_t_4 = __pyx_v_self->data;
22515   __pyx_v_info->buf = __pyx_t_4;
22516 
22517   /* "View.MemoryView":194
22518  *             raise ValueError("Can only create a buffer that is contiguous in memory.")
22519  *         info.buf = self.data
22520  *         info.len = self.len             # <<<<<<<<<<<<<<
22521  *         info.ndim = self.ndim
22522  *         info.shape = self._shape
22523  */
22524   __pyx_t_5 = __pyx_v_self->len;
22525   __pyx_v_info->len = __pyx_t_5;
22526 
22527   /* "View.MemoryView":195
22528  *         info.buf = self.data
22529  *         info.len = self.len
22530  *         info.ndim = self.ndim             # <<<<<<<<<<<<<<
22531  *         info.shape = self._shape
22532  *         info.strides = self._strides
22533  */
22534   __pyx_t_6 = __pyx_v_self->ndim;
22535   __pyx_v_info->ndim = __pyx_t_6;
22536 
22537   /* "View.MemoryView":196
22538  *         info.len = self.len
22539  *         info.ndim = self.ndim
22540  *         info.shape = self._shape             # <<<<<<<<<<<<<<
22541  *         info.strides = self._strides
22542  *         info.suboffsets = NULL
22543  */
22544   __pyx_t_7 = __pyx_v_self->_shape;
22545   __pyx_v_info->shape = __pyx_t_7;
22546 
22547   /* "View.MemoryView":197
22548  *         info.ndim = self.ndim
22549  *         info.shape = self._shape
22550  *         info.strides = self._strides             # <<<<<<<<<<<<<<
22551  *         info.suboffsets = NULL
22552  *         info.itemsize = self.itemsize
22553  */
22554   __pyx_t_7 = __pyx_v_self->_strides;
22555   __pyx_v_info->strides = __pyx_t_7;
22556 
22557   /* "View.MemoryView":198
22558  *         info.shape = self._shape
22559  *         info.strides = self._strides
22560  *         info.suboffsets = NULL             # <<<<<<<<<<<<<<
22561  *         info.itemsize = self.itemsize
22562  *         info.readonly = 0
22563  */
22564   __pyx_v_info->suboffsets = NULL;
22565 
22566   /* "View.MemoryView":199
22567  *         info.strides = self._strides
22568  *         info.suboffsets = NULL
22569  *         info.itemsize = self.itemsize             # <<<<<<<<<<<<<<
22570  *         info.readonly = 0
22571  *
22572  */
22573   __pyx_t_5 = __pyx_v_self->itemsize;
22574   __pyx_v_info->itemsize = __pyx_t_5;
22575 
22576   /* "View.MemoryView":200
22577  *         info.suboffsets = NULL
22578  *         info.itemsize = self.itemsize
22579  *         info.readonly = 0             # <<<<<<<<<<<<<<
22580  *
22581  *         if flags & PyBUF_FORMAT:
22582  */
22583   __pyx_v_info->readonly = 0;
22584 
22585   /* "View.MemoryView":202
22586  *         info.readonly = 0
22587  *
22588  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
22589  *             info.format = self.format
22590  *         else:
22591  */
22592   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
22593   if (__pyx_t_1) {
22594 
22595     /* "View.MemoryView":203
22596  *
22597  *         if flags & PyBUF_FORMAT:
22598  *             info.format = self.format             # <<<<<<<<<<<<<<
22599  *         else:
22600  *             info.format = NULL
22601  */
22602     __pyx_t_4 = __pyx_v_self->format;
22603     __pyx_v_info->format = __pyx_t_4;
22604 
22605     /* "View.MemoryView":202
22606  *         info.readonly = 0
22607  *
22608  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
22609  *             info.format = self.format
22610  *         else:
22611  */
22612     goto __pyx_L5;
22613   }
22614 
22615   /* "View.MemoryView":205
22616  *             info.format = self.format
22617  *         else:
22618  *             info.format = NULL             # <<<<<<<<<<<<<<
22619  *
22620  *         info.obj = self
22621  */
22622   /*else*/ {
22623     __pyx_v_info->format = NULL;
22624   }
22625   __pyx_L5:;
22626 
22627   /* "View.MemoryView":207
22628  *             info.format = NULL
22629  *
22630  *         info.obj = self             # <<<<<<<<<<<<<<
22631  *
22632  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
22633  */
22634   __Pyx_INCREF(((PyObject *)__pyx_v_self));
22635   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
22636   __Pyx_GOTREF(__pyx_v_info->obj);
22637   __Pyx_DECREF(__pyx_v_info->obj);
22638   __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
22639 
22640   /* "View.MemoryView":185
22641  *
22642  *     @cname('getbuffer')
22643  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
22644  *         cdef int bufmode = -1
22645  *         if self.mode == u"c":
22646  */
22647 
22648   /* function exit code */
22649   __pyx_r = 0;
22650   goto __pyx_L0;
22651   __pyx_L1_error:;
22652   __Pyx_XDECREF(__pyx_t_3);
22653   __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
22654   __pyx_r = -1;
22655   if (__pyx_v_info->obj != NULL) {
22656     __Pyx_GOTREF(__pyx_v_info->obj);
22657     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
22658   }
22659   goto __pyx_L2;
22660   __pyx_L0:;
22661   if (__pyx_v_info->obj == Py_None) {
22662     __Pyx_GOTREF(__pyx_v_info->obj);
22663     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
22664   }
22665   __pyx_L2:;
22666   __Pyx_RefNannyFinishContext();
22667   return __pyx_r;
22668 }
22669 
22670 /* "View.MemoryView":211
22671  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
22672  *
22673  *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
22674  *         if self.callback_free_data != NULL:
22675  *             self.callback_free_data(self.data)
22676  */
22677 
22678 /* Python wrapper */
22679 static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_array___dealloc__(PyObject * __pyx_v_self)22680 static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
22681   __Pyx_RefNannyDeclarations
22682   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
22683   __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self));
22684 
22685   /* function exit code */
22686   __Pyx_RefNannyFinishContext();
22687 }
22688 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj * __pyx_v_self)22689 static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) {
22690   __Pyx_RefNannyDeclarations
22691   int __pyx_t_1;
22692   __Pyx_RefNannySetupContext("__dealloc__", 0);
22693 
22694   /* "View.MemoryView":212
22695  *
22696  *     def __dealloc__(array self):
22697  *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
22698  *             self.callback_free_data(self.data)
22699  *         elif self.free_data:
22700  */
22701   __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0);
22702   if (__pyx_t_1) {
22703 
22704     /* "View.MemoryView":213
22705  *     def __dealloc__(array self):
22706  *         if self.callback_free_data != NULL:
22707  *             self.callback_free_data(self.data)             # <<<<<<<<<<<<<<
22708  *         elif self.free_data:
22709  *             if self.dtype_is_object:
22710  */
22711     __pyx_v_self->callback_free_data(__pyx_v_self->data);
22712 
22713     /* "View.MemoryView":212
22714  *
22715  *     def __dealloc__(array self):
22716  *         if self.callback_free_data != NULL:             # <<<<<<<<<<<<<<
22717  *             self.callback_free_data(self.data)
22718  *         elif self.free_data:
22719  */
22720     goto __pyx_L3;
22721   }
22722 
22723   /* "View.MemoryView":214
22724  *         if self.callback_free_data != NULL:
22725  *             self.callback_free_data(self.data)
22726  *         elif self.free_data:             # <<<<<<<<<<<<<<
22727  *             if self.dtype_is_object:
22728  *                 refcount_objects_in_slice(self.data, self._shape,
22729  */
22730   __pyx_t_1 = (__pyx_v_self->free_data != 0);
22731   if (__pyx_t_1) {
22732 
22733     /* "View.MemoryView":215
22734  *             self.callback_free_data(self.data)
22735  *         elif self.free_data:
22736  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
22737  *                 refcount_objects_in_slice(self.data, self._shape,
22738  *                                           self._strides, self.ndim, False)
22739  */
22740     __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
22741     if (__pyx_t_1) {
22742 
22743       /* "View.MemoryView":216
22744  *         elif self.free_data:
22745  *             if self.dtype_is_object:
22746  *                 refcount_objects_in_slice(self.data, self._shape,             # <<<<<<<<<<<<<<
22747  *                                           self._strides, self.ndim, False)
22748  *             free(self.data)
22749  */
22750       __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0);
22751 
22752       /* "View.MemoryView":215
22753  *             self.callback_free_data(self.data)
22754  *         elif self.free_data:
22755  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
22756  *                 refcount_objects_in_slice(self.data, self._shape,
22757  *                                           self._strides, self.ndim, False)
22758  */
22759     }
22760 
22761     /* "View.MemoryView":218
22762  *                 refcount_objects_in_slice(self.data, self._shape,
22763  *                                           self._strides, self.ndim, False)
22764  *             free(self.data)             # <<<<<<<<<<<<<<
22765  *         PyObject_Free(self._shape)
22766  *
22767  */
22768     free(__pyx_v_self->data);
22769 
22770     /* "View.MemoryView":214
22771  *         if self.callback_free_data != NULL:
22772  *             self.callback_free_data(self.data)
22773  *         elif self.free_data:             # <<<<<<<<<<<<<<
22774  *             if self.dtype_is_object:
22775  *                 refcount_objects_in_slice(self.data, self._shape,
22776  */
22777   }
22778   __pyx_L3:;
22779 
22780   /* "View.MemoryView":219
22781  *                                           self._strides, self.ndim, False)
22782  *             free(self.data)
22783  *         PyObject_Free(self._shape)             # <<<<<<<<<<<<<<
22784  *
22785  *     @property
22786  */
22787   PyObject_Free(__pyx_v_self->_shape);
22788 
22789   /* "View.MemoryView":211
22790  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
22791  *
22792  *     def __dealloc__(array self):             # <<<<<<<<<<<<<<
22793  *         if self.callback_free_data != NULL:
22794  *             self.callback_free_data(self.data)
22795  */
22796 
22797   /* function exit code */
22798   __Pyx_RefNannyFinishContext();
22799 }
22800 
22801 /* "View.MemoryView":222
22802  *
22803  *     @property
22804  *     def memview(self):             # <<<<<<<<<<<<<<
22805  *         return self.get_memview()
22806  *
22807  */
22808 
22809 /* Python wrapper */
22810 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)22811 static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) {
22812   PyObject *__pyx_r = 0;
22813   __Pyx_RefNannyDeclarations
22814   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
22815   __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self));
22816 
22817   /* function exit code */
22818   __Pyx_RefNannyFinishContext();
22819   return __pyx_r;
22820 }
22821 
__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj * __pyx_v_self)22822 static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) {
22823   PyObject *__pyx_r = NULL;
22824   __Pyx_RefNannyDeclarations
22825   PyObject *__pyx_t_1 = NULL;
22826   int __pyx_lineno = 0;
22827   const char *__pyx_filename = NULL;
22828   int __pyx_clineno = 0;
22829   __Pyx_RefNannySetupContext("__get__", 0);
22830 
22831   /* "View.MemoryView":223
22832  *     @property
22833  *     def memview(self):
22834  *         return self.get_memview()             # <<<<<<<<<<<<<<
22835  *
22836  *     @cname('get_memview')
22837  */
22838   __Pyx_XDECREF(__pyx_r);
22839   __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)
22840   __Pyx_GOTREF(__pyx_t_1);
22841   __pyx_r = __pyx_t_1;
22842   __pyx_t_1 = 0;
22843   goto __pyx_L0;
22844 
22845   /* "View.MemoryView":222
22846  *
22847  *     @property
22848  *     def memview(self):             # <<<<<<<<<<<<<<
22849  *         return self.get_memview()
22850  *
22851  */
22852 
22853   /* function exit code */
22854   __pyx_L1_error:;
22855   __Pyx_XDECREF(__pyx_t_1);
22856   __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
22857   __pyx_r = NULL;
22858   __pyx_L0:;
22859   __Pyx_XGIVEREF(__pyx_r);
22860   __Pyx_RefNannyFinishContext();
22861   return __pyx_r;
22862 }
22863 
22864 /* "View.MemoryView":226
22865  *
22866  *     @cname('get_memview')
22867  *     cdef get_memview(self):             # <<<<<<<<<<<<<<
22868  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
22869  *         return  memoryview(self, flags, self.dtype_is_object)
22870  */
22871 
__pyx_array_get_memview(struct __pyx_array_obj * __pyx_v_self)22872 static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) {
22873   int __pyx_v_flags;
22874   PyObject *__pyx_r = NULL;
22875   __Pyx_RefNannyDeclarations
22876   PyObject *__pyx_t_1 = NULL;
22877   PyObject *__pyx_t_2 = NULL;
22878   PyObject *__pyx_t_3 = NULL;
22879   int __pyx_lineno = 0;
22880   const char *__pyx_filename = NULL;
22881   int __pyx_clineno = 0;
22882   __Pyx_RefNannySetupContext("get_memview", 0);
22883 
22884   /* "View.MemoryView":227
22885  *     @cname('get_memview')
22886  *     cdef get_memview(self):
22887  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE             # <<<<<<<<<<<<<<
22888  *         return  memoryview(self, flags, self.dtype_is_object)
22889  *
22890  */
22891   __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);
22892 
22893   /* "View.MemoryView":228
22894  *     cdef get_memview(self):
22895  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
22896  *         return  memoryview(self, flags, self.dtype_is_object)             # <<<<<<<<<<<<<<
22897  *
22898  *     def __len__(self):
22899  */
22900   __Pyx_XDECREF(__pyx_r);
22901   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 228, __pyx_L1_error)
22902   __Pyx_GOTREF(__pyx_t_1);
22903   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 228, __pyx_L1_error)
22904   __Pyx_GOTREF(__pyx_t_2);
22905   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 228, __pyx_L1_error)
22906   __Pyx_GOTREF(__pyx_t_3);
22907   __Pyx_INCREF(((PyObject *)__pyx_v_self));
22908   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
22909   PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
22910   __Pyx_GIVEREF(__pyx_t_1);
22911   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
22912   __Pyx_GIVEREF(__pyx_t_2);
22913   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
22914   __pyx_t_1 = 0;
22915   __pyx_t_2 = 0;
22916   __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)
22917   __Pyx_GOTREF(__pyx_t_2);
22918   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
22919   __pyx_r = __pyx_t_2;
22920   __pyx_t_2 = 0;
22921   goto __pyx_L0;
22922 
22923   /* "View.MemoryView":226
22924  *
22925  *     @cname('get_memview')
22926  *     cdef get_memview(self):             # <<<<<<<<<<<<<<
22927  *         flags =  PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
22928  *         return  memoryview(self, flags, self.dtype_is_object)
22929  */
22930 
22931   /* function exit code */
22932   __pyx_L1_error:;
22933   __Pyx_XDECREF(__pyx_t_1);
22934   __Pyx_XDECREF(__pyx_t_2);
22935   __Pyx_XDECREF(__pyx_t_3);
22936   __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
22937   __pyx_r = 0;
22938   __pyx_L0:;
22939   __Pyx_XGIVEREF(__pyx_r);
22940   __Pyx_RefNannyFinishContext();
22941   return __pyx_r;
22942 }
22943 
22944 /* "View.MemoryView":230
22945  *         return  memoryview(self, flags, self.dtype_is_object)
22946  *
22947  *     def __len__(self):             # <<<<<<<<<<<<<<
22948  *         return self._shape[0]
22949  *
22950  */
22951 
22952 /* Python wrapper */
22953 static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self); /*proto*/
__pyx_array___len__(PyObject * __pyx_v_self)22954 static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) {
22955   Py_ssize_t __pyx_r;
22956   __Pyx_RefNannyDeclarations
22957   __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
22958   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(((struct __pyx_array_obj *)__pyx_v_self));
22959 
22960   /* function exit code */
22961   __Pyx_RefNannyFinishContext();
22962   return __pyx_r;
22963 }
22964 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj * __pyx_v_self)22965 static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self) {
22966   Py_ssize_t __pyx_r;
22967   __Pyx_RefNannyDeclarations
22968   __Pyx_RefNannySetupContext("__len__", 0);
22969 
22970   /* "View.MemoryView":231
22971  *
22972  *     def __len__(self):
22973  *         return self._shape[0]             # <<<<<<<<<<<<<<
22974  *
22975  *     def __getattr__(self, attr):
22976  */
22977   __pyx_r = (__pyx_v_self->_shape[0]);
22978   goto __pyx_L0;
22979 
22980   /* "View.MemoryView":230
22981  *         return  memoryview(self, flags, self.dtype_is_object)
22982  *
22983  *     def __len__(self):             # <<<<<<<<<<<<<<
22984  *         return self._shape[0]
22985  *
22986  */
22987 
22988   /* function exit code */
22989   __pyx_L0:;
22990   __Pyx_RefNannyFinishContext();
22991   return __pyx_r;
22992 }
22993 
22994 /* "View.MemoryView":233
22995  *         return self._shape[0]
22996  *
22997  *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
22998  *         return getattr(self.memview, attr)
22999  *
23000  */
23001 
23002 /* Python wrapper */
23003 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)23004 static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
23005   PyObject *__pyx_r = 0;
23006   __Pyx_RefNannyDeclarations
23007   __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
23008   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));
23009 
23010   /* function exit code */
23011   __Pyx_RefNannyFinishContext();
23012   return __pyx_r;
23013 }
23014 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_attr)23015 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) {
23016   PyObject *__pyx_r = NULL;
23017   __Pyx_RefNannyDeclarations
23018   PyObject *__pyx_t_1 = NULL;
23019   PyObject *__pyx_t_2 = NULL;
23020   int __pyx_lineno = 0;
23021   const char *__pyx_filename = NULL;
23022   int __pyx_clineno = 0;
23023   __Pyx_RefNannySetupContext("__getattr__", 0);
23024 
23025   /* "View.MemoryView":234
23026  *
23027  *     def __getattr__(self, attr):
23028  *         return getattr(self.memview, attr)             # <<<<<<<<<<<<<<
23029  *
23030  *     def __getitem__(self, item):
23031  */
23032   __Pyx_XDECREF(__pyx_r);
23033   __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)
23034   __Pyx_GOTREF(__pyx_t_1);
23035   __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 234, __pyx_L1_error)
23036   __Pyx_GOTREF(__pyx_t_2);
23037   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23038   __pyx_r = __pyx_t_2;
23039   __pyx_t_2 = 0;
23040   goto __pyx_L0;
23041 
23042   /* "View.MemoryView":233
23043  *         return self._shape[0]
23044  *
23045  *     def __getattr__(self, attr):             # <<<<<<<<<<<<<<
23046  *         return getattr(self.memview, attr)
23047  *
23048  */
23049 
23050   /* function exit code */
23051   __pyx_L1_error:;
23052   __Pyx_XDECREF(__pyx_t_1);
23053   __Pyx_XDECREF(__pyx_t_2);
23054   __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
23055   __pyx_r = NULL;
23056   __pyx_L0:;
23057   __Pyx_XGIVEREF(__pyx_r);
23058   __Pyx_RefNannyFinishContext();
23059   return __pyx_r;
23060 }
23061 
23062 /* "View.MemoryView":236
23063  *         return getattr(self.memview, attr)
23064  *
23065  *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
23066  *         return self.memview[item]
23067  *
23068  */
23069 
23070 /* Python wrapper */
23071 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)23072 static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
23073   PyObject *__pyx_r = 0;
23074   __Pyx_RefNannyDeclarations
23075   __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
23076   __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item));
23077 
23078   /* function exit code */
23079   __Pyx_RefNannyFinishContext();
23080   return __pyx_r;
23081 }
23082 
__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj * __pyx_v_self,PyObject * __pyx_v_item)23083 static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) {
23084   PyObject *__pyx_r = NULL;
23085   __Pyx_RefNannyDeclarations
23086   PyObject *__pyx_t_1 = NULL;
23087   PyObject *__pyx_t_2 = NULL;
23088   int __pyx_lineno = 0;
23089   const char *__pyx_filename = NULL;
23090   int __pyx_clineno = 0;
23091   __Pyx_RefNannySetupContext("__getitem__", 0);
23092 
23093   /* "View.MemoryView":237
23094  *
23095  *     def __getitem__(self, item):
23096  *         return self.memview[item]             # <<<<<<<<<<<<<<
23097  *
23098  *     def __setitem__(self, item, value):
23099  */
23100   __Pyx_XDECREF(__pyx_r);
23101   __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)
23102   __Pyx_GOTREF(__pyx_t_1);
23103   __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 237, __pyx_L1_error)
23104   __Pyx_GOTREF(__pyx_t_2);
23105   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23106   __pyx_r = __pyx_t_2;
23107   __pyx_t_2 = 0;
23108   goto __pyx_L0;
23109 
23110   /* "View.MemoryView":236
23111  *         return getattr(self.memview, attr)
23112  *
23113  *     def __getitem__(self, item):             # <<<<<<<<<<<<<<
23114  *         return self.memview[item]
23115  *
23116  */
23117 
23118   /* function exit code */
23119   __pyx_L1_error:;
23120   __Pyx_XDECREF(__pyx_t_1);
23121   __Pyx_XDECREF(__pyx_t_2);
23122   __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
23123   __pyx_r = NULL;
23124   __pyx_L0:;
23125   __Pyx_XGIVEREF(__pyx_r);
23126   __Pyx_RefNannyFinishContext();
23127   return __pyx_r;
23128 }
23129 
23130 /* "View.MemoryView":239
23131  *         return self.memview[item]
23132  *
23133  *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
23134  *         self.memview[item] = value
23135  *
23136  */
23137 
23138 /* Python wrapper */
23139 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)23140 static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
23141   int __pyx_r;
23142   __Pyx_RefNannyDeclarations
23143   __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
23144   __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));
23145 
23146   /* function exit code */
23147   __Pyx_RefNannyFinishContext();
23148   return __pyx_r;
23149 }
23150 
__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)23151 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) {
23152   int __pyx_r;
23153   __Pyx_RefNannyDeclarations
23154   PyObject *__pyx_t_1 = NULL;
23155   int __pyx_lineno = 0;
23156   const char *__pyx_filename = NULL;
23157   int __pyx_clineno = 0;
23158   __Pyx_RefNannySetupContext("__setitem__", 0);
23159 
23160   /* "View.MemoryView":240
23161  *
23162  *     def __setitem__(self, item, value):
23163  *         self.memview[item] = value             # <<<<<<<<<<<<<<
23164  *
23165  *
23166  */
23167   __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)
23168   __Pyx_GOTREF(__pyx_t_1);
23169   if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(2, 240, __pyx_L1_error)
23170   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23171 
23172   /* "View.MemoryView":239
23173  *         return self.memview[item]
23174  *
23175  *     def __setitem__(self, item, value):             # <<<<<<<<<<<<<<
23176  *         self.memview[item] = value
23177  *
23178  */
23179 
23180   /* function exit code */
23181   __pyx_r = 0;
23182   goto __pyx_L0;
23183   __pyx_L1_error:;
23184   __Pyx_XDECREF(__pyx_t_1);
23185   __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
23186   __pyx_r = -1;
23187   __pyx_L0:;
23188   __Pyx_RefNannyFinishContext();
23189   return __pyx_r;
23190 }
23191 
23192 /* "(tree fragment)":1
23193  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
23194  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23195  * def __setstate_cython__(self, __pyx_state):
23196  */
23197 
23198 /* Python wrapper */
23199 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)23200 static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
23201   PyObject *__pyx_r = 0;
23202   __Pyx_RefNannyDeclarations
23203   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
23204   __pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self));
23205 
23206   /* function exit code */
23207   __Pyx_RefNannyFinishContext();
23208   return __pyx_r;
23209 }
23210 
__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj * __pyx_v_self)23211 static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) {
23212   PyObject *__pyx_r = NULL;
23213   __Pyx_RefNannyDeclarations
23214   PyObject *__pyx_t_1 = NULL;
23215   int __pyx_lineno = 0;
23216   const char *__pyx_filename = NULL;
23217   int __pyx_clineno = 0;
23218   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
23219 
23220   /* "(tree fragment)":2
23221  * def __reduce_cython__(self):
23222  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
23223  * def __setstate_cython__(self, __pyx_state):
23224  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23225  */
23226   __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)
23227   __Pyx_GOTREF(__pyx_t_1);
23228   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
23229   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23230   __PYX_ERR(2, 2, __pyx_L1_error)
23231 
23232   /* "(tree fragment)":1
23233  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
23234  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23235  * def __setstate_cython__(self, __pyx_state):
23236  */
23237 
23238   /* function exit code */
23239   __pyx_L1_error:;
23240   __Pyx_XDECREF(__pyx_t_1);
23241   __Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
23242   __pyx_r = NULL;
23243   __Pyx_XGIVEREF(__pyx_r);
23244   __Pyx_RefNannyFinishContext();
23245   return __pyx_r;
23246 }
23247 
23248 /* "(tree fragment)":3
23249  * def __reduce_cython__(self):
23250  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23251  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
23252  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23253  */
23254 
23255 /* Python wrapper */
23256 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)23257 static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
23258   PyObject *__pyx_r = 0;
23259   __Pyx_RefNannyDeclarations
23260   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
23261   __pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
23262 
23263   /* function exit code */
23264   __Pyx_RefNannyFinishContext();
23265   return __pyx_r;
23266 }
23267 
__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)23268 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) {
23269   PyObject *__pyx_r = NULL;
23270   __Pyx_RefNannyDeclarations
23271   PyObject *__pyx_t_1 = NULL;
23272   int __pyx_lineno = 0;
23273   const char *__pyx_filename = NULL;
23274   int __pyx_clineno = 0;
23275   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
23276 
23277   /* "(tree fragment)":4
23278  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23279  * def __setstate_cython__(self, __pyx_state):
23280  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
23281  */
23282   __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)
23283   __Pyx_GOTREF(__pyx_t_1);
23284   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
23285   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23286   __PYX_ERR(2, 4, __pyx_L1_error)
23287 
23288   /* "(tree fragment)":3
23289  * def __reduce_cython__(self):
23290  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23291  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
23292  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
23293  */
23294 
23295   /* function exit code */
23296   __pyx_L1_error:;
23297   __Pyx_XDECREF(__pyx_t_1);
23298   __Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
23299   __pyx_r = NULL;
23300   __Pyx_XGIVEREF(__pyx_r);
23301   __Pyx_RefNannyFinishContext();
23302   return __pyx_r;
23303 }
23304 
23305 /* "View.MemoryView":244
23306  *
23307  * @cname("__pyx_array_new")
23308  * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
23309  *                           char *mode, char *buf):
23310  *     cdef array result
23311  */
23312 
__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)23313 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) {
23314   struct __pyx_array_obj *__pyx_v_result = 0;
23315   struct __pyx_array_obj *__pyx_r = NULL;
23316   __Pyx_RefNannyDeclarations
23317   int __pyx_t_1;
23318   PyObject *__pyx_t_2 = NULL;
23319   PyObject *__pyx_t_3 = NULL;
23320   PyObject *__pyx_t_4 = NULL;
23321   PyObject *__pyx_t_5 = NULL;
23322   int __pyx_lineno = 0;
23323   const char *__pyx_filename = NULL;
23324   int __pyx_clineno = 0;
23325   __Pyx_RefNannySetupContext("array_cwrapper", 0);
23326 
23327   /* "View.MemoryView":248
23328  *     cdef array result
23329  *
23330  *     if buf == NULL:             # <<<<<<<<<<<<<<
23331  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
23332  *     else:
23333  */
23334   __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
23335   if (__pyx_t_1) {
23336 
23337     /* "View.MemoryView":249
23338  *
23339  *     if buf == NULL:
23340  *         result = array(shape, itemsize, format, mode.decode('ASCII'))             # <<<<<<<<<<<<<<
23341  *     else:
23342  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
23343  */
23344     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 249, __pyx_L1_error)
23345     __Pyx_GOTREF(__pyx_t_2);
23346     __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 249, __pyx_L1_error)
23347     __Pyx_GOTREF(__pyx_t_3);
23348     __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)
23349     __Pyx_GOTREF(__pyx_t_4);
23350     __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 249, __pyx_L1_error)
23351     __Pyx_GOTREF(__pyx_t_5);
23352     __Pyx_INCREF(__pyx_v_shape);
23353     __Pyx_GIVEREF(__pyx_v_shape);
23354     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape);
23355     __Pyx_GIVEREF(__pyx_t_2);
23356     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
23357     __Pyx_GIVEREF(__pyx_t_3);
23358     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
23359     __Pyx_GIVEREF(__pyx_t_4);
23360     PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
23361     __pyx_t_2 = 0;
23362     __pyx_t_3 = 0;
23363     __pyx_t_4 = 0;
23364     __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)
23365     __Pyx_GOTREF(__pyx_t_4);
23366     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
23367     __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4);
23368     __pyx_t_4 = 0;
23369 
23370     /* "View.MemoryView":248
23371  *     cdef array result
23372  *
23373  *     if buf == NULL:             # <<<<<<<<<<<<<<
23374  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
23375  *     else:
23376  */
23377     goto __pyx_L3;
23378   }
23379 
23380   /* "View.MemoryView":251
23381  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
23382  *     else:
23383  *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
23384  *                        allocate_buffer=False)
23385  *         result.data = buf
23386  */
23387   /*else*/ {
23388     __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 251, __pyx_L1_error)
23389     __Pyx_GOTREF(__pyx_t_4);
23390     __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 251, __pyx_L1_error)
23391     __Pyx_GOTREF(__pyx_t_5);
23392     __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)
23393     __Pyx_GOTREF(__pyx_t_3);
23394     __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 251, __pyx_L1_error)
23395     __Pyx_GOTREF(__pyx_t_2);
23396     __Pyx_INCREF(__pyx_v_shape);
23397     __Pyx_GIVEREF(__pyx_v_shape);
23398     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
23399     __Pyx_GIVEREF(__pyx_t_4);
23400     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
23401     __Pyx_GIVEREF(__pyx_t_5);
23402     PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
23403     __Pyx_GIVEREF(__pyx_t_3);
23404     PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
23405     __pyx_t_4 = 0;
23406     __pyx_t_5 = 0;
23407     __pyx_t_3 = 0;
23408 
23409     /* "View.MemoryView":252
23410  *     else:
23411  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
23412  *                        allocate_buffer=False)             # <<<<<<<<<<<<<<
23413  *         result.data = buf
23414  *
23415  */
23416     __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 252, __pyx_L1_error)
23417     __Pyx_GOTREF(__pyx_t_3);
23418     if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(2, 252, __pyx_L1_error)
23419 
23420     /* "View.MemoryView":251
23421  *         result = array(shape, itemsize, format, mode.decode('ASCII'))
23422  *     else:
23423  *         result = array(shape, itemsize, format, mode.decode('ASCII'),             # <<<<<<<<<<<<<<
23424  *                        allocate_buffer=False)
23425  *         result.data = buf
23426  */
23427     __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)
23428     __Pyx_GOTREF(__pyx_t_5);
23429     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
23430     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23431     __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5);
23432     __pyx_t_5 = 0;
23433 
23434     /* "View.MemoryView":253
23435  *         result = array(shape, itemsize, format, mode.decode('ASCII'),
23436  *                        allocate_buffer=False)
23437  *         result.data = buf             # <<<<<<<<<<<<<<
23438  *
23439  *     return result
23440  */
23441     __pyx_v_result->data = __pyx_v_buf;
23442   }
23443   __pyx_L3:;
23444 
23445   /* "View.MemoryView":255
23446  *         result.data = buf
23447  *
23448  *     return result             # <<<<<<<<<<<<<<
23449  *
23450  *
23451  */
23452   __Pyx_XDECREF(((PyObject *)__pyx_r));
23453   __Pyx_INCREF(((PyObject *)__pyx_v_result));
23454   __pyx_r = __pyx_v_result;
23455   goto __pyx_L0;
23456 
23457   /* "View.MemoryView":244
23458  *
23459  * @cname("__pyx_array_new")
23460  * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format,             # <<<<<<<<<<<<<<
23461  *                           char *mode, char *buf):
23462  *     cdef array result
23463  */
23464 
23465   /* function exit code */
23466   __pyx_L1_error:;
23467   __Pyx_XDECREF(__pyx_t_2);
23468   __Pyx_XDECREF(__pyx_t_3);
23469   __Pyx_XDECREF(__pyx_t_4);
23470   __Pyx_XDECREF(__pyx_t_5);
23471   __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
23472   __pyx_r = 0;
23473   __pyx_L0:;
23474   __Pyx_XDECREF((PyObject *)__pyx_v_result);
23475   __Pyx_XGIVEREF((PyObject *)__pyx_r);
23476   __Pyx_RefNannyFinishContext();
23477   return __pyx_r;
23478 }
23479 
23480 /* "View.MemoryView":281
23481  * cdef class Enum(object):
23482  *     cdef object name
23483  *     def __init__(self, name):             # <<<<<<<<<<<<<<
23484  *         self.name = name
23485  *     def __repr__(self):
23486  */
23487 
23488 /* Python wrapper */
23489 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)23490 static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
23491   PyObject *__pyx_v_name = 0;
23492   int __pyx_lineno = 0;
23493   const char *__pyx_filename = NULL;
23494   int __pyx_clineno = 0;
23495   int __pyx_r;
23496   __Pyx_RefNannyDeclarations
23497   __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
23498   {
23499     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
23500     PyObject* values[1] = {0};
23501     if (unlikely(__pyx_kwds)) {
23502       Py_ssize_t kw_args;
23503       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
23504       switch (pos_args) {
23505         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
23506         CYTHON_FALLTHROUGH;
23507         case  0: break;
23508         default: goto __pyx_L5_argtuple_error;
23509       }
23510       kw_args = PyDict_Size(__pyx_kwds);
23511       switch (pos_args) {
23512         case  0:
23513         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
23514         else goto __pyx_L5_argtuple_error;
23515       }
23516       if (unlikely(kw_args > 0)) {
23517         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(2, 281, __pyx_L3_error)
23518       }
23519     } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
23520       goto __pyx_L5_argtuple_error;
23521     } else {
23522       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
23523     }
23524     __pyx_v_name = values[0];
23525   }
23526   goto __pyx_L4_argument_unpacking_done;
23527   __pyx_L5_argtuple_error:;
23528   __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 281, __pyx_L3_error)
23529   __pyx_L3_error:;
23530   __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
23531   __Pyx_RefNannyFinishContext();
23532   return -1;
23533   __pyx_L4_argument_unpacking_done:;
23534   __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name);
23535 
23536   /* function exit code */
23537   __Pyx_RefNannyFinishContext();
23538   return __pyx_r;
23539 }
23540 
__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj * __pyx_v_self,PyObject * __pyx_v_name)23541 static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) {
23542   int __pyx_r;
23543   __Pyx_RefNannyDeclarations
23544   __Pyx_RefNannySetupContext("__init__", 0);
23545 
23546   /* "View.MemoryView":282
23547  *     cdef object name
23548  *     def __init__(self, name):
23549  *         self.name = name             # <<<<<<<<<<<<<<
23550  *     def __repr__(self):
23551  *         return self.name
23552  */
23553   __Pyx_INCREF(__pyx_v_name);
23554   __Pyx_GIVEREF(__pyx_v_name);
23555   __Pyx_GOTREF(__pyx_v_self->name);
23556   __Pyx_DECREF(__pyx_v_self->name);
23557   __pyx_v_self->name = __pyx_v_name;
23558 
23559   /* "View.MemoryView":281
23560  * cdef class Enum(object):
23561  *     cdef object name
23562  *     def __init__(self, name):             # <<<<<<<<<<<<<<
23563  *         self.name = name
23564  *     def __repr__(self):
23565  */
23566 
23567   /* function exit code */
23568   __pyx_r = 0;
23569   __Pyx_RefNannyFinishContext();
23570   return __pyx_r;
23571 }
23572 
23573 /* "View.MemoryView":283
23574  *     def __init__(self, name):
23575  *         self.name = name
23576  *     def __repr__(self):             # <<<<<<<<<<<<<<
23577  *         return self.name
23578  *
23579  */
23580 
23581 /* Python wrapper */
23582 static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/
__pyx_MemviewEnum___repr__(PyObject * __pyx_v_self)23583 static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
23584   PyObject *__pyx_r = 0;
23585   __Pyx_RefNannyDeclarations
23586   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
23587   __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
23588 
23589   /* function exit code */
23590   __Pyx_RefNannyFinishContext();
23591   return __pyx_r;
23592 }
23593 
__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj * __pyx_v_self)23594 static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
23595   PyObject *__pyx_r = NULL;
23596   __Pyx_RefNannyDeclarations
23597   __Pyx_RefNannySetupContext("__repr__", 0);
23598 
23599   /* "View.MemoryView":284
23600  *         self.name = name
23601  *     def __repr__(self):
23602  *         return self.name             # <<<<<<<<<<<<<<
23603  *
23604  * cdef generic = Enum("<strided and direct or indirect>")
23605  */
23606   __Pyx_XDECREF(__pyx_r);
23607   __Pyx_INCREF(__pyx_v_self->name);
23608   __pyx_r = __pyx_v_self->name;
23609   goto __pyx_L0;
23610 
23611   /* "View.MemoryView":283
23612  *     def __init__(self, name):
23613  *         self.name = name
23614  *     def __repr__(self):             # <<<<<<<<<<<<<<
23615  *         return self.name
23616  *
23617  */
23618 
23619   /* function exit code */
23620   __pyx_L0:;
23621   __Pyx_XGIVEREF(__pyx_r);
23622   __Pyx_RefNannyFinishContext();
23623   return __pyx_r;
23624 }
23625 
23626 /* "(tree fragment)":1
23627  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
23628  *     cdef tuple state
23629  *     cdef object _dict
23630  */
23631 
23632 /* Python wrapper */
23633 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)23634 static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
23635   PyObject *__pyx_r = 0;
23636   __Pyx_RefNannyDeclarations
23637   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
23638   __pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
23639 
23640   /* function exit code */
23641   __Pyx_RefNannyFinishContext();
23642   return __pyx_r;
23643 }
23644 
__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj * __pyx_v_self)23645 static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
23646   PyObject *__pyx_v_state = 0;
23647   PyObject *__pyx_v__dict = 0;
23648   int __pyx_v_use_setstate;
23649   PyObject *__pyx_r = NULL;
23650   __Pyx_RefNannyDeclarations
23651   PyObject *__pyx_t_1 = NULL;
23652   int __pyx_t_2;
23653   int __pyx_t_3;
23654   PyObject *__pyx_t_4 = NULL;
23655   PyObject *__pyx_t_5 = NULL;
23656   int __pyx_lineno = 0;
23657   const char *__pyx_filename = NULL;
23658   int __pyx_clineno = 0;
23659   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
23660 
23661   /* "(tree fragment)":5
23662  *     cdef object _dict
23663  *     cdef bint use_setstate
23664  *     state = (self.name,)             # <<<<<<<<<<<<<<
23665  *     _dict = getattr(self, '__dict__', None)
23666  *     if _dict is not None:
23667  */
23668   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
23669   __Pyx_GOTREF(__pyx_t_1);
23670   __Pyx_INCREF(__pyx_v_self->name);
23671   __Pyx_GIVEREF(__pyx_v_self->name);
23672   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name);
23673   __pyx_v_state = ((PyObject*)__pyx_t_1);
23674   __pyx_t_1 = 0;
23675 
23676   /* "(tree fragment)":6
23677  *     cdef bint use_setstate
23678  *     state = (self.name,)
23679  *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
23680  *     if _dict is not None:
23681  *         state += (_dict,)
23682  */
23683   __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)
23684   __Pyx_GOTREF(__pyx_t_1);
23685   __pyx_v__dict = __pyx_t_1;
23686   __pyx_t_1 = 0;
23687 
23688   /* "(tree fragment)":7
23689  *     state = (self.name,)
23690  *     _dict = getattr(self, '__dict__', None)
23691  *     if _dict is not None:             # <<<<<<<<<<<<<<
23692  *         state += (_dict,)
23693  *         use_setstate = True
23694  */
23695   __pyx_t_2 = (__pyx_v__dict != Py_None);
23696   __pyx_t_3 = (__pyx_t_2 != 0);
23697   if (__pyx_t_3) {
23698 
23699     /* "(tree fragment)":8
23700  *     _dict = getattr(self, '__dict__', None)
23701  *     if _dict is not None:
23702  *         state += (_dict,)             # <<<<<<<<<<<<<<
23703  *         use_setstate = True
23704  *     else:
23705  */
23706     __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
23707     __Pyx_GOTREF(__pyx_t_1);
23708     __Pyx_INCREF(__pyx_v__dict);
23709     __Pyx_GIVEREF(__pyx_v__dict);
23710     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
23711     __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 8, __pyx_L1_error)
23712     __Pyx_GOTREF(__pyx_t_4);
23713     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23714     __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
23715     __pyx_t_4 = 0;
23716 
23717     /* "(tree fragment)":9
23718  *     if _dict is not None:
23719  *         state += (_dict,)
23720  *         use_setstate = True             # <<<<<<<<<<<<<<
23721  *     else:
23722  *         use_setstate = self.name is not None
23723  */
23724     __pyx_v_use_setstate = 1;
23725 
23726     /* "(tree fragment)":7
23727  *     state = (self.name,)
23728  *     _dict = getattr(self, '__dict__', None)
23729  *     if _dict is not None:             # <<<<<<<<<<<<<<
23730  *         state += (_dict,)
23731  *         use_setstate = True
23732  */
23733     goto __pyx_L3;
23734   }
23735 
23736   /* "(tree fragment)":11
23737  *         use_setstate = True
23738  *     else:
23739  *         use_setstate = self.name is not None             # <<<<<<<<<<<<<<
23740  *     if use_setstate:
23741  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
23742  */
23743   /*else*/ {
23744     __pyx_t_3 = (__pyx_v_self->name != Py_None);
23745     __pyx_v_use_setstate = __pyx_t_3;
23746   }
23747   __pyx_L3:;
23748 
23749   /* "(tree fragment)":12
23750  *     else:
23751  *         use_setstate = self.name is not None
23752  *     if use_setstate:             # <<<<<<<<<<<<<<
23753  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
23754  *     else:
23755  */
23756   __pyx_t_3 = (__pyx_v_use_setstate != 0);
23757   if (__pyx_t_3) {
23758 
23759     /* "(tree fragment)":13
23760  *         use_setstate = self.name is not None
23761  *     if use_setstate:
23762  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state             # <<<<<<<<<<<<<<
23763  *     else:
23764  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
23765  */
23766     __Pyx_XDECREF(__pyx_r);
23767     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 13, __pyx_L1_error)
23768     __Pyx_GOTREF(__pyx_t_4);
23769     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 13, __pyx_L1_error)
23770     __Pyx_GOTREF(__pyx_t_1);
23771     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
23772     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
23773     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
23774     __Pyx_INCREF(__pyx_int_184977713);
23775     __Pyx_GIVEREF(__pyx_int_184977713);
23776     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
23777     __Pyx_INCREF(Py_None);
23778     __Pyx_GIVEREF(Py_None);
23779     PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
23780     __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 13, __pyx_L1_error)
23781     __Pyx_GOTREF(__pyx_t_5);
23782     __Pyx_GIVEREF(__pyx_t_4);
23783     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
23784     __Pyx_GIVEREF(__pyx_t_1);
23785     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
23786     __Pyx_INCREF(__pyx_v_state);
23787     __Pyx_GIVEREF(__pyx_v_state);
23788     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
23789     __pyx_t_4 = 0;
23790     __pyx_t_1 = 0;
23791     __pyx_r = __pyx_t_5;
23792     __pyx_t_5 = 0;
23793     goto __pyx_L0;
23794 
23795     /* "(tree fragment)":12
23796  *     else:
23797  *         use_setstate = self.name is not None
23798  *     if use_setstate:             # <<<<<<<<<<<<<<
23799  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
23800  *     else:
23801  */
23802   }
23803 
23804   /* "(tree fragment)":15
23805  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
23806  *     else:
23807  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)             # <<<<<<<<<<<<<<
23808  * def __setstate_cython__(self, __pyx_state):
23809  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
23810  */
23811   /*else*/ {
23812     __Pyx_XDECREF(__pyx_r);
23813     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 15, __pyx_L1_error)
23814     __Pyx_GOTREF(__pyx_t_5);
23815     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 15, __pyx_L1_error)
23816     __Pyx_GOTREF(__pyx_t_1);
23817     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
23818     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
23819     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
23820     __Pyx_INCREF(__pyx_int_184977713);
23821     __Pyx_GIVEREF(__pyx_int_184977713);
23822     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
23823     __Pyx_INCREF(__pyx_v_state);
23824     __Pyx_GIVEREF(__pyx_v_state);
23825     PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
23826     __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 15, __pyx_L1_error)
23827     __Pyx_GOTREF(__pyx_t_4);
23828     __Pyx_GIVEREF(__pyx_t_5);
23829     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
23830     __Pyx_GIVEREF(__pyx_t_1);
23831     PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
23832     __pyx_t_5 = 0;
23833     __pyx_t_1 = 0;
23834     __pyx_r = __pyx_t_4;
23835     __pyx_t_4 = 0;
23836     goto __pyx_L0;
23837   }
23838 
23839   /* "(tree fragment)":1
23840  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
23841  *     cdef tuple state
23842  *     cdef object _dict
23843  */
23844 
23845   /* function exit code */
23846   __pyx_L1_error:;
23847   __Pyx_XDECREF(__pyx_t_1);
23848   __Pyx_XDECREF(__pyx_t_4);
23849   __Pyx_XDECREF(__pyx_t_5);
23850   __Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
23851   __pyx_r = NULL;
23852   __pyx_L0:;
23853   __Pyx_XDECREF(__pyx_v_state);
23854   __Pyx_XDECREF(__pyx_v__dict);
23855   __Pyx_XGIVEREF(__pyx_r);
23856   __Pyx_RefNannyFinishContext();
23857   return __pyx_r;
23858 }
23859 
23860 /* "(tree fragment)":16
23861  *     else:
23862  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
23863  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
23864  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
23865  */
23866 
23867 /* Python wrapper */
23868 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)23869 static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
23870   PyObject *__pyx_r = 0;
23871   __Pyx_RefNannyDeclarations
23872   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
23873   __pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
23874 
23875   /* function exit code */
23876   __Pyx_RefNannyFinishContext();
23877   return __pyx_r;
23878 }
23879 
__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj * __pyx_v_self,PyObject * __pyx_v___pyx_state)23880 static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
23881   PyObject *__pyx_r = NULL;
23882   __Pyx_RefNannyDeclarations
23883   PyObject *__pyx_t_1 = NULL;
23884   int __pyx_lineno = 0;
23885   const char *__pyx_filename = NULL;
23886   int __pyx_clineno = 0;
23887   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
23888 
23889   /* "(tree fragment)":17
23890  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
23891  * def __setstate_cython__(self, __pyx_state):
23892  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
23893  */
23894   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)
23895   __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)
23896   __Pyx_GOTREF(__pyx_t_1);
23897   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23898 
23899   /* "(tree fragment)":16
23900  *     else:
23901  *         return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
23902  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
23903  *     __pyx_unpickle_Enum__set_state(self, __pyx_state)
23904  */
23905 
23906   /* function exit code */
23907   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
23908   goto __pyx_L0;
23909   __pyx_L1_error:;
23910   __Pyx_XDECREF(__pyx_t_1);
23911   __Pyx_AddTraceback("View.MemoryView.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
23912   __pyx_r = NULL;
23913   __pyx_L0:;
23914   __Pyx_XGIVEREF(__pyx_r);
23915   __Pyx_RefNannyFinishContext();
23916   return __pyx_r;
23917 }
23918 
23919 /* "View.MemoryView":298
23920  *
23921  * @cname('__pyx_align_pointer')
23922  * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
23923  *     "Align pointer memory on a given boundary"
23924  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
23925  */
23926 
__pyx_align_pointer(void * __pyx_v_memory,size_t __pyx_v_alignment)23927 static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) {
23928   Py_intptr_t __pyx_v_aligned_p;
23929   size_t __pyx_v_offset;
23930   void *__pyx_r;
23931   int __pyx_t_1;
23932 
23933   /* "View.MemoryView":300
23934  * cdef void *align_pointer(void *memory, size_t alignment) nogil:
23935  *     "Align pointer memory on a given boundary"
23936  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory             # <<<<<<<<<<<<<<
23937  *     cdef size_t offset
23938  *
23939  */
23940   __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);
23941 
23942   /* "View.MemoryView":304
23943  *
23944  *     with cython.cdivision(True):
23945  *         offset = aligned_p % alignment             # <<<<<<<<<<<<<<
23946  *
23947  *     if offset > 0:
23948  */
23949   __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);
23950 
23951   /* "View.MemoryView":306
23952  *         offset = aligned_p % alignment
23953  *
23954  *     if offset > 0:             # <<<<<<<<<<<<<<
23955  *         aligned_p += alignment - offset
23956  *
23957  */
23958   __pyx_t_1 = ((__pyx_v_offset > 0) != 0);
23959   if (__pyx_t_1) {
23960 
23961     /* "View.MemoryView":307
23962  *
23963  *     if offset > 0:
23964  *         aligned_p += alignment - offset             # <<<<<<<<<<<<<<
23965  *
23966  *     return <void *> aligned_p
23967  */
23968     __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));
23969 
23970     /* "View.MemoryView":306
23971  *         offset = aligned_p % alignment
23972  *
23973  *     if offset > 0:             # <<<<<<<<<<<<<<
23974  *         aligned_p += alignment - offset
23975  *
23976  */
23977   }
23978 
23979   /* "View.MemoryView":309
23980  *         aligned_p += alignment - offset
23981  *
23982  *     return <void *> aligned_p             # <<<<<<<<<<<<<<
23983  *
23984  *
23985  */
23986   __pyx_r = ((void *)__pyx_v_aligned_p);
23987   goto __pyx_L0;
23988 
23989   /* "View.MemoryView":298
23990  *
23991  * @cname('__pyx_align_pointer')
23992  * cdef void *align_pointer(void *memory, size_t alignment) nogil:             # <<<<<<<<<<<<<<
23993  *     "Align pointer memory on a given boundary"
23994  *     cdef Py_intptr_t aligned_p = <Py_intptr_t> memory
23995  */
23996 
23997   /* function exit code */
23998   __pyx_L0:;
23999   return __pyx_r;
24000 }
24001 
24002 /* "View.MemoryView":345
24003  *     cdef __Pyx_TypeInfo *typeinfo
24004  *
24005  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
24006  *         self.obj = obj
24007  *         self.flags = flags
24008  */
24009 
24010 /* Python wrapper */
24011 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)24012 static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
24013   PyObject *__pyx_v_obj = 0;
24014   int __pyx_v_flags;
24015   int __pyx_v_dtype_is_object;
24016   int __pyx_lineno = 0;
24017   const char *__pyx_filename = NULL;
24018   int __pyx_clineno = 0;
24019   int __pyx_r;
24020   __Pyx_RefNannyDeclarations
24021   __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
24022   {
24023     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0};
24024     PyObject* values[3] = {0,0,0};
24025     if (unlikely(__pyx_kwds)) {
24026       Py_ssize_t kw_args;
24027       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
24028       switch (pos_args) {
24029         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
24030         CYTHON_FALLTHROUGH;
24031         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
24032         CYTHON_FALLTHROUGH;
24033         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
24034         CYTHON_FALLTHROUGH;
24035         case  0: break;
24036         default: goto __pyx_L5_argtuple_error;
24037       }
24038       kw_args = PyDict_Size(__pyx_kwds);
24039       switch (pos_args) {
24040         case  0:
24041         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
24042         else goto __pyx_L5_argtuple_error;
24043         CYTHON_FALLTHROUGH;
24044         case  1:
24045         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
24046         else {
24047           __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(2, 345, __pyx_L3_error)
24048         }
24049         CYTHON_FALLTHROUGH;
24050         case  2:
24051         if (kw_args > 0) {
24052           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype_is_object);
24053           if (value) { values[2] = value; kw_args--; }
24054         }
24055       }
24056       if (unlikely(kw_args > 0)) {
24057         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(2, 345, __pyx_L3_error)
24058       }
24059     } else {
24060       switch (PyTuple_GET_SIZE(__pyx_args)) {
24061         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
24062         CYTHON_FALLTHROUGH;
24063         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
24064         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
24065         break;
24066         default: goto __pyx_L5_argtuple_error;
24067       }
24068     }
24069     __pyx_v_obj = values[0];
24070     __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)
24071     if (values[2]) {
24072       __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)
24073     } else {
24074       __pyx_v_dtype_is_object = ((int)0);
24075     }
24076   }
24077   goto __pyx_L4_argument_unpacking_done;
24078   __pyx_L5_argtuple_error:;
24079   __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 345, __pyx_L3_error)
24080   __pyx_L3_error:;
24081   __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
24082   __Pyx_RefNannyFinishContext();
24083   return -1;
24084   __pyx_L4_argument_unpacking_done:;
24085   __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);
24086 
24087   /* function exit code */
24088   __Pyx_RefNannyFinishContext();
24089   return __pyx_r;
24090 }
24091 
__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)24092 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) {
24093   int __pyx_r;
24094   __Pyx_RefNannyDeclarations
24095   int __pyx_t_1;
24096   int __pyx_t_2;
24097   int __pyx_t_3;
24098   int __pyx_t_4;
24099   int __pyx_lineno = 0;
24100   const char *__pyx_filename = NULL;
24101   int __pyx_clineno = 0;
24102   __Pyx_RefNannySetupContext("__cinit__", 0);
24103 
24104   /* "View.MemoryView":346
24105  *
24106  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
24107  *         self.obj = obj             # <<<<<<<<<<<<<<
24108  *         self.flags = flags
24109  *         if type(self) is memoryview or obj is not None:
24110  */
24111   __Pyx_INCREF(__pyx_v_obj);
24112   __Pyx_GIVEREF(__pyx_v_obj);
24113   __Pyx_GOTREF(__pyx_v_self->obj);
24114   __Pyx_DECREF(__pyx_v_self->obj);
24115   __pyx_v_self->obj = __pyx_v_obj;
24116 
24117   /* "View.MemoryView":347
24118  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
24119  *         self.obj = obj
24120  *         self.flags = flags             # <<<<<<<<<<<<<<
24121  *         if type(self) is memoryview or obj is not None:
24122  *             __Pyx_GetBuffer(obj, &self.view, flags)
24123  */
24124   __pyx_v_self->flags = __pyx_v_flags;
24125 
24126   /* "View.MemoryView":348
24127  *         self.obj = obj
24128  *         self.flags = flags
24129  *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
24130  *             __Pyx_GetBuffer(obj, &self.view, flags)
24131  *             if <PyObject *> self.view.obj == NULL:
24132  */
24133   __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type));
24134   __pyx_t_3 = (__pyx_t_2 != 0);
24135   if (!__pyx_t_3) {
24136   } else {
24137     __pyx_t_1 = __pyx_t_3;
24138     goto __pyx_L4_bool_binop_done;
24139   }
24140   __pyx_t_3 = (__pyx_v_obj != Py_None);
24141   __pyx_t_2 = (__pyx_t_3 != 0);
24142   __pyx_t_1 = __pyx_t_2;
24143   __pyx_L4_bool_binop_done:;
24144   if (__pyx_t_1) {
24145 
24146     /* "View.MemoryView":349
24147  *         self.flags = flags
24148  *         if type(self) is memoryview or obj is not None:
24149  *             __Pyx_GetBuffer(obj, &self.view, flags)             # <<<<<<<<<<<<<<
24150  *             if <PyObject *> self.view.obj == NULL:
24151  *                 (<__pyx_buffer *> &self.view).obj = Py_None
24152  */
24153     __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)
24154 
24155     /* "View.MemoryView":350
24156  *         if type(self) is memoryview or obj is not None:
24157  *             __Pyx_GetBuffer(obj, &self.view, flags)
24158  *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
24159  *                 (<__pyx_buffer *> &self.view).obj = Py_None
24160  *                 Py_INCREF(Py_None)
24161  */
24162     __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0);
24163     if (__pyx_t_1) {
24164 
24165       /* "View.MemoryView":351
24166  *             __Pyx_GetBuffer(obj, &self.view, flags)
24167  *             if <PyObject *> self.view.obj == NULL:
24168  *                 (<__pyx_buffer *> &self.view).obj = Py_None             # <<<<<<<<<<<<<<
24169  *                 Py_INCREF(Py_None)
24170  *
24171  */
24172       ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None;
24173 
24174       /* "View.MemoryView":352
24175  *             if <PyObject *> self.view.obj == NULL:
24176  *                 (<__pyx_buffer *> &self.view).obj = Py_None
24177  *                 Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
24178  *
24179  *         global __pyx_memoryview_thread_locks_used
24180  */
24181       Py_INCREF(Py_None);
24182 
24183       /* "View.MemoryView":350
24184  *         if type(self) is memoryview or obj is not None:
24185  *             __Pyx_GetBuffer(obj, &self.view, flags)
24186  *             if <PyObject *> self.view.obj == NULL:             # <<<<<<<<<<<<<<
24187  *                 (<__pyx_buffer *> &self.view).obj = Py_None
24188  *                 Py_INCREF(Py_None)
24189  */
24190     }
24191 
24192     /* "View.MemoryView":348
24193  *         self.obj = obj
24194  *         self.flags = flags
24195  *         if type(self) is memoryview or obj is not None:             # <<<<<<<<<<<<<<
24196  *             __Pyx_GetBuffer(obj, &self.view, flags)
24197  *             if <PyObject *> self.view.obj == NULL:
24198  */
24199   }
24200 
24201   /* "View.MemoryView":355
24202  *
24203  *         global __pyx_memoryview_thread_locks_used
24204  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
24205  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
24206  *             __pyx_memoryview_thread_locks_used += 1
24207  */
24208   __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0);
24209   if (__pyx_t_1) {
24210 
24211     /* "View.MemoryView":356
24212  *         global __pyx_memoryview_thread_locks_used
24213  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
24214  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]             # <<<<<<<<<<<<<<
24215  *             __pyx_memoryview_thread_locks_used += 1
24216  *         if self.lock is NULL:
24217  */
24218     __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
24219 
24220     /* "View.MemoryView":357
24221  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
24222  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
24223  *             __pyx_memoryview_thread_locks_used += 1             # <<<<<<<<<<<<<<
24224  *         if self.lock is NULL:
24225  *             self.lock = PyThread_allocate_lock()
24226  */
24227     __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1);
24228 
24229     /* "View.MemoryView":355
24230  *
24231  *         global __pyx_memoryview_thread_locks_used
24232  *         if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:             # <<<<<<<<<<<<<<
24233  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
24234  *             __pyx_memoryview_thread_locks_used += 1
24235  */
24236   }
24237 
24238   /* "View.MemoryView":358
24239  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
24240  *             __pyx_memoryview_thread_locks_used += 1
24241  *         if self.lock is NULL:             # <<<<<<<<<<<<<<
24242  *             self.lock = PyThread_allocate_lock()
24243  *             if self.lock is NULL:
24244  */
24245   __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
24246   if (__pyx_t_1) {
24247 
24248     /* "View.MemoryView":359
24249  *             __pyx_memoryview_thread_locks_used += 1
24250  *         if self.lock is NULL:
24251  *             self.lock = PyThread_allocate_lock()             # <<<<<<<<<<<<<<
24252  *             if self.lock is NULL:
24253  *                 raise MemoryError
24254  */
24255     __pyx_v_self->lock = PyThread_allocate_lock();
24256 
24257     /* "View.MemoryView":360
24258  *         if self.lock is NULL:
24259  *             self.lock = PyThread_allocate_lock()
24260  *             if self.lock is NULL:             # <<<<<<<<<<<<<<
24261  *                 raise MemoryError
24262  *
24263  */
24264     __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
24265     if (unlikely(__pyx_t_1)) {
24266 
24267       /* "View.MemoryView":361
24268  *             self.lock = PyThread_allocate_lock()
24269  *             if self.lock is NULL:
24270  *                 raise MemoryError             # <<<<<<<<<<<<<<
24271  *
24272  *         if flags & PyBUF_FORMAT:
24273  */
24274       PyErr_NoMemory(); __PYX_ERR(2, 361, __pyx_L1_error)
24275 
24276       /* "View.MemoryView":360
24277  *         if self.lock is NULL:
24278  *             self.lock = PyThread_allocate_lock()
24279  *             if self.lock is NULL:             # <<<<<<<<<<<<<<
24280  *                 raise MemoryError
24281  *
24282  */
24283     }
24284 
24285     /* "View.MemoryView":358
24286  *             self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
24287  *             __pyx_memoryview_thread_locks_used += 1
24288  *         if self.lock is NULL:             # <<<<<<<<<<<<<<
24289  *             self.lock = PyThread_allocate_lock()
24290  *             if self.lock is NULL:
24291  */
24292   }
24293 
24294   /* "View.MemoryView":363
24295  *                 raise MemoryError
24296  *
24297  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
24298  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
24299  *         else:
24300  */
24301   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
24302   if (__pyx_t_1) {
24303 
24304     /* "View.MemoryView":364
24305  *
24306  *         if flags & PyBUF_FORMAT:
24307  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')             # <<<<<<<<<<<<<<
24308  *         else:
24309  *             self.dtype_is_object = dtype_is_object
24310  */
24311     __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0);
24312     if (__pyx_t_2) {
24313     } else {
24314       __pyx_t_1 = __pyx_t_2;
24315       goto __pyx_L11_bool_binop_done;
24316     }
24317     __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0);
24318     __pyx_t_1 = __pyx_t_2;
24319     __pyx_L11_bool_binop_done:;
24320     __pyx_v_self->dtype_is_object = __pyx_t_1;
24321 
24322     /* "View.MemoryView":363
24323  *                 raise MemoryError
24324  *
24325  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
24326  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
24327  *         else:
24328  */
24329     goto __pyx_L10;
24330   }
24331 
24332   /* "View.MemoryView":366
24333  *             self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
24334  *         else:
24335  *             self.dtype_is_object = dtype_is_object             # <<<<<<<<<<<<<<
24336  *
24337  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
24338  */
24339   /*else*/ {
24340     __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object;
24341   }
24342   __pyx_L10:;
24343 
24344   /* "View.MemoryView":368
24345  *             self.dtype_is_object = dtype_is_object
24346  *
24347  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(             # <<<<<<<<<<<<<<
24348  *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
24349  *         self.typeinfo = NULL
24350  */
24351   __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int))));
24352 
24353   /* "View.MemoryView":370
24354  *         self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
24355  *                   <void *> &self.acquisition_count[0], sizeof(__pyx_atomic_int))
24356  *         self.typeinfo = NULL             # <<<<<<<<<<<<<<
24357  *
24358  *     def __dealloc__(memoryview self):
24359  */
24360   __pyx_v_self->typeinfo = NULL;
24361 
24362   /* "View.MemoryView":345
24363  *     cdef __Pyx_TypeInfo *typeinfo
24364  *
24365  *     def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):             # <<<<<<<<<<<<<<
24366  *         self.obj = obj
24367  *         self.flags = flags
24368  */
24369 
24370   /* function exit code */
24371   __pyx_r = 0;
24372   goto __pyx_L0;
24373   __pyx_L1_error:;
24374   __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
24375   __pyx_r = -1;
24376   __pyx_L0:;
24377   __Pyx_RefNannyFinishContext();
24378   return __pyx_r;
24379 }
24380 
24381 /* "View.MemoryView":372
24382  *         self.typeinfo = NULL
24383  *
24384  *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
24385  *         if self.obj is not None:
24386  *             __Pyx_ReleaseBuffer(&self.view)
24387  */
24388 
24389 /* Python wrapper */
24390 static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___dealloc__(PyObject * __pyx_v_self)24391 static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
24392   __Pyx_RefNannyDeclarations
24393   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
24394   __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self));
24395 
24396   /* function exit code */
24397   __Pyx_RefNannyFinishContext();
24398 }
24399 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj * __pyx_v_self)24400 static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) {
24401   int __pyx_v_i;
24402   __Pyx_RefNannyDeclarations
24403   int __pyx_t_1;
24404   int __pyx_t_2;
24405   int __pyx_t_3;
24406   int __pyx_t_4;
24407   int __pyx_t_5;
24408   PyThread_type_lock __pyx_t_6;
24409   PyThread_type_lock __pyx_t_7;
24410   __Pyx_RefNannySetupContext("__dealloc__", 0);
24411 
24412   /* "View.MemoryView":373
24413  *
24414  *     def __dealloc__(memoryview self):
24415  *         if self.obj is not None:             # <<<<<<<<<<<<<<
24416  *             __Pyx_ReleaseBuffer(&self.view)
24417  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
24418  */
24419   __pyx_t_1 = (__pyx_v_self->obj != Py_None);
24420   __pyx_t_2 = (__pyx_t_1 != 0);
24421   if (__pyx_t_2) {
24422 
24423     /* "View.MemoryView":374
24424  *     def __dealloc__(memoryview self):
24425  *         if self.obj is not None:
24426  *             __Pyx_ReleaseBuffer(&self.view)             # <<<<<<<<<<<<<<
24427  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
24428  *
24429  */
24430     __Pyx_ReleaseBuffer((&__pyx_v_self->view));
24431 
24432     /* "View.MemoryView":373
24433  *
24434  *     def __dealloc__(memoryview self):
24435  *         if self.obj is not None:             # <<<<<<<<<<<<<<
24436  *             __Pyx_ReleaseBuffer(&self.view)
24437  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
24438  */
24439     goto __pyx_L3;
24440   }
24441 
24442   /* "View.MemoryView":375
24443  *         if self.obj is not None:
24444  *             __Pyx_ReleaseBuffer(&self.view)
24445  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:             # <<<<<<<<<<<<<<
24446  *
24447  *             (<__pyx_buffer *> &self.view).obj = NULL
24448  */
24449   __pyx_t_2 = ((((Py_buffer *)(&__pyx_v_self->view))->obj == Py_None) != 0);
24450   if (__pyx_t_2) {
24451 
24452     /* "View.MemoryView":377
24453  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:
24454  *
24455  *             (<__pyx_buffer *> &self.view).obj = NULL             # <<<<<<<<<<<<<<
24456  *             Py_DECREF(Py_None)
24457  *
24458  */
24459     ((Py_buffer *)(&__pyx_v_self->view))->obj = NULL;
24460 
24461     /* "View.MemoryView":378
24462  *
24463  *             (<__pyx_buffer *> &self.view).obj = NULL
24464  *             Py_DECREF(Py_None)             # <<<<<<<<<<<<<<
24465  *
24466  *         cdef int i
24467  */
24468     Py_DECREF(Py_None);
24469 
24470     /* "View.MemoryView":375
24471  *         if self.obj is not None:
24472  *             __Pyx_ReleaseBuffer(&self.view)
24473  *         elif (<__pyx_buffer *> &self.view).obj == Py_None:             # <<<<<<<<<<<<<<
24474  *
24475  *             (<__pyx_buffer *> &self.view).obj = NULL
24476  */
24477   }
24478   __pyx_L3:;
24479 
24480   /* "View.MemoryView":382
24481  *         cdef int i
24482  *         global __pyx_memoryview_thread_locks_used
24483  *         if self.lock != NULL:             # <<<<<<<<<<<<<<
24484  *             for i in range(__pyx_memoryview_thread_locks_used):
24485  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
24486  */
24487   __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
24488   if (__pyx_t_2) {
24489 
24490     /* "View.MemoryView":383
24491  *         global __pyx_memoryview_thread_locks_used
24492  *         if self.lock != NULL:
24493  *             for i in range(__pyx_memoryview_thread_locks_used):             # <<<<<<<<<<<<<<
24494  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
24495  *                     __pyx_memoryview_thread_locks_used -= 1
24496  */
24497     __pyx_t_3 = __pyx_memoryview_thread_locks_used;
24498     __pyx_t_4 = __pyx_t_3;
24499     for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
24500       __pyx_v_i = __pyx_t_5;
24501 
24502       /* "View.MemoryView":384
24503  *         if self.lock != NULL:
24504  *             for i in range(__pyx_memoryview_thread_locks_used):
24505  *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
24506  *                     __pyx_memoryview_thread_locks_used -= 1
24507  *                     if i != __pyx_memoryview_thread_locks_used:
24508  */
24509       __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0);
24510       if (__pyx_t_2) {
24511 
24512         /* "View.MemoryView":385
24513  *             for i in range(__pyx_memoryview_thread_locks_used):
24514  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
24515  *                     __pyx_memoryview_thread_locks_used -= 1             # <<<<<<<<<<<<<<
24516  *                     if i != __pyx_memoryview_thread_locks_used:
24517  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
24518  */
24519         __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1);
24520 
24521         /* "View.MemoryView":386
24522  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
24523  *                     __pyx_memoryview_thread_locks_used -= 1
24524  *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
24525  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
24526  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
24527  */
24528         __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0);
24529         if (__pyx_t_2) {
24530 
24531           /* "View.MemoryView":388
24532  *                     if i != __pyx_memoryview_thread_locks_used:
24533  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
24534  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])             # <<<<<<<<<<<<<<
24535  *                     break
24536  *             else:
24537  */
24538           __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
24539           __pyx_t_7 = (__pyx_memoryview_thread_locks[__pyx_v_i]);
24540 
24541           /* "View.MemoryView":387
24542  *                     __pyx_memoryview_thread_locks_used -= 1
24543  *                     if i != __pyx_memoryview_thread_locks_used:
24544  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (             # <<<<<<<<<<<<<<
24545  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
24546  *                     break
24547  */
24548           (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_6;
24549           (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_7;
24550 
24551           /* "View.MemoryView":386
24552  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
24553  *                     __pyx_memoryview_thread_locks_used -= 1
24554  *                     if i != __pyx_memoryview_thread_locks_used:             # <<<<<<<<<<<<<<
24555  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
24556  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
24557  */
24558         }
24559 
24560         /* "View.MemoryView":389
24561  *                         __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
24562  *                             __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
24563  *                     break             # <<<<<<<<<<<<<<
24564  *             else:
24565  *                 PyThread_free_lock(self.lock)
24566  */
24567         goto __pyx_L6_break;
24568 
24569         /* "View.MemoryView":384
24570  *         if self.lock != NULL:
24571  *             for i in range(__pyx_memoryview_thread_locks_used):
24572  *                 if __pyx_memoryview_thread_locks[i] is self.lock:             # <<<<<<<<<<<<<<
24573  *                     __pyx_memoryview_thread_locks_used -= 1
24574  *                     if i != __pyx_memoryview_thread_locks_used:
24575  */
24576       }
24577     }
24578     /*else*/ {
24579 
24580       /* "View.MemoryView":391
24581  *                     break
24582  *             else:
24583  *                 PyThread_free_lock(self.lock)             # <<<<<<<<<<<<<<
24584  *
24585  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
24586  */
24587       PyThread_free_lock(__pyx_v_self->lock);
24588     }
24589     __pyx_L6_break:;
24590 
24591     /* "View.MemoryView":382
24592  *         cdef int i
24593  *         global __pyx_memoryview_thread_locks_used
24594  *         if self.lock != NULL:             # <<<<<<<<<<<<<<
24595  *             for i in range(__pyx_memoryview_thread_locks_used):
24596  *                 if __pyx_memoryview_thread_locks[i] is self.lock:
24597  */
24598   }
24599 
24600   /* "View.MemoryView":372
24601  *         self.typeinfo = NULL
24602  *
24603  *     def __dealloc__(memoryview self):             # <<<<<<<<<<<<<<
24604  *         if self.obj is not None:
24605  *             __Pyx_ReleaseBuffer(&self.view)
24606  */
24607 
24608   /* function exit code */
24609   __Pyx_RefNannyFinishContext();
24610 }
24611 
24612 /* "View.MemoryView":393
24613  *                 PyThread_free_lock(self.lock)
24614  *
24615  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
24616  *         cdef Py_ssize_t dim
24617  *         cdef char *itemp = <char *> self.view.buf
24618  */
24619 
__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index)24620 static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
24621   Py_ssize_t __pyx_v_dim;
24622   char *__pyx_v_itemp;
24623   PyObject *__pyx_v_idx = NULL;
24624   char *__pyx_r;
24625   __Pyx_RefNannyDeclarations
24626   Py_ssize_t __pyx_t_1;
24627   PyObject *__pyx_t_2 = NULL;
24628   Py_ssize_t __pyx_t_3;
24629   PyObject *(*__pyx_t_4)(PyObject *);
24630   PyObject *__pyx_t_5 = NULL;
24631   Py_ssize_t __pyx_t_6;
24632   char *__pyx_t_7;
24633   int __pyx_lineno = 0;
24634   const char *__pyx_filename = NULL;
24635   int __pyx_clineno = 0;
24636   __Pyx_RefNannySetupContext("get_item_pointer", 0);
24637 
24638   /* "View.MemoryView":395
24639  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:
24640  *         cdef Py_ssize_t dim
24641  *         cdef char *itemp = <char *> self.view.buf             # <<<<<<<<<<<<<<
24642  *
24643  *         for dim, idx in enumerate(index):
24644  */
24645   __pyx_v_itemp = ((char *)__pyx_v_self->view.buf);
24646 
24647   /* "View.MemoryView":397
24648  *         cdef char *itemp = <char *> self.view.buf
24649  *
24650  *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
24651  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
24652  *
24653  */
24654   __pyx_t_1 = 0;
24655   if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) {
24656     __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
24657     __pyx_t_4 = NULL;
24658   } else {
24659     __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 397, __pyx_L1_error)
24660     __Pyx_GOTREF(__pyx_t_2);
24661     __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 397, __pyx_L1_error)
24662   }
24663   for (;;) {
24664     if (likely(!__pyx_t_4)) {
24665       if (likely(PyList_CheckExact(__pyx_t_2))) {
24666         if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
24667         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
24668         __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)
24669         #else
24670         __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)
24671         __Pyx_GOTREF(__pyx_t_5);
24672         #endif
24673       } else {
24674         if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
24675         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
24676         __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)
24677         #else
24678         __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)
24679         __Pyx_GOTREF(__pyx_t_5);
24680         #endif
24681       }
24682     } else {
24683       __pyx_t_5 = __pyx_t_4(__pyx_t_2);
24684       if (unlikely(!__pyx_t_5)) {
24685         PyObject* exc_type = PyErr_Occurred();
24686         if (exc_type) {
24687           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
24688           else __PYX_ERR(2, 397, __pyx_L1_error)
24689         }
24690         break;
24691       }
24692       __Pyx_GOTREF(__pyx_t_5);
24693     }
24694     __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5);
24695     __pyx_t_5 = 0;
24696     __pyx_v_dim = __pyx_t_1;
24697     __pyx_t_1 = (__pyx_t_1 + 1);
24698 
24699     /* "View.MemoryView":398
24700  *
24701  *         for dim, idx in enumerate(index):
24702  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)             # <<<<<<<<<<<<<<
24703  *
24704  *         return itemp
24705  */
24706     __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)
24707     __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)
24708     __pyx_v_itemp = __pyx_t_7;
24709 
24710     /* "View.MemoryView":397
24711  *         cdef char *itemp = <char *> self.view.buf
24712  *
24713  *         for dim, idx in enumerate(index):             # <<<<<<<<<<<<<<
24714  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
24715  *
24716  */
24717   }
24718   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
24719 
24720   /* "View.MemoryView":400
24721  *             itemp = pybuffer_index(&self.view, itemp, idx, dim)
24722  *
24723  *         return itemp             # <<<<<<<<<<<<<<
24724  *
24725  *
24726  */
24727   __pyx_r = __pyx_v_itemp;
24728   goto __pyx_L0;
24729 
24730   /* "View.MemoryView":393
24731  *                 PyThread_free_lock(self.lock)
24732  *
24733  *     cdef char *get_item_pointer(memoryview self, object index) except NULL:             # <<<<<<<<<<<<<<
24734  *         cdef Py_ssize_t dim
24735  *         cdef char *itemp = <char *> self.view.buf
24736  */
24737 
24738   /* function exit code */
24739   __pyx_L1_error:;
24740   __Pyx_XDECREF(__pyx_t_2);
24741   __Pyx_XDECREF(__pyx_t_5);
24742   __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
24743   __pyx_r = NULL;
24744   __pyx_L0:;
24745   __Pyx_XDECREF(__pyx_v_idx);
24746   __Pyx_RefNannyFinishContext();
24747   return __pyx_r;
24748 }
24749 
24750 /* "View.MemoryView":403
24751  *
24752  *
24753  *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
24754  *         if index is Ellipsis:
24755  *             return self
24756  */
24757 
24758 /* Python wrapper */
24759 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)24760 static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
24761   PyObject *__pyx_r = 0;
24762   __Pyx_RefNannyDeclarations
24763   __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
24764   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index));
24765 
24766   /* function exit code */
24767   __Pyx_RefNannyFinishContext();
24768   return __pyx_r;
24769 }
24770 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index)24771 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
24772   PyObject *__pyx_v_have_slices = NULL;
24773   PyObject *__pyx_v_indices = NULL;
24774   char *__pyx_v_itemp;
24775   PyObject *__pyx_r = NULL;
24776   __Pyx_RefNannyDeclarations
24777   int __pyx_t_1;
24778   int __pyx_t_2;
24779   PyObject *__pyx_t_3 = NULL;
24780   PyObject *__pyx_t_4 = NULL;
24781   PyObject *__pyx_t_5 = NULL;
24782   char *__pyx_t_6;
24783   int __pyx_lineno = 0;
24784   const char *__pyx_filename = NULL;
24785   int __pyx_clineno = 0;
24786   __Pyx_RefNannySetupContext("__getitem__", 0);
24787 
24788   /* "View.MemoryView":404
24789  *
24790  *     def __getitem__(memoryview self, object index):
24791  *         if index is Ellipsis:             # <<<<<<<<<<<<<<
24792  *             return self
24793  *
24794  */
24795   __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis);
24796   __pyx_t_2 = (__pyx_t_1 != 0);
24797   if (__pyx_t_2) {
24798 
24799     /* "View.MemoryView":405
24800  *     def __getitem__(memoryview self, object index):
24801  *         if index is Ellipsis:
24802  *             return self             # <<<<<<<<<<<<<<
24803  *
24804  *         have_slices, indices = _unellipsify(index, self.view.ndim)
24805  */
24806     __Pyx_XDECREF(__pyx_r);
24807     __Pyx_INCREF(((PyObject *)__pyx_v_self));
24808     __pyx_r = ((PyObject *)__pyx_v_self);
24809     goto __pyx_L0;
24810 
24811     /* "View.MemoryView":404
24812  *
24813  *     def __getitem__(memoryview self, object index):
24814  *         if index is Ellipsis:             # <<<<<<<<<<<<<<
24815  *             return self
24816  *
24817  */
24818   }
24819 
24820   /* "View.MemoryView":407
24821  *             return self
24822  *
24823  *         have_slices, indices = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
24824  *
24825  *         cdef char *itemp
24826  */
24827   __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 407, __pyx_L1_error)
24828   __Pyx_GOTREF(__pyx_t_3);
24829   if (likely(__pyx_t_3 != Py_None)) {
24830     PyObject* sequence = __pyx_t_3;
24831     Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
24832     if (unlikely(size != 2)) {
24833       if (size > 2) __Pyx_RaiseTooManyValuesError(2);
24834       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
24835       __PYX_ERR(2, 407, __pyx_L1_error)
24836     }
24837     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
24838     __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
24839     __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
24840     __Pyx_INCREF(__pyx_t_4);
24841     __Pyx_INCREF(__pyx_t_5);
24842     #else
24843     __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 407, __pyx_L1_error)
24844     __Pyx_GOTREF(__pyx_t_4);
24845     __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 407, __pyx_L1_error)
24846     __Pyx_GOTREF(__pyx_t_5);
24847     #endif
24848     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
24849   } else {
24850     __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 407, __pyx_L1_error)
24851   }
24852   __pyx_v_have_slices = __pyx_t_4;
24853   __pyx_t_4 = 0;
24854   __pyx_v_indices = __pyx_t_5;
24855   __pyx_t_5 = 0;
24856 
24857   /* "View.MemoryView":410
24858  *
24859  *         cdef char *itemp
24860  *         if have_slices:             # <<<<<<<<<<<<<<
24861  *             return memview_slice(self, indices)
24862  *         else:
24863  */
24864   __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 410, __pyx_L1_error)
24865   if (__pyx_t_2) {
24866 
24867     /* "View.MemoryView":411
24868  *         cdef char *itemp
24869  *         if have_slices:
24870  *             return memview_slice(self, indices)             # <<<<<<<<<<<<<<
24871  *         else:
24872  *             itemp = self.get_item_pointer(indices)
24873  */
24874     __Pyx_XDECREF(__pyx_r);
24875     __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)
24876     __Pyx_GOTREF(__pyx_t_3);
24877     __pyx_r = __pyx_t_3;
24878     __pyx_t_3 = 0;
24879     goto __pyx_L0;
24880 
24881     /* "View.MemoryView":410
24882  *
24883  *         cdef char *itemp
24884  *         if have_slices:             # <<<<<<<<<<<<<<
24885  *             return memview_slice(self, indices)
24886  *         else:
24887  */
24888   }
24889 
24890   /* "View.MemoryView":413
24891  *             return memview_slice(self, indices)
24892  *         else:
24893  *             itemp = self.get_item_pointer(indices)             # <<<<<<<<<<<<<<
24894  *             return self.convert_item_to_object(itemp)
24895  *
24896  */
24897   /*else*/ {
24898     __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)
24899     __pyx_v_itemp = __pyx_t_6;
24900 
24901     /* "View.MemoryView":414
24902  *         else:
24903  *             itemp = self.get_item_pointer(indices)
24904  *             return self.convert_item_to_object(itemp)             # <<<<<<<<<<<<<<
24905  *
24906  *     def __setitem__(memoryview self, object index, object value):
24907  */
24908     __Pyx_XDECREF(__pyx_r);
24909     __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)
24910     __Pyx_GOTREF(__pyx_t_3);
24911     __pyx_r = __pyx_t_3;
24912     __pyx_t_3 = 0;
24913     goto __pyx_L0;
24914   }
24915 
24916   /* "View.MemoryView":403
24917  *
24918  *
24919  *     def __getitem__(memoryview self, object index):             # <<<<<<<<<<<<<<
24920  *         if index is Ellipsis:
24921  *             return self
24922  */
24923 
24924   /* function exit code */
24925   __pyx_L1_error:;
24926   __Pyx_XDECREF(__pyx_t_3);
24927   __Pyx_XDECREF(__pyx_t_4);
24928   __Pyx_XDECREF(__pyx_t_5);
24929   __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
24930   __pyx_r = NULL;
24931   __pyx_L0:;
24932   __Pyx_XDECREF(__pyx_v_have_slices);
24933   __Pyx_XDECREF(__pyx_v_indices);
24934   __Pyx_XGIVEREF(__pyx_r);
24935   __Pyx_RefNannyFinishContext();
24936   return __pyx_r;
24937 }
24938 
24939 /* "View.MemoryView":416
24940  *             return self.convert_item_to_object(itemp)
24941  *
24942  *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
24943  *         if self.view.readonly:
24944  *             raise TypeError("Cannot assign to read-only memoryview")
24945  */
24946 
24947 /* Python wrapper */
24948 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)24949 static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
24950   int __pyx_r;
24951   __Pyx_RefNannyDeclarations
24952   __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
24953   __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));
24954 
24955   /* function exit code */
24956   __Pyx_RefNannyFinishContext();
24957   return __pyx_r;
24958 }
24959 
__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)24960 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) {
24961   PyObject *__pyx_v_have_slices = NULL;
24962   PyObject *__pyx_v_obj = NULL;
24963   int __pyx_r;
24964   __Pyx_RefNannyDeclarations
24965   int __pyx_t_1;
24966   PyObject *__pyx_t_2 = NULL;
24967   PyObject *__pyx_t_3 = NULL;
24968   PyObject *__pyx_t_4 = NULL;
24969   int __pyx_lineno = 0;
24970   const char *__pyx_filename = NULL;
24971   int __pyx_clineno = 0;
24972   __Pyx_RefNannySetupContext("__setitem__", 0);
24973   __Pyx_INCREF(__pyx_v_index);
24974 
24975   /* "View.MemoryView":417
24976  *
24977  *     def __setitem__(memoryview self, object index, object value):
24978  *         if self.view.readonly:             # <<<<<<<<<<<<<<
24979  *             raise TypeError("Cannot assign to read-only memoryview")
24980  *
24981  */
24982   __pyx_t_1 = (__pyx_v_self->view.readonly != 0);
24983   if (unlikely(__pyx_t_1)) {
24984 
24985     /* "View.MemoryView":418
24986  *     def __setitem__(memoryview self, object index, object value):
24987  *         if self.view.readonly:
24988  *             raise TypeError("Cannot assign to read-only memoryview")             # <<<<<<<<<<<<<<
24989  *
24990  *         have_slices, index = _unellipsify(index, self.view.ndim)
24991  */
24992     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 418, __pyx_L1_error)
24993     __Pyx_GOTREF(__pyx_t_2);
24994     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
24995     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
24996     __PYX_ERR(2, 418, __pyx_L1_error)
24997 
24998     /* "View.MemoryView":417
24999  *
25000  *     def __setitem__(memoryview self, object index, object value):
25001  *         if self.view.readonly:             # <<<<<<<<<<<<<<
25002  *             raise TypeError("Cannot assign to read-only memoryview")
25003  *
25004  */
25005   }
25006 
25007   /* "View.MemoryView":420
25008  *             raise TypeError("Cannot assign to read-only memoryview")
25009  *
25010  *         have_slices, index = _unellipsify(index, self.view.ndim)             # <<<<<<<<<<<<<<
25011  *
25012  *         if have_slices:
25013  */
25014   __pyx_t_2 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 420, __pyx_L1_error)
25015   __Pyx_GOTREF(__pyx_t_2);
25016   if (likely(__pyx_t_2 != Py_None)) {
25017     PyObject* sequence = __pyx_t_2;
25018     Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
25019     if (unlikely(size != 2)) {
25020       if (size > 2) __Pyx_RaiseTooManyValuesError(2);
25021       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
25022       __PYX_ERR(2, 420, __pyx_L1_error)
25023     }
25024     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
25025     __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
25026     __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
25027     __Pyx_INCREF(__pyx_t_3);
25028     __Pyx_INCREF(__pyx_t_4);
25029     #else
25030     __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 420, __pyx_L1_error)
25031     __Pyx_GOTREF(__pyx_t_3);
25032     __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 420, __pyx_L1_error)
25033     __Pyx_GOTREF(__pyx_t_4);
25034     #endif
25035     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25036   } else {
25037     __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 420, __pyx_L1_error)
25038   }
25039   __pyx_v_have_slices = __pyx_t_3;
25040   __pyx_t_3 = 0;
25041   __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_4);
25042   __pyx_t_4 = 0;
25043 
25044   /* "View.MemoryView":422
25045  *         have_slices, index = _unellipsify(index, self.view.ndim)
25046  *
25047  *         if have_slices:             # <<<<<<<<<<<<<<
25048  *             obj = self.is_slice(value)
25049  *             if obj:
25050  */
25051   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 422, __pyx_L1_error)
25052   if (__pyx_t_1) {
25053 
25054     /* "View.MemoryView":423
25055  *
25056  *         if have_slices:
25057  *             obj = self.is_slice(value)             # <<<<<<<<<<<<<<
25058  *             if obj:
25059  *                 self.setitem_slice_assignment(self[index], obj)
25060  */
25061     __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)
25062     __Pyx_GOTREF(__pyx_t_2);
25063     __pyx_v_obj = __pyx_t_2;
25064     __pyx_t_2 = 0;
25065 
25066     /* "View.MemoryView":424
25067  *         if have_slices:
25068  *             obj = self.is_slice(value)
25069  *             if obj:             # <<<<<<<<<<<<<<
25070  *                 self.setitem_slice_assignment(self[index], obj)
25071  *             else:
25072  */
25073     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 424, __pyx_L1_error)
25074     if (__pyx_t_1) {
25075 
25076       /* "View.MemoryView":425
25077  *             obj = self.is_slice(value)
25078  *             if obj:
25079  *                 self.setitem_slice_assignment(self[index], obj)             # <<<<<<<<<<<<<<
25080  *             else:
25081  *                 self.setitem_slice_assign_scalar(self[index], value)
25082  */
25083       __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)
25084       __Pyx_GOTREF(__pyx_t_2);
25085       __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)
25086       __Pyx_GOTREF(__pyx_t_4);
25087       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25088       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25089 
25090       /* "View.MemoryView":424
25091  *         if have_slices:
25092  *             obj = self.is_slice(value)
25093  *             if obj:             # <<<<<<<<<<<<<<
25094  *                 self.setitem_slice_assignment(self[index], obj)
25095  *             else:
25096  */
25097       goto __pyx_L5;
25098     }
25099 
25100     /* "View.MemoryView":427
25101  *                 self.setitem_slice_assignment(self[index], obj)
25102  *             else:
25103  *                 self.setitem_slice_assign_scalar(self[index], value)             # <<<<<<<<<<<<<<
25104  *         else:
25105  *             self.setitem_indexed(index, value)
25106  */
25107     /*else*/ {
25108       __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)
25109       __Pyx_GOTREF(__pyx_t_4);
25110       if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_memoryview_type))))) __PYX_ERR(2, 427, __pyx_L1_error)
25111       __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)
25112       __Pyx_GOTREF(__pyx_t_2);
25113       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25114       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25115     }
25116     __pyx_L5:;
25117 
25118     /* "View.MemoryView":422
25119  *         have_slices, index = _unellipsify(index, self.view.ndim)
25120  *
25121  *         if have_slices:             # <<<<<<<<<<<<<<
25122  *             obj = self.is_slice(value)
25123  *             if obj:
25124  */
25125     goto __pyx_L4;
25126   }
25127 
25128   /* "View.MemoryView":429
25129  *                 self.setitem_slice_assign_scalar(self[index], value)
25130  *         else:
25131  *             self.setitem_indexed(index, value)             # <<<<<<<<<<<<<<
25132  *
25133  *     cdef is_slice(self, obj):
25134  */
25135   /*else*/ {
25136     __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)
25137     __Pyx_GOTREF(__pyx_t_2);
25138     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25139   }
25140   __pyx_L4:;
25141 
25142   /* "View.MemoryView":416
25143  *             return self.convert_item_to_object(itemp)
25144  *
25145  *     def __setitem__(memoryview self, object index, object value):             # <<<<<<<<<<<<<<
25146  *         if self.view.readonly:
25147  *             raise TypeError("Cannot assign to read-only memoryview")
25148  */
25149 
25150   /* function exit code */
25151   __pyx_r = 0;
25152   goto __pyx_L0;
25153   __pyx_L1_error:;
25154   __Pyx_XDECREF(__pyx_t_2);
25155   __Pyx_XDECREF(__pyx_t_3);
25156   __Pyx_XDECREF(__pyx_t_4);
25157   __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
25158   __pyx_r = -1;
25159   __pyx_L0:;
25160   __Pyx_XDECREF(__pyx_v_have_slices);
25161   __Pyx_XDECREF(__pyx_v_obj);
25162   __Pyx_XDECREF(__pyx_v_index);
25163   __Pyx_RefNannyFinishContext();
25164   return __pyx_r;
25165 }
25166 
25167 /* "View.MemoryView":431
25168  *             self.setitem_indexed(index, value)
25169  *
25170  *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
25171  *         if not isinstance(obj, memoryview):
25172  *             try:
25173  */
25174 
__pyx_memoryview_is_slice(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_obj)25175 static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) {
25176   PyObject *__pyx_r = NULL;
25177   __Pyx_RefNannyDeclarations
25178   int __pyx_t_1;
25179   int __pyx_t_2;
25180   PyObject *__pyx_t_3 = NULL;
25181   PyObject *__pyx_t_4 = NULL;
25182   PyObject *__pyx_t_5 = NULL;
25183   PyObject *__pyx_t_6 = NULL;
25184   PyObject *__pyx_t_7 = NULL;
25185   PyObject *__pyx_t_8 = NULL;
25186   int __pyx_t_9;
25187   int __pyx_lineno = 0;
25188   const char *__pyx_filename = NULL;
25189   int __pyx_clineno = 0;
25190   __Pyx_RefNannySetupContext("is_slice", 0);
25191   __Pyx_INCREF(__pyx_v_obj);
25192 
25193   /* "View.MemoryView":432
25194  *
25195  *     cdef is_slice(self, obj):
25196  *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
25197  *             try:
25198  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
25199  */
25200   __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type);
25201   __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
25202   if (__pyx_t_2) {
25203 
25204     /* "View.MemoryView":433
25205  *     cdef is_slice(self, obj):
25206  *         if not isinstance(obj, memoryview):
25207  *             try:             # <<<<<<<<<<<<<<
25208  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
25209  *                                  self.dtype_is_object)
25210  */
25211     {
25212       __Pyx_PyThreadState_declare
25213       __Pyx_PyThreadState_assign
25214       __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
25215       __Pyx_XGOTREF(__pyx_t_3);
25216       __Pyx_XGOTREF(__pyx_t_4);
25217       __Pyx_XGOTREF(__pyx_t_5);
25218       /*try:*/ {
25219 
25220         /* "View.MemoryView":434
25221  *         if not isinstance(obj, memoryview):
25222  *             try:
25223  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
25224  *                                  self.dtype_is_object)
25225  *             except TypeError:
25226  */
25227         __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)
25228         __Pyx_GOTREF(__pyx_t_6);
25229 
25230         /* "View.MemoryView":435
25231  *             try:
25232  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
25233  *                                  self.dtype_is_object)             # <<<<<<<<<<<<<<
25234  *             except TypeError:
25235  *                 return None
25236  */
25237         __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 435, __pyx_L4_error)
25238         __Pyx_GOTREF(__pyx_t_7);
25239 
25240         /* "View.MemoryView":434
25241  *         if not isinstance(obj, memoryview):
25242  *             try:
25243  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,             # <<<<<<<<<<<<<<
25244  *                                  self.dtype_is_object)
25245  *             except TypeError:
25246  */
25247         __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 434, __pyx_L4_error)
25248         __Pyx_GOTREF(__pyx_t_8);
25249         __Pyx_INCREF(__pyx_v_obj);
25250         __Pyx_GIVEREF(__pyx_v_obj);
25251         PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
25252         __Pyx_GIVEREF(__pyx_t_6);
25253         PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
25254         __Pyx_GIVEREF(__pyx_t_7);
25255         PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
25256         __pyx_t_6 = 0;
25257         __pyx_t_7 = 0;
25258         __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)
25259         __Pyx_GOTREF(__pyx_t_7);
25260         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
25261         __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7);
25262         __pyx_t_7 = 0;
25263 
25264         /* "View.MemoryView":433
25265  *     cdef is_slice(self, obj):
25266  *         if not isinstance(obj, memoryview):
25267  *             try:             # <<<<<<<<<<<<<<
25268  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
25269  *                                  self.dtype_is_object)
25270  */
25271       }
25272       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
25273       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
25274       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
25275       goto __pyx_L9_try_end;
25276       __pyx_L4_error:;
25277       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
25278       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
25279       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
25280 
25281       /* "View.MemoryView":436
25282  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
25283  *                                  self.dtype_is_object)
25284  *             except TypeError:             # <<<<<<<<<<<<<<
25285  *                 return None
25286  *
25287  */
25288       __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
25289       if (__pyx_t_9) {
25290         __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
25291         if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(2, 436, __pyx_L6_except_error)
25292         __Pyx_GOTREF(__pyx_t_7);
25293         __Pyx_GOTREF(__pyx_t_8);
25294         __Pyx_GOTREF(__pyx_t_6);
25295 
25296         /* "View.MemoryView":437
25297  *                                  self.dtype_is_object)
25298  *             except TypeError:
25299  *                 return None             # <<<<<<<<<<<<<<
25300  *
25301  *         return obj
25302  */
25303         __Pyx_XDECREF(__pyx_r);
25304         __pyx_r = Py_None; __Pyx_INCREF(Py_None);
25305         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
25306         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
25307         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
25308         goto __pyx_L7_except_return;
25309       }
25310       goto __pyx_L6_except_error;
25311       __pyx_L6_except_error:;
25312 
25313       /* "View.MemoryView":433
25314  *     cdef is_slice(self, obj):
25315  *         if not isinstance(obj, memoryview):
25316  *             try:             # <<<<<<<<<<<<<<
25317  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
25318  *                                  self.dtype_is_object)
25319  */
25320       __Pyx_XGIVEREF(__pyx_t_3);
25321       __Pyx_XGIVEREF(__pyx_t_4);
25322       __Pyx_XGIVEREF(__pyx_t_5);
25323       __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
25324       goto __pyx_L1_error;
25325       __pyx_L7_except_return:;
25326       __Pyx_XGIVEREF(__pyx_t_3);
25327       __Pyx_XGIVEREF(__pyx_t_4);
25328       __Pyx_XGIVEREF(__pyx_t_5);
25329       __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
25330       goto __pyx_L0;
25331       __pyx_L9_try_end:;
25332     }
25333 
25334     /* "View.MemoryView":432
25335  *
25336  *     cdef is_slice(self, obj):
25337  *         if not isinstance(obj, memoryview):             # <<<<<<<<<<<<<<
25338  *             try:
25339  *                 obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
25340  */
25341   }
25342 
25343   /* "View.MemoryView":439
25344  *                 return None
25345  *
25346  *         return obj             # <<<<<<<<<<<<<<
25347  *
25348  *     cdef setitem_slice_assignment(self, dst, src):
25349  */
25350   __Pyx_XDECREF(__pyx_r);
25351   __Pyx_INCREF(__pyx_v_obj);
25352   __pyx_r = __pyx_v_obj;
25353   goto __pyx_L0;
25354 
25355   /* "View.MemoryView":431
25356  *             self.setitem_indexed(index, value)
25357  *
25358  *     cdef is_slice(self, obj):             # <<<<<<<<<<<<<<
25359  *         if not isinstance(obj, memoryview):
25360  *             try:
25361  */
25362 
25363   /* function exit code */
25364   __pyx_L1_error:;
25365   __Pyx_XDECREF(__pyx_t_6);
25366   __Pyx_XDECREF(__pyx_t_7);
25367   __Pyx_XDECREF(__pyx_t_8);
25368   __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
25369   __pyx_r = 0;
25370   __pyx_L0:;
25371   __Pyx_XDECREF(__pyx_v_obj);
25372   __Pyx_XGIVEREF(__pyx_r);
25373   __Pyx_RefNannyFinishContext();
25374   return __pyx_r;
25375 }
25376 
25377 /* "View.MemoryView":441
25378  *         return obj
25379  *
25380  *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
25381  *         cdef __Pyx_memviewslice dst_slice
25382  *         cdef __Pyx_memviewslice src_slice
25383  */
25384 
__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_dst,PyObject * __pyx_v_src)25385 static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) {
25386   __Pyx_memviewslice __pyx_v_dst_slice;
25387   __Pyx_memviewslice __pyx_v_src_slice;
25388   PyObject *__pyx_r = NULL;
25389   __Pyx_RefNannyDeclarations
25390   __Pyx_memviewslice *__pyx_t_1;
25391   __Pyx_memviewslice *__pyx_t_2;
25392   PyObject *__pyx_t_3 = NULL;
25393   int __pyx_t_4;
25394   int __pyx_t_5;
25395   int __pyx_t_6;
25396   int __pyx_lineno = 0;
25397   const char *__pyx_filename = NULL;
25398   int __pyx_clineno = 0;
25399   __Pyx_RefNannySetupContext("setitem_slice_assignment", 0);
25400 
25401   /* "View.MemoryView":445
25402  *         cdef __Pyx_memviewslice src_slice
25403  *
25404  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
25405  *                                  get_slice_from_memview(dst, &dst_slice)[0],
25406  *                                  src.ndim, dst.ndim, self.dtype_is_object)
25407  */
25408   if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(2, 445, __pyx_L1_error)
25409   __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)
25410 
25411   /* "View.MemoryView":446
25412  *
25413  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
25414  *                                  get_slice_from_memview(dst, &dst_slice)[0],             # <<<<<<<<<<<<<<
25415  *                                  src.ndim, dst.ndim, self.dtype_is_object)
25416  *
25417  */
25418   if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(2, 446, __pyx_L1_error)
25419   __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)
25420 
25421   /* "View.MemoryView":447
25422  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
25423  *                                  get_slice_from_memview(dst, &dst_slice)[0],
25424  *                                  src.ndim, dst.ndim, self.dtype_is_object)             # <<<<<<<<<<<<<<
25425  *
25426  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
25427  */
25428   __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)
25429   __Pyx_GOTREF(__pyx_t_3);
25430   __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)
25431   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25432   __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)
25433   __Pyx_GOTREF(__pyx_t_3);
25434   __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)
25435   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25436 
25437   /* "View.MemoryView":445
25438  *         cdef __Pyx_memviewslice src_slice
25439  *
25440  *         memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],             # <<<<<<<<<<<<<<
25441  *                                  get_slice_from_memview(dst, &dst_slice)[0],
25442  *                                  src.ndim, dst.ndim, self.dtype_is_object)
25443  */
25444   __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)
25445 
25446   /* "View.MemoryView":441
25447  *         return obj
25448  *
25449  *     cdef setitem_slice_assignment(self, dst, src):             # <<<<<<<<<<<<<<
25450  *         cdef __Pyx_memviewslice dst_slice
25451  *         cdef __Pyx_memviewslice src_slice
25452  */
25453 
25454   /* function exit code */
25455   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
25456   goto __pyx_L0;
25457   __pyx_L1_error:;
25458   __Pyx_XDECREF(__pyx_t_3);
25459   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
25460   __pyx_r = 0;
25461   __pyx_L0:;
25462   __Pyx_XGIVEREF(__pyx_r);
25463   __Pyx_RefNannyFinishContext();
25464   return __pyx_r;
25465 }
25466 
25467 /* "View.MemoryView":449
25468  *                                  src.ndim, dst.ndim, self.dtype_is_object)
25469  *
25470  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
25471  *         cdef int array[128]
25472  *         cdef void *tmp = NULL
25473  */
25474 
__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj * __pyx_v_self,struct __pyx_memoryview_obj * __pyx_v_dst,PyObject * __pyx_v_value)25475 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) {
25476   int __pyx_v_array[0x80];
25477   void *__pyx_v_tmp;
25478   void *__pyx_v_item;
25479   __Pyx_memviewslice *__pyx_v_dst_slice;
25480   __Pyx_memviewslice __pyx_v_tmp_slice;
25481   PyObject *__pyx_r = NULL;
25482   __Pyx_RefNannyDeclarations
25483   __Pyx_memviewslice *__pyx_t_1;
25484   int __pyx_t_2;
25485   PyObject *__pyx_t_3 = NULL;
25486   int __pyx_t_4;
25487   int __pyx_t_5;
25488   char const *__pyx_t_6;
25489   PyObject *__pyx_t_7 = NULL;
25490   PyObject *__pyx_t_8 = NULL;
25491   PyObject *__pyx_t_9 = NULL;
25492   PyObject *__pyx_t_10 = NULL;
25493   PyObject *__pyx_t_11 = NULL;
25494   PyObject *__pyx_t_12 = NULL;
25495   int __pyx_lineno = 0;
25496   const char *__pyx_filename = NULL;
25497   int __pyx_clineno = 0;
25498   __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);
25499 
25500   /* "View.MemoryView":451
25501  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):
25502  *         cdef int array[128]
25503  *         cdef void *tmp = NULL             # <<<<<<<<<<<<<<
25504  *         cdef void *item
25505  *
25506  */
25507   __pyx_v_tmp = NULL;
25508 
25509   /* "View.MemoryView":456
25510  *         cdef __Pyx_memviewslice *dst_slice
25511  *         cdef __Pyx_memviewslice tmp_slice
25512  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)             # <<<<<<<<<<<<<<
25513  *
25514  *         if <size_t>self.view.itemsize > sizeof(array):
25515  */
25516   __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)
25517   __pyx_v_dst_slice = __pyx_t_1;
25518 
25519   /* "View.MemoryView":458
25520  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
25521  *
25522  *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
25523  *             tmp = PyMem_Malloc(self.view.itemsize)
25524  *             if tmp == NULL:
25525  */
25526   __pyx_t_2 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
25527   if (__pyx_t_2) {
25528 
25529     /* "View.MemoryView":459
25530  *
25531  *         if <size_t>self.view.itemsize > sizeof(array):
25532  *             tmp = PyMem_Malloc(self.view.itemsize)             # <<<<<<<<<<<<<<
25533  *             if tmp == NULL:
25534  *                 raise MemoryError
25535  */
25536     __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize);
25537 
25538     /* "View.MemoryView":460
25539  *         if <size_t>self.view.itemsize > sizeof(array):
25540  *             tmp = PyMem_Malloc(self.view.itemsize)
25541  *             if tmp == NULL:             # <<<<<<<<<<<<<<
25542  *                 raise MemoryError
25543  *             item = tmp
25544  */
25545     __pyx_t_2 = ((__pyx_v_tmp == NULL) != 0);
25546     if (unlikely(__pyx_t_2)) {
25547 
25548       /* "View.MemoryView":461
25549  *             tmp = PyMem_Malloc(self.view.itemsize)
25550  *             if tmp == NULL:
25551  *                 raise MemoryError             # <<<<<<<<<<<<<<
25552  *             item = tmp
25553  *         else:
25554  */
25555       PyErr_NoMemory(); __PYX_ERR(2, 461, __pyx_L1_error)
25556 
25557       /* "View.MemoryView":460
25558  *         if <size_t>self.view.itemsize > sizeof(array):
25559  *             tmp = PyMem_Malloc(self.view.itemsize)
25560  *             if tmp == NULL:             # <<<<<<<<<<<<<<
25561  *                 raise MemoryError
25562  *             item = tmp
25563  */
25564     }
25565 
25566     /* "View.MemoryView":462
25567  *             if tmp == NULL:
25568  *                 raise MemoryError
25569  *             item = tmp             # <<<<<<<<<<<<<<
25570  *         else:
25571  *             item = <void *> array
25572  */
25573     __pyx_v_item = __pyx_v_tmp;
25574 
25575     /* "View.MemoryView":458
25576  *         dst_slice = get_slice_from_memview(dst, &tmp_slice)
25577  *
25578  *         if <size_t>self.view.itemsize > sizeof(array):             # <<<<<<<<<<<<<<
25579  *             tmp = PyMem_Malloc(self.view.itemsize)
25580  *             if tmp == NULL:
25581  */
25582     goto __pyx_L3;
25583   }
25584 
25585   /* "View.MemoryView":464
25586  *             item = tmp
25587  *         else:
25588  *             item = <void *> array             # <<<<<<<<<<<<<<
25589  *
25590  *         try:
25591  */
25592   /*else*/ {
25593     __pyx_v_item = ((void *)__pyx_v_array);
25594   }
25595   __pyx_L3:;
25596 
25597   /* "View.MemoryView":466
25598  *             item = <void *> array
25599  *
25600  *         try:             # <<<<<<<<<<<<<<
25601  *             if self.dtype_is_object:
25602  *                 (<PyObject **> item)[0] = <PyObject *> value
25603  */
25604   /*try:*/ {
25605 
25606     /* "View.MemoryView":467
25607  *
25608  *         try:
25609  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
25610  *                 (<PyObject **> item)[0] = <PyObject *> value
25611  *             else:
25612  */
25613     __pyx_t_2 = (__pyx_v_self->dtype_is_object != 0);
25614     if (__pyx_t_2) {
25615 
25616       /* "View.MemoryView":468
25617  *         try:
25618  *             if self.dtype_is_object:
25619  *                 (<PyObject **> item)[0] = <PyObject *> value             # <<<<<<<<<<<<<<
25620  *             else:
25621  *                 self.assign_item_from_object(<char *> item, value)
25622  */
25623       (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);
25624 
25625       /* "View.MemoryView":467
25626  *
25627  *         try:
25628  *             if self.dtype_is_object:             # <<<<<<<<<<<<<<
25629  *                 (<PyObject **> item)[0] = <PyObject *> value
25630  *             else:
25631  */
25632       goto __pyx_L8;
25633     }
25634 
25635     /* "View.MemoryView":470
25636  *                 (<PyObject **> item)[0] = <PyObject *> value
25637  *             else:
25638  *                 self.assign_item_from_object(<char *> item, value)             # <<<<<<<<<<<<<<
25639  *
25640  *
25641  */
25642     /*else*/ {
25643       __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)
25644       __Pyx_GOTREF(__pyx_t_3);
25645       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25646     }
25647     __pyx_L8:;
25648 
25649     /* "View.MemoryView":474
25650  *
25651  *
25652  *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
25653  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
25654  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
25655  */
25656     __pyx_t_2 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
25657     if (__pyx_t_2) {
25658 
25659       /* "View.MemoryView":475
25660  *
25661  *             if self.view.suboffsets != NULL:
25662  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)             # <<<<<<<<<<<<<<
25663  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
25664  *                                 item, self.dtype_is_object)
25665  */
25666       __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)
25667       __Pyx_GOTREF(__pyx_t_3);
25668       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25669 
25670       /* "View.MemoryView":474
25671  *
25672  *
25673  *             if self.view.suboffsets != NULL:             # <<<<<<<<<<<<<<
25674  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
25675  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
25676  */
25677     }
25678 
25679     /* "View.MemoryView":476
25680  *             if self.view.suboffsets != NULL:
25681  *                 assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
25682  *             slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,             # <<<<<<<<<<<<<<
25683  *                                 item, self.dtype_is_object)
25684  *         finally:
25685  */
25686     __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);
25687   }
25688 
25689   /* "View.MemoryView":479
25690  *                                 item, self.dtype_is_object)
25691  *         finally:
25692  *             PyMem_Free(tmp)             # <<<<<<<<<<<<<<
25693  *
25694  *     cdef setitem_indexed(self, index, value):
25695  */
25696   /*finally:*/ {
25697     /*normal exit:*/{
25698       PyMem_Free(__pyx_v_tmp);
25699       goto __pyx_L7;
25700     }
25701     __pyx_L6_error:;
25702     /*exception exit:*/{
25703       __Pyx_PyThreadState_declare
25704       __Pyx_PyThreadState_assign
25705       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
25706       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
25707       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
25708       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);
25709       __Pyx_XGOTREF(__pyx_t_7);
25710       __Pyx_XGOTREF(__pyx_t_8);
25711       __Pyx_XGOTREF(__pyx_t_9);
25712       __Pyx_XGOTREF(__pyx_t_10);
25713       __Pyx_XGOTREF(__pyx_t_11);
25714       __Pyx_XGOTREF(__pyx_t_12);
25715       __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
25716       {
25717         PyMem_Free(__pyx_v_tmp);
25718       }
25719       if (PY_MAJOR_VERSION >= 3) {
25720         __Pyx_XGIVEREF(__pyx_t_10);
25721         __Pyx_XGIVEREF(__pyx_t_11);
25722         __Pyx_XGIVEREF(__pyx_t_12);
25723         __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
25724       }
25725       __Pyx_XGIVEREF(__pyx_t_7);
25726       __Pyx_XGIVEREF(__pyx_t_8);
25727       __Pyx_XGIVEREF(__pyx_t_9);
25728       __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
25729       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
25730       __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
25731       goto __pyx_L1_error;
25732     }
25733     __pyx_L7:;
25734   }
25735 
25736   /* "View.MemoryView":449
25737  *                                  src.ndim, dst.ndim, self.dtype_is_object)
25738  *
25739  *     cdef setitem_slice_assign_scalar(self, memoryview dst, value):             # <<<<<<<<<<<<<<
25740  *         cdef int array[128]
25741  *         cdef void *tmp = NULL
25742  */
25743 
25744   /* function exit code */
25745   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
25746   goto __pyx_L0;
25747   __pyx_L1_error:;
25748   __Pyx_XDECREF(__pyx_t_3);
25749   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
25750   __pyx_r = 0;
25751   __pyx_L0:;
25752   __Pyx_XGIVEREF(__pyx_r);
25753   __Pyx_RefNannyFinishContext();
25754   return __pyx_r;
25755 }
25756 
25757 /* "View.MemoryView":481
25758  *             PyMem_Free(tmp)
25759  *
25760  *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
25761  *         cdef char *itemp = self.get_item_pointer(index)
25762  *         self.assign_item_from_object(itemp, value)
25763  */
25764 
__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj * __pyx_v_self,PyObject * __pyx_v_index,PyObject * __pyx_v_value)25765 static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
25766   char *__pyx_v_itemp;
25767   PyObject *__pyx_r = NULL;
25768   __Pyx_RefNannyDeclarations
25769   char *__pyx_t_1;
25770   PyObject *__pyx_t_2 = NULL;
25771   int __pyx_lineno = 0;
25772   const char *__pyx_filename = NULL;
25773   int __pyx_clineno = 0;
25774   __Pyx_RefNannySetupContext("setitem_indexed", 0);
25775 
25776   /* "View.MemoryView":482
25777  *
25778  *     cdef setitem_indexed(self, index, value):
25779  *         cdef char *itemp = self.get_item_pointer(index)             # <<<<<<<<<<<<<<
25780  *         self.assign_item_from_object(itemp, value)
25781  *
25782  */
25783   __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)
25784   __pyx_v_itemp = __pyx_t_1;
25785 
25786   /* "View.MemoryView":483
25787  *     cdef setitem_indexed(self, index, value):
25788  *         cdef char *itemp = self.get_item_pointer(index)
25789  *         self.assign_item_from_object(itemp, value)             # <<<<<<<<<<<<<<
25790  *
25791  *     cdef convert_item_to_object(self, char *itemp):
25792  */
25793   __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)
25794   __Pyx_GOTREF(__pyx_t_2);
25795   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25796 
25797   /* "View.MemoryView":481
25798  *             PyMem_Free(tmp)
25799  *
25800  *     cdef setitem_indexed(self, index, value):             # <<<<<<<<<<<<<<
25801  *         cdef char *itemp = self.get_item_pointer(index)
25802  *         self.assign_item_from_object(itemp, value)
25803  */
25804 
25805   /* function exit code */
25806   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
25807   goto __pyx_L0;
25808   __pyx_L1_error:;
25809   __Pyx_XDECREF(__pyx_t_2);
25810   __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename);
25811   __pyx_r = 0;
25812   __pyx_L0:;
25813   __Pyx_XGIVEREF(__pyx_r);
25814   __Pyx_RefNannyFinishContext();
25815   return __pyx_r;
25816 }
25817 
25818 /* "View.MemoryView":485
25819  *         self.assign_item_from_object(itemp, value)
25820  *
25821  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
25822  *         """Only used if instantiated manually by the user, or if Cython doesn't
25823  *         know how to convert the type"""
25824  */
25825 
__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj * __pyx_v_self,char * __pyx_v_itemp)25826 static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) {
25827   PyObject *__pyx_v_struct = NULL;
25828   PyObject *__pyx_v_bytesitem = 0;
25829   PyObject *__pyx_v_result = NULL;
25830   PyObject *__pyx_r = NULL;
25831   __Pyx_RefNannyDeclarations
25832   PyObject *__pyx_t_1 = NULL;
25833   PyObject *__pyx_t_2 = NULL;
25834   PyObject *__pyx_t_3 = NULL;
25835   PyObject *__pyx_t_4 = NULL;
25836   PyObject *__pyx_t_5 = NULL;
25837   PyObject *__pyx_t_6 = NULL;
25838   PyObject *__pyx_t_7 = NULL;
25839   int __pyx_t_8;
25840   PyObject *__pyx_t_9 = NULL;
25841   size_t __pyx_t_10;
25842   int __pyx_t_11;
25843   int __pyx_lineno = 0;
25844   const char *__pyx_filename = NULL;
25845   int __pyx_clineno = 0;
25846   __Pyx_RefNannySetupContext("convert_item_to_object", 0);
25847 
25848   /* "View.MemoryView":488
25849  *         """Only used if instantiated manually by the user, or if Cython doesn't
25850  *         know how to convert the type"""
25851  *         import struct             # <<<<<<<<<<<<<<
25852  *         cdef bytes bytesitem
25853  *
25854  */
25855   __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 488, __pyx_L1_error)
25856   __Pyx_GOTREF(__pyx_t_1);
25857   __pyx_v_struct = __pyx_t_1;
25858   __pyx_t_1 = 0;
25859 
25860   /* "View.MemoryView":491
25861  *         cdef bytes bytesitem
25862  *
25863  *         bytesitem = itemp[:self.view.itemsize]             # <<<<<<<<<<<<<<
25864  *         try:
25865  *             result = struct.unpack(self.view.format, bytesitem)
25866  */
25867   __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)
25868   __Pyx_GOTREF(__pyx_t_1);
25869   __pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
25870   __pyx_t_1 = 0;
25871 
25872   /* "View.MemoryView":492
25873  *
25874  *         bytesitem = itemp[:self.view.itemsize]
25875  *         try:             # <<<<<<<<<<<<<<
25876  *             result = struct.unpack(self.view.format, bytesitem)
25877  *         except struct.error:
25878  */
25879   {
25880     __Pyx_PyThreadState_declare
25881     __Pyx_PyThreadState_assign
25882     __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
25883     __Pyx_XGOTREF(__pyx_t_2);
25884     __Pyx_XGOTREF(__pyx_t_3);
25885     __Pyx_XGOTREF(__pyx_t_4);
25886     /*try:*/ {
25887 
25888       /* "View.MemoryView":493
25889  *         bytesitem = itemp[:self.view.itemsize]
25890  *         try:
25891  *             result = struct.unpack(self.view.format, bytesitem)             # <<<<<<<<<<<<<<
25892  *         except struct.error:
25893  *             raise ValueError("Unable to convert item to object")
25894  */
25895       __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)
25896       __Pyx_GOTREF(__pyx_t_5);
25897       __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 493, __pyx_L3_error)
25898       __Pyx_GOTREF(__pyx_t_6);
25899       __pyx_t_7 = NULL;
25900       __pyx_t_8 = 0;
25901       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
25902         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
25903         if (likely(__pyx_t_7)) {
25904           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
25905           __Pyx_INCREF(__pyx_t_7);
25906           __Pyx_INCREF(function);
25907           __Pyx_DECREF_SET(__pyx_t_5, function);
25908           __pyx_t_8 = 1;
25909         }
25910       }
25911       #if CYTHON_FAST_PYCALL
25912       if (PyFunction_Check(__pyx_t_5)) {
25913         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
25914         __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)
25915         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
25916         __Pyx_GOTREF(__pyx_t_1);
25917         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
25918       } else
25919       #endif
25920       #if CYTHON_FAST_PYCCALL
25921       if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
25922         PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
25923         __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)
25924         __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
25925         __Pyx_GOTREF(__pyx_t_1);
25926         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
25927       } else
25928       #endif
25929       {
25930         __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 493, __pyx_L3_error)
25931         __Pyx_GOTREF(__pyx_t_9);
25932         if (__pyx_t_7) {
25933           __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
25934         }
25935         __Pyx_GIVEREF(__pyx_t_6);
25936         PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6);
25937         __Pyx_INCREF(__pyx_v_bytesitem);
25938         __Pyx_GIVEREF(__pyx_v_bytesitem);
25939         PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem);
25940         __pyx_t_6 = 0;
25941         __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)
25942         __Pyx_GOTREF(__pyx_t_1);
25943         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
25944       }
25945       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
25946       __pyx_v_result = __pyx_t_1;
25947       __pyx_t_1 = 0;
25948 
25949       /* "View.MemoryView":492
25950  *
25951  *         bytesitem = itemp[:self.view.itemsize]
25952  *         try:             # <<<<<<<<<<<<<<
25953  *             result = struct.unpack(self.view.format, bytesitem)
25954  *         except struct.error:
25955  */
25956     }
25957 
25958     /* "View.MemoryView":497
25959  *             raise ValueError("Unable to convert item to object")
25960  *         else:
25961  *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
25962  *                 return result[0]
25963  *             return result
25964  */
25965     /*else:*/ {
25966       __pyx_t_10 = strlen(__pyx_v_self->view.format);
25967       __pyx_t_11 = ((__pyx_t_10 == 1) != 0);
25968       if (__pyx_t_11) {
25969 
25970         /* "View.MemoryView":498
25971  *         else:
25972  *             if len(self.view.format) == 1:
25973  *                 return result[0]             # <<<<<<<<<<<<<<
25974  *             return result
25975  *
25976  */
25977         __Pyx_XDECREF(__pyx_r);
25978         __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)
25979         __Pyx_GOTREF(__pyx_t_1);
25980         __pyx_r = __pyx_t_1;
25981         __pyx_t_1 = 0;
25982         goto __pyx_L6_except_return;
25983 
25984         /* "View.MemoryView":497
25985  *             raise ValueError("Unable to convert item to object")
25986  *         else:
25987  *             if len(self.view.format) == 1:             # <<<<<<<<<<<<<<
25988  *                 return result[0]
25989  *             return result
25990  */
25991       }
25992 
25993       /* "View.MemoryView":499
25994  *             if len(self.view.format) == 1:
25995  *                 return result[0]
25996  *             return result             # <<<<<<<<<<<<<<
25997  *
25998  *     cdef assign_item_from_object(self, char *itemp, object value):
25999  */
26000       __Pyx_XDECREF(__pyx_r);
26001       __Pyx_INCREF(__pyx_v_result);
26002       __pyx_r = __pyx_v_result;
26003       goto __pyx_L6_except_return;
26004     }
26005     __pyx_L3_error:;
26006     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
26007     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
26008     __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
26009     __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
26010     __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
26011 
26012     /* "View.MemoryView":494
26013  *         try:
26014  *             result = struct.unpack(self.view.format, bytesitem)
26015  *         except struct.error:             # <<<<<<<<<<<<<<
26016  *             raise ValueError("Unable to convert item to object")
26017  *         else:
26018  */
26019     __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9);
26020     __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)
26021     __Pyx_GOTREF(__pyx_t_6);
26022     __pyx_t_8 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
26023     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
26024     __Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_9);
26025     __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
26026     if (__pyx_t_8) {
26027       __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
26028       if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(2, 494, __pyx_L5_except_error)
26029       __Pyx_GOTREF(__pyx_t_9);
26030       __Pyx_GOTREF(__pyx_t_5);
26031       __Pyx_GOTREF(__pyx_t_1);
26032 
26033       /* "View.MemoryView":495
26034  *             result = struct.unpack(self.view.format, bytesitem)
26035  *         except struct.error:
26036  *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
26037  *         else:
26038  *             if len(self.view.format) == 1:
26039  */
26040       __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 495, __pyx_L5_except_error)
26041       __Pyx_GOTREF(__pyx_t_6);
26042       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
26043       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
26044       __PYX_ERR(2, 495, __pyx_L5_except_error)
26045     }
26046     goto __pyx_L5_except_error;
26047     __pyx_L5_except_error:;
26048 
26049     /* "View.MemoryView":492
26050  *
26051  *         bytesitem = itemp[:self.view.itemsize]
26052  *         try:             # <<<<<<<<<<<<<<
26053  *             result = struct.unpack(self.view.format, bytesitem)
26054  *         except struct.error:
26055  */
26056     __Pyx_XGIVEREF(__pyx_t_2);
26057     __Pyx_XGIVEREF(__pyx_t_3);
26058     __Pyx_XGIVEREF(__pyx_t_4);
26059     __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
26060     goto __pyx_L1_error;
26061     __pyx_L6_except_return:;
26062     __Pyx_XGIVEREF(__pyx_t_2);
26063     __Pyx_XGIVEREF(__pyx_t_3);
26064     __Pyx_XGIVEREF(__pyx_t_4);
26065     __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
26066     goto __pyx_L0;
26067   }
26068 
26069   /* "View.MemoryView":485
26070  *         self.assign_item_from_object(itemp, value)
26071  *
26072  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
26073  *         """Only used if instantiated manually by the user, or if Cython doesn't
26074  *         know how to convert the type"""
26075  */
26076 
26077   /* function exit code */
26078   __pyx_L1_error:;
26079   __Pyx_XDECREF(__pyx_t_1);
26080   __Pyx_XDECREF(__pyx_t_5);
26081   __Pyx_XDECREF(__pyx_t_6);
26082   __Pyx_XDECREF(__pyx_t_7);
26083   __Pyx_XDECREF(__pyx_t_9);
26084   __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
26085   __pyx_r = 0;
26086   __pyx_L0:;
26087   __Pyx_XDECREF(__pyx_v_struct);
26088   __Pyx_XDECREF(__pyx_v_bytesitem);
26089   __Pyx_XDECREF(__pyx_v_result);
26090   __Pyx_XGIVEREF(__pyx_r);
26091   __Pyx_RefNannyFinishContext();
26092   return __pyx_r;
26093 }
26094 
26095 /* "View.MemoryView":501
26096  *             return result
26097  *
26098  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
26099  *         """Only used if instantiated manually by the user, or if Cython doesn't
26100  *         know how to convert the type"""
26101  */
26102 
__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj * __pyx_v_self,char * __pyx_v_itemp,PyObject * __pyx_v_value)26103 static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
26104   PyObject *__pyx_v_struct = NULL;
26105   char __pyx_v_c;
26106   PyObject *__pyx_v_bytesvalue = 0;
26107   Py_ssize_t __pyx_v_i;
26108   PyObject *__pyx_r = NULL;
26109   __Pyx_RefNannyDeclarations
26110   PyObject *__pyx_t_1 = NULL;
26111   int __pyx_t_2;
26112   int __pyx_t_3;
26113   PyObject *__pyx_t_4 = NULL;
26114   PyObject *__pyx_t_5 = NULL;
26115   PyObject *__pyx_t_6 = NULL;
26116   int __pyx_t_7;
26117   PyObject *__pyx_t_8 = NULL;
26118   Py_ssize_t __pyx_t_9;
26119   PyObject *__pyx_t_10 = NULL;
26120   char *__pyx_t_11;
26121   char *__pyx_t_12;
26122   char *__pyx_t_13;
26123   char *__pyx_t_14;
26124   int __pyx_lineno = 0;
26125   const char *__pyx_filename = NULL;
26126   int __pyx_clineno = 0;
26127   __Pyx_RefNannySetupContext("assign_item_from_object", 0);
26128 
26129   /* "View.MemoryView":504
26130  *         """Only used if instantiated manually by the user, or if Cython doesn't
26131  *         know how to convert the type"""
26132  *         import struct             # <<<<<<<<<<<<<<
26133  *         cdef char c
26134  *         cdef bytes bytesvalue
26135  */
26136   __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 504, __pyx_L1_error)
26137   __Pyx_GOTREF(__pyx_t_1);
26138   __pyx_v_struct = __pyx_t_1;
26139   __pyx_t_1 = 0;
26140 
26141   /* "View.MemoryView":509
26142  *         cdef Py_ssize_t i
26143  *
26144  *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
26145  *             bytesvalue = struct.pack(self.view.format, *value)
26146  *         else:
26147  */
26148   __pyx_t_2 = PyTuple_Check(__pyx_v_value);
26149   __pyx_t_3 = (__pyx_t_2 != 0);
26150   if (__pyx_t_3) {
26151 
26152     /* "View.MemoryView":510
26153  *
26154  *         if isinstance(value, tuple):
26155  *             bytesvalue = struct.pack(self.view.format, *value)             # <<<<<<<<<<<<<<
26156  *         else:
26157  *             bytesvalue = struct.pack(self.view.format, value)
26158  */
26159     __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)
26160     __Pyx_GOTREF(__pyx_t_1);
26161     __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 510, __pyx_L1_error)
26162     __Pyx_GOTREF(__pyx_t_4);
26163     __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 510, __pyx_L1_error)
26164     __Pyx_GOTREF(__pyx_t_5);
26165     __Pyx_GIVEREF(__pyx_t_4);
26166     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
26167     __pyx_t_4 = 0;
26168     __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 510, __pyx_L1_error)
26169     __Pyx_GOTREF(__pyx_t_4);
26170     __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 510, __pyx_L1_error)
26171     __Pyx_GOTREF(__pyx_t_6);
26172     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
26173     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26174     __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)
26175     __Pyx_GOTREF(__pyx_t_4);
26176     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26177     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
26178     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)
26179     __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
26180     __pyx_t_4 = 0;
26181 
26182     /* "View.MemoryView":509
26183  *         cdef Py_ssize_t i
26184  *
26185  *         if isinstance(value, tuple):             # <<<<<<<<<<<<<<
26186  *             bytesvalue = struct.pack(self.view.format, *value)
26187  *         else:
26188  */
26189     goto __pyx_L3;
26190   }
26191 
26192   /* "View.MemoryView":512
26193  *             bytesvalue = struct.pack(self.view.format, *value)
26194  *         else:
26195  *             bytesvalue = struct.pack(self.view.format, value)             # <<<<<<<<<<<<<<
26196  *
26197  *         for i, c in enumerate(bytesvalue):
26198  */
26199   /*else*/ {
26200     __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)
26201     __Pyx_GOTREF(__pyx_t_6);
26202     __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 512, __pyx_L1_error)
26203     __Pyx_GOTREF(__pyx_t_1);
26204     __pyx_t_5 = NULL;
26205     __pyx_t_7 = 0;
26206     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
26207       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
26208       if (likely(__pyx_t_5)) {
26209         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
26210         __Pyx_INCREF(__pyx_t_5);
26211         __Pyx_INCREF(function);
26212         __Pyx_DECREF_SET(__pyx_t_6, function);
26213         __pyx_t_7 = 1;
26214       }
26215     }
26216     #if CYTHON_FAST_PYCALL
26217     if (PyFunction_Check(__pyx_t_6)) {
26218       PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
26219       __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)
26220       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
26221       __Pyx_GOTREF(__pyx_t_4);
26222       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26223     } else
26224     #endif
26225     #if CYTHON_FAST_PYCCALL
26226     if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
26227       PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
26228       __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)
26229       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
26230       __Pyx_GOTREF(__pyx_t_4);
26231       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26232     } else
26233     #endif
26234     {
26235       __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 512, __pyx_L1_error)
26236       __Pyx_GOTREF(__pyx_t_8);
26237       if (__pyx_t_5) {
26238         __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
26239       }
26240       __Pyx_GIVEREF(__pyx_t_1);
26241       PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
26242       __Pyx_INCREF(__pyx_v_value);
26243       __Pyx_GIVEREF(__pyx_v_value);
26244       PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
26245       __pyx_t_1 = 0;
26246       __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)
26247       __Pyx_GOTREF(__pyx_t_4);
26248       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
26249     }
26250     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
26251     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)
26252     __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
26253     __pyx_t_4 = 0;
26254   }
26255   __pyx_L3:;
26256 
26257   /* "View.MemoryView":514
26258  *             bytesvalue = struct.pack(self.view.format, value)
26259  *
26260  *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
26261  *             itemp[i] = c
26262  *
26263  */
26264   __pyx_t_9 = 0;
26265   if (unlikely(__pyx_v_bytesvalue == Py_None)) {
26266     PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
26267     __PYX_ERR(2, 514, __pyx_L1_error)
26268   }
26269   __Pyx_INCREF(__pyx_v_bytesvalue);
26270   __pyx_t_10 = __pyx_v_bytesvalue;
26271   __pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10);
26272   __pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10));
26273   for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) {
26274     __pyx_t_11 = __pyx_t_14;
26275     __pyx_v_c = (__pyx_t_11[0]);
26276 
26277     /* "View.MemoryView":515
26278  *
26279  *         for i, c in enumerate(bytesvalue):
26280  *             itemp[i] = c             # <<<<<<<<<<<<<<
26281  *
26282  *     @cname('getbuffer')
26283  */
26284     __pyx_v_i = __pyx_t_9;
26285 
26286     /* "View.MemoryView":514
26287  *             bytesvalue = struct.pack(self.view.format, value)
26288  *
26289  *         for i, c in enumerate(bytesvalue):             # <<<<<<<<<<<<<<
26290  *             itemp[i] = c
26291  *
26292  */
26293     __pyx_t_9 = (__pyx_t_9 + 1);
26294 
26295     /* "View.MemoryView":515
26296  *
26297  *         for i, c in enumerate(bytesvalue):
26298  *             itemp[i] = c             # <<<<<<<<<<<<<<
26299  *
26300  *     @cname('getbuffer')
26301  */
26302     (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
26303   }
26304   __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
26305 
26306   /* "View.MemoryView":501
26307  *             return result
26308  *
26309  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
26310  *         """Only used if instantiated manually by the user, or if Cython doesn't
26311  *         know how to convert the type"""
26312  */
26313 
26314   /* function exit code */
26315   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26316   goto __pyx_L0;
26317   __pyx_L1_error:;
26318   __Pyx_XDECREF(__pyx_t_1);
26319   __Pyx_XDECREF(__pyx_t_4);
26320   __Pyx_XDECREF(__pyx_t_5);
26321   __Pyx_XDECREF(__pyx_t_6);
26322   __Pyx_XDECREF(__pyx_t_8);
26323   __Pyx_XDECREF(__pyx_t_10);
26324   __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
26325   __pyx_r = 0;
26326   __pyx_L0:;
26327   __Pyx_XDECREF(__pyx_v_struct);
26328   __Pyx_XDECREF(__pyx_v_bytesvalue);
26329   __Pyx_XGIVEREF(__pyx_r);
26330   __Pyx_RefNannyFinishContext();
26331   return __pyx_r;
26332 }
26333 
26334 /* "View.MemoryView":518
26335  *
26336  *     @cname('getbuffer')
26337  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
26338  *         if flags & PyBUF_WRITABLE and self.view.readonly:
26339  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
26340  */
26341 
26342 /* Python wrapper */
26343 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)26344 static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
26345   int __pyx_r;
26346   __Pyx_RefNannyDeclarations
26347   __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
26348   __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));
26349 
26350   /* function exit code */
26351   __Pyx_RefNannyFinishContext();
26352   return __pyx_r;
26353 }
26354 
__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)26355 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) {
26356   int __pyx_r;
26357   __Pyx_RefNannyDeclarations
26358   int __pyx_t_1;
26359   int __pyx_t_2;
26360   PyObject *__pyx_t_3 = NULL;
26361   Py_ssize_t *__pyx_t_4;
26362   char *__pyx_t_5;
26363   void *__pyx_t_6;
26364   int __pyx_t_7;
26365   Py_ssize_t __pyx_t_8;
26366   int __pyx_lineno = 0;
26367   const char *__pyx_filename = NULL;
26368   int __pyx_clineno = 0;
26369   if (__pyx_v_info == NULL) {
26370     PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
26371     return -1;
26372   }
26373   __Pyx_RefNannySetupContext("__getbuffer__", 0);
26374   __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
26375   __Pyx_GIVEREF(__pyx_v_info->obj);
26376 
26377   /* "View.MemoryView":519
26378  *     @cname('getbuffer')
26379  *     def __getbuffer__(self, Py_buffer *info, int flags):
26380  *         if flags & PyBUF_WRITABLE and self.view.readonly:             # <<<<<<<<<<<<<<
26381  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
26382  *
26383  */
26384   __pyx_t_2 = ((__pyx_v_flags & PyBUF_WRITABLE) != 0);
26385   if (__pyx_t_2) {
26386   } else {
26387     __pyx_t_1 = __pyx_t_2;
26388     goto __pyx_L4_bool_binop_done;
26389   }
26390   __pyx_t_2 = (__pyx_v_self->view.readonly != 0);
26391   __pyx_t_1 = __pyx_t_2;
26392   __pyx_L4_bool_binop_done:;
26393   if (unlikely(__pyx_t_1)) {
26394 
26395     /* "View.MemoryView":520
26396  *     def __getbuffer__(self, Py_buffer *info, int flags):
26397  *         if flags & PyBUF_WRITABLE and self.view.readonly:
26398  *             raise ValueError("Cannot create writable memory view from read-only memoryview")             # <<<<<<<<<<<<<<
26399  *
26400  *         if flags & PyBUF_ND:
26401  */
26402     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 520, __pyx_L1_error)
26403     __Pyx_GOTREF(__pyx_t_3);
26404     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
26405     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
26406     __PYX_ERR(2, 520, __pyx_L1_error)
26407 
26408     /* "View.MemoryView":519
26409  *     @cname('getbuffer')
26410  *     def __getbuffer__(self, Py_buffer *info, int flags):
26411  *         if flags & PyBUF_WRITABLE and self.view.readonly:             # <<<<<<<<<<<<<<
26412  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
26413  *
26414  */
26415   }
26416 
26417   /* "View.MemoryView":522
26418  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
26419  *
26420  *         if flags & PyBUF_ND:             # <<<<<<<<<<<<<<
26421  *             info.shape = self.view.shape
26422  *         else:
26423  */
26424   __pyx_t_1 = ((__pyx_v_flags & PyBUF_ND) != 0);
26425   if (__pyx_t_1) {
26426 
26427     /* "View.MemoryView":523
26428  *
26429  *         if flags & PyBUF_ND:
26430  *             info.shape = self.view.shape             # <<<<<<<<<<<<<<
26431  *         else:
26432  *             info.shape = NULL
26433  */
26434     __pyx_t_4 = __pyx_v_self->view.shape;
26435     __pyx_v_info->shape = __pyx_t_4;
26436 
26437     /* "View.MemoryView":522
26438  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
26439  *
26440  *         if flags & PyBUF_ND:             # <<<<<<<<<<<<<<
26441  *             info.shape = self.view.shape
26442  *         else:
26443  */
26444     goto __pyx_L6;
26445   }
26446 
26447   /* "View.MemoryView":525
26448  *             info.shape = self.view.shape
26449  *         else:
26450  *             info.shape = NULL             # <<<<<<<<<<<<<<
26451  *
26452  *         if flags & PyBUF_STRIDES:
26453  */
26454   /*else*/ {
26455     __pyx_v_info->shape = NULL;
26456   }
26457   __pyx_L6:;
26458 
26459   /* "View.MemoryView":527
26460  *             info.shape = NULL
26461  *
26462  *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
26463  *             info.strides = self.view.strides
26464  *         else:
26465  */
26466   __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
26467   if (__pyx_t_1) {
26468 
26469     /* "View.MemoryView":528
26470  *
26471  *         if flags & PyBUF_STRIDES:
26472  *             info.strides = self.view.strides             # <<<<<<<<<<<<<<
26473  *         else:
26474  *             info.strides = NULL
26475  */
26476     __pyx_t_4 = __pyx_v_self->view.strides;
26477     __pyx_v_info->strides = __pyx_t_4;
26478 
26479     /* "View.MemoryView":527
26480  *             info.shape = NULL
26481  *
26482  *         if flags & PyBUF_STRIDES:             # <<<<<<<<<<<<<<
26483  *             info.strides = self.view.strides
26484  *         else:
26485  */
26486     goto __pyx_L7;
26487   }
26488 
26489   /* "View.MemoryView":530
26490  *             info.strides = self.view.strides
26491  *         else:
26492  *             info.strides = NULL             # <<<<<<<<<<<<<<
26493  *
26494  *         if flags & PyBUF_INDIRECT:
26495  */
26496   /*else*/ {
26497     __pyx_v_info->strides = NULL;
26498   }
26499   __pyx_L7:;
26500 
26501   /* "View.MemoryView":532
26502  *             info.strides = NULL
26503  *
26504  *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
26505  *             info.suboffsets = self.view.suboffsets
26506  *         else:
26507  */
26508   __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0);
26509   if (__pyx_t_1) {
26510 
26511     /* "View.MemoryView":533
26512  *
26513  *         if flags & PyBUF_INDIRECT:
26514  *             info.suboffsets = self.view.suboffsets             # <<<<<<<<<<<<<<
26515  *         else:
26516  *             info.suboffsets = NULL
26517  */
26518     __pyx_t_4 = __pyx_v_self->view.suboffsets;
26519     __pyx_v_info->suboffsets = __pyx_t_4;
26520 
26521     /* "View.MemoryView":532
26522  *             info.strides = NULL
26523  *
26524  *         if flags & PyBUF_INDIRECT:             # <<<<<<<<<<<<<<
26525  *             info.suboffsets = self.view.suboffsets
26526  *         else:
26527  */
26528     goto __pyx_L8;
26529   }
26530 
26531   /* "View.MemoryView":535
26532  *             info.suboffsets = self.view.suboffsets
26533  *         else:
26534  *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
26535  *
26536  *         if flags & PyBUF_FORMAT:
26537  */
26538   /*else*/ {
26539     __pyx_v_info->suboffsets = NULL;
26540   }
26541   __pyx_L8:;
26542 
26543   /* "View.MemoryView":537
26544  *             info.suboffsets = NULL
26545  *
26546  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
26547  *             info.format = self.view.format
26548  *         else:
26549  */
26550   __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
26551   if (__pyx_t_1) {
26552 
26553     /* "View.MemoryView":538
26554  *
26555  *         if flags & PyBUF_FORMAT:
26556  *             info.format = self.view.format             # <<<<<<<<<<<<<<
26557  *         else:
26558  *             info.format = NULL
26559  */
26560     __pyx_t_5 = __pyx_v_self->view.format;
26561     __pyx_v_info->format = __pyx_t_5;
26562 
26563     /* "View.MemoryView":537
26564  *             info.suboffsets = NULL
26565  *
26566  *         if flags & PyBUF_FORMAT:             # <<<<<<<<<<<<<<
26567  *             info.format = self.view.format
26568  *         else:
26569  */
26570     goto __pyx_L9;
26571   }
26572 
26573   /* "View.MemoryView":540
26574  *             info.format = self.view.format
26575  *         else:
26576  *             info.format = NULL             # <<<<<<<<<<<<<<
26577  *
26578  *         info.buf = self.view.buf
26579  */
26580   /*else*/ {
26581     __pyx_v_info->format = NULL;
26582   }
26583   __pyx_L9:;
26584 
26585   /* "View.MemoryView":542
26586  *             info.format = NULL
26587  *
26588  *         info.buf = self.view.buf             # <<<<<<<<<<<<<<
26589  *         info.ndim = self.view.ndim
26590  *         info.itemsize = self.view.itemsize
26591  */
26592   __pyx_t_6 = __pyx_v_self->view.buf;
26593   __pyx_v_info->buf = __pyx_t_6;
26594 
26595   /* "View.MemoryView":543
26596  *
26597  *         info.buf = self.view.buf
26598  *         info.ndim = self.view.ndim             # <<<<<<<<<<<<<<
26599  *         info.itemsize = self.view.itemsize
26600  *         info.len = self.view.len
26601  */
26602   __pyx_t_7 = __pyx_v_self->view.ndim;
26603   __pyx_v_info->ndim = __pyx_t_7;
26604 
26605   /* "View.MemoryView":544
26606  *         info.buf = self.view.buf
26607  *         info.ndim = self.view.ndim
26608  *         info.itemsize = self.view.itemsize             # <<<<<<<<<<<<<<
26609  *         info.len = self.view.len
26610  *         info.readonly = self.view.readonly
26611  */
26612   __pyx_t_8 = __pyx_v_self->view.itemsize;
26613   __pyx_v_info->itemsize = __pyx_t_8;
26614 
26615   /* "View.MemoryView":545
26616  *         info.ndim = self.view.ndim
26617  *         info.itemsize = self.view.itemsize
26618  *         info.len = self.view.len             # <<<<<<<<<<<<<<
26619  *         info.readonly = self.view.readonly
26620  *         info.obj = self
26621  */
26622   __pyx_t_8 = __pyx_v_self->view.len;
26623   __pyx_v_info->len = __pyx_t_8;
26624 
26625   /* "View.MemoryView":546
26626  *         info.itemsize = self.view.itemsize
26627  *         info.len = self.view.len
26628  *         info.readonly = self.view.readonly             # <<<<<<<<<<<<<<
26629  *         info.obj = self
26630  *
26631  */
26632   __pyx_t_1 = __pyx_v_self->view.readonly;
26633   __pyx_v_info->readonly = __pyx_t_1;
26634 
26635   /* "View.MemoryView":547
26636  *         info.len = self.view.len
26637  *         info.readonly = self.view.readonly
26638  *         info.obj = self             # <<<<<<<<<<<<<<
26639  *
26640  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
26641  */
26642   __Pyx_INCREF(((PyObject *)__pyx_v_self));
26643   __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
26644   __Pyx_GOTREF(__pyx_v_info->obj);
26645   __Pyx_DECREF(__pyx_v_info->obj);
26646   __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
26647 
26648   /* "View.MemoryView":518
26649  *
26650  *     @cname('getbuffer')
26651  *     def __getbuffer__(self, Py_buffer *info, int flags):             # <<<<<<<<<<<<<<
26652  *         if flags & PyBUF_WRITABLE and self.view.readonly:
26653  *             raise ValueError("Cannot create writable memory view from read-only memoryview")
26654  */
26655 
26656   /* function exit code */
26657   __pyx_r = 0;
26658   goto __pyx_L0;
26659   __pyx_L1_error:;
26660   __Pyx_XDECREF(__pyx_t_3);
26661   __Pyx_AddTraceback("View.MemoryView.memoryview.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
26662   __pyx_r = -1;
26663   if (__pyx_v_info->obj != NULL) {
26664     __Pyx_GOTREF(__pyx_v_info->obj);
26665     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
26666   }
26667   goto __pyx_L2;
26668   __pyx_L0:;
26669   if (__pyx_v_info->obj == Py_None) {
26670     __Pyx_GOTREF(__pyx_v_info->obj);
26671     __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
26672   }
26673   __pyx_L2:;
26674   __Pyx_RefNannyFinishContext();
26675   return __pyx_r;
26676 }
26677 
26678 /* "View.MemoryView":553
26679  *
26680  *     @property
26681  *     def T(self):             # <<<<<<<<<<<<<<
26682  *         cdef _memoryviewslice result = memoryview_copy(self)
26683  *         transpose_memslice(&result.from_slice)
26684  */
26685 
26686 /* Python wrapper */
26687 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)26688 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) {
26689   PyObject *__pyx_r = 0;
26690   __Pyx_RefNannyDeclarations
26691   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
26692   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
26693 
26694   /* function exit code */
26695   __Pyx_RefNannyFinishContext();
26696   return __pyx_r;
26697 }
26698 
__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj * __pyx_v_self)26699 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
26700   struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
26701   PyObject *__pyx_r = NULL;
26702   __Pyx_RefNannyDeclarations
26703   PyObject *__pyx_t_1 = NULL;
26704   int __pyx_t_2;
26705   int __pyx_lineno = 0;
26706   const char *__pyx_filename = NULL;
26707   int __pyx_clineno = 0;
26708   __Pyx_RefNannySetupContext("__get__", 0);
26709 
26710   /* "View.MemoryView":554
26711  *     @property
26712  *     def T(self):
26713  *         cdef _memoryviewslice result = memoryview_copy(self)             # <<<<<<<<<<<<<<
26714  *         transpose_memslice(&result.from_slice)
26715  *         return result
26716  */
26717   __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 554, __pyx_L1_error)
26718   __Pyx_GOTREF(__pyx_t_1);
26719   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(2, 554, __pyx_L1_error)
26720   __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
26721   __pyx_t_1 = 0;
26722 
26723   /* "View.MemoryView":555
26724  *     def T(self):
26725  *         cdef _memoryviewslice result = memoryview_copy(self)
26726  *         transpose_memslice(&result.from_slice)             # <<<<<<<<<<<<<<
26727  *         return result
26728  *
26729  */
26730   __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)
26731 
26732   /* "View.MemoryView":556
26733  *         cdef _memoryviewslice result = memoryview_copy(self)
26734  *         transpose_memslice(&result.from_slice)
26735  *         return result             # <<<<<<<<<<<<<<
26736  *
26737  *     @property
26738  */
26739   __Pyx_XDECREF(__pyx_r);
26740   __Pyx_INCREF(((PyObject *)__pyx_v_result));
26741   __pyx_r = ((PyObject *)__pyx_v_result);
26742   goto __pyx_L0;
26743 
26744   /* "View.MemoryView":553
26745  *
26746  *     @property
26747  *     def T(self):             # <<<<<<<<<<<<<<
26748  *         cdef _memoryviewslice result = memoryview_copy(self)
26749  *         transpose_memslice(&result.from_slice)
26750  */
26751 
26752   /* function exit code */
26753   __pyx_L1_error:;
26754   __Pyx_XDECREF(__pyx_t_1);
26755   __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
26756   __pyx_r = NULL;
26757   __pyx_L0:;
26758   __Pyx_XDECREF((PyObject *)__pyx_v_result);
26759   __Pyx_XGIVEREF(__pyx_r);
26760   __Pyx_RefNannyFinishContext();
26761   return __pyx_r;
26762 }
26763 
26764 /* "View.MemoryView":559
26765  *
26766  *     @property
26767  *     def base(self):             # <<<<<<<<<<<<<<
26768  *         return self.obj
26769  *
26770  */
26771 
26772 /* Python wrapper */
26773 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)26774 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) {
26775   PyObject *__pyx_r = 0;
26776   __Pyx_RefNannyDeclarations
26777   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
26778   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
26779 
26780   /* function exit code */
26781   __Pyx_RefNannyFinishContext();
26782   return __pyx_r;
26783 }
26784 
__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj * __pyx_v_self)26785 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
26786   PyObject *__pyx_r = NULL;
26787   __Pyx_RefNannyDeclarations
26788   __Pyx_RefNannySetupContext("__get__", 0);
26789 
26790   /* "View.MemoryView":560
26791  *     @property
26792  *     def base(self):
26793  *         return self.obj             # <<<<<<<<<<<<<<
26794  *
26795  *     @property
26796  */
26797   __Pyx_XDECREF(__pyx_r);
26798   __Pyx_INCREF(__pyx_v_self->obj);
26799   __pyx_r = __pyx_v_self->obj;
26800   goto __pyx_L0;
26801 
26802   /* "View.MemoryView":559
26803  *
26804  *     @property
26805  *     def base(self):             # <<<<<<<<<<<<<<
26806  *         return self.obj
26807  *
26808  */
26809 
26810   /* function exit code */
26811   __pyx_L0:;
26812   __Pyx_XGIVEREF(__pyx_r);
26813   __Pyx_RefNannyFinishContext();
26814   return __pyx_r;
26815 }
26816 
26817 /* "View.MemoryView":563
26818  *
26819  *     @property
26820  *     def shape(self):             # <<<<<<<<<<<<<<
26821  *         return tuple([length for length in self.view.shape[:self.view.ndim]])
26822  *
26823  */
26824 
26825 /* Python wrapper */
26826 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)26827 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) {
26828   PyObject *__pyx_r = 0;
26829   __Pyx_RefNannyDeclarations
26830   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
26831   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
26832 
26833   /* function exit code */
26834   __Pyx_RefNannyFinishContext();
26835   return __pyx_r;
26836 }
26837 
__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj * __pyx_v_self)26838 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
26839   Py_ssize_t __pyx_v_length;
26840   PyObject *__pyx_r = NULL;
26841   __Pyx_RefNannyDeclarations
26842   PyObject *__pyx_t_1 = NULL;
26843   Py_ssize_t *__pyx_t_2;
26844   Py_ssize_t *__pyx_t_3;
26845   Py_ssize_t *__pyx_t_4;
26846   PyObject *__pyx_t_5 = NULL;
26847   int __pyx_lineno = 0;
26848   const char *__pyx_filename = NULL;
26849   int __pyx_clineno = 0;
26850   __Pyx_RefNannySetupContext("__get__", 0);
26851 
26852   /* "View.MemoryView":564
26853  *     @property
26854  *     def shape(self):
26855  *         return tuple([length for length in self.view.shape[:self.view.ndim]])             # <<<<<<<<<<<<<<
26856  *
26857  *     @property
26858  */
26859   __Pyx_XDECREF(__pyx_r);
26860   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 564, __pyx_L1_error)
26861   __Pyx_GOTREF(__pyx_t_1);
26862   __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
26863   for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
26864     __pyx_t_2 = __pyx_t_4;
26865     __pyx_v_length = (__pyx_t_2[0]);
26866     __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 564, __pyx_L1_error)
26867     __Pyx_GOTREF(__pyx_t_5);
26868     if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(2, 564, __pyx_L1_error)
26869     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
26870   }
26871   __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 564, __pyx_L1_error)
26872   __Pyx_GOTREF(__pyx_t_5);
26873   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26874   __pyx_r = __pyx_t_5;
26875   __pyx_t_5 = 0;
26876   goto __pyx_L0;
26877 
26878   /* "View.MemoryView":563
26879  *
26880  *     @property
26881  *     def shape(self):             # <<<<<<<<<<<<<<
26882  *         return tuple([length for length in self.view.shape[:self.view.ndim]])
26883  *
26884  */
26885 
26886   /* function exit code */
26887   __pyx_L1_error:;
26888   __Pyx_XDECREF(__pyx_t_1);
26889   __Pyx_XDECREF(__pyx_t_5);
26890   __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
26891   __pyx_r = NULL;
26892   __pyx_L0:;
26893   __Pyx_XGIVEREF(__pyx_r);
26894   __Pyx_RefNannyFinishContext();
26895   return __pyx_r;
26896 }
26897 
26898 /* "View.MemoryView":567
26899  *
26900  *     @property
26901  *     def strides(self):             # <<<<<<<<<<<<<<
26902  *         if self.view.strides == NULL:
26903  *
26904  */
26905 
26906 /* Python wrapper */
26907 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)26908 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) {
26909   PyObject *__pyx_r = 0;
26910   __Pyx_RefNannyDeclarations
26911   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
26912   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
26913 
26914   /* function exit code */
26915   __Pyx_RefNannyFinishContext();
26916   return __pyx_r;
26917 }
26918 
__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj * __pyx_v_self)26919 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
26920   Py_ssize_t __pyx_v_stride;
26921   PyObject *__pyx_r = NULL;
26922   __Pyx_RefNannyDeclarations
26923   int __pyx_t_1;
26924   PyObject *__pyx_t_2 = NULL;
26925   Py_ssize_t *__pyx_t_3;
26926   Py_ssize_t *__pyx_t_4;
26927   Py_ssize_t *__pyx_t_5;
26928   PyObject *__pyx_t_6 = NULL;
26929   int __pyx_lineno = 0;
26930   const char *__pyx_filename = NULL;
26931   int __pyx_clineno = 0;
26932   __Pyx_RefNannySetupContext("__get__", 0);
26933 
26934   /* "View.MemoryView":568
26935  *     @property
26936  *     def strides(self):
26937  *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
26938  *
26939  *             raise ValueError("Buffer view does not expose strides")
26940  */
26941   __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0);
26942   if (unlikely(__pyx_t_1)) {
26943 
26944     /* "View.MemoryView":570
26945  *         if self.view.strides == NULL:
26946  *
26947  *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
26948  *
26949  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
26950  */
26951     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 570, __pyx_L1_error)
26952     __Pyx_GOTREF(__pyx_t_2);
26953     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
26954     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26955     __PYX_ERR(2, 570, __pyx_L1_error)
26956 
26957     /* "View.MemoryView":568
26958  *     @property
26959  *     def strides(self):
26960  *         if self.view.strides == NULL:             # <<<<<<<<<<<<<<
26961  *
26962  *             raise ValueError("Buffer view does not expose strides")
26963  */
26964   }
26965 
26966   /* "View.MemoryView":572
26967  *             raise ValueError("Buffer view does not expose strides")
26968  *
26969  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])             # <<<<<<<<<<<<<<
26970  *
26971  *     @property
26972  */
26973   __Pyx_XDECREF(__pyx_r);
26974   __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 572, __pyx_L1_error)
26975   __Pyx_GOTREF(__pyx_t_2);
26976   __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim);
26977   for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
26978     __pyx_t_3 = __pyx_t_5;
26979     __pyx_v_stride = (__pyx_t_3[0]);
26980     __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 572, __pyx_L1_error)
26981     __Pyx_GOTREF(__pyx_t_6);
26982     if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(2, 572, __pyx_L1_error)
26983     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
26984   }
26985   __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 572, __pyx_L1_error)
26986   __Pyx_GOTREF(__pyx_t_6);
26987   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26988   __pyx_r = __pyx_t_6;
26989   __pyx_t_6 = 0;
26990   goto __pyx_L0;
26991 
26992   /* "View.MemoryView":567
26993  *
26994  *     @property
26995  *     def strides(self):             # <<<<<<<<<<<<<<
26996  *         if self.view.strides == NULL:
26997  *
26998  */
26999 
27000   /* function exit code */
27001   __pyx_L1_error:;
27002   __Pyx_XDECREF(__pyx_t_2);
27003   __Pyx_XDECREF(__pyx_t_6);
27004   __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
27005   __pyx_r = NULL;
27006   __pyx_L0:;
27007   __Pyx_XGIVEREF(__pyx_r);
27008   __Pyx_RefNannyFinishContext();
27009   return __pyx_r;
27010 }
27011 
27012 /* "View.MemoryView":575
27013  *
27014  *     @property
27015  *     def suboffsets(self):             # <<<<<<<<<<<<<<
27016  *         if self.view.suboffsets == NULL:
27017  *             return (-1,) * self.view.ndim
27018  */
27019 
27020 /* Python wrapper */
27021 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)27022 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) {
27023   PyObject *__pyx_r = 0;
27024   __Pyx_RefNannyDeclarations
27025   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
27026   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
27027 
27028   /* function exit code */
27029   __Pyx_RefNannyFinishContext();
27030   return __pyx_r;
27031 }
27032 
__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj * __pyx_v_self)27033 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
27034   Py_ssize_t __pyx_v_suboffset;
27035   PyObject *__pyx_r = NULL;
27036   __Pyx_RefNannyDeclarations
27037   int __pyx_t_1;
27038   PyObject *__pyx_t_2 = NULL;
27039   PyObject *__pyx_t_3 = NULL;
27040   Py_ssize_t *__pyx_t_4;
27041   Py_ssize_t *__pyx_t_5;
27042   Py_ssize_t *__pyx_t_6;
27043   int __pyx_lineno = 0;
27044   const char *__pyx_filename = NULL;
27045   int __pyx_clineno = 0;
27046   __Pyx_RefNannySetupContext("__get__", 0);
27047 
27048   /* "View.MemoryView":576
27049  *     @property
27050  *     def suboffsets(self):
27051  *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
27052  *             return (-1,) * self.view.ndim
27053  *
27054  */
27055   __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0);
27056   if (__pyx_t_1) {
27057 
27058     /* "View.MemoryView":577
27059  *     def suboffsets(self):
27060  *         if self.view.suboffsets == NULL:
27061  *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
27062  *
27063  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
27064  */
27065     __Pyx_XDECREF(__pyx_r);
27066     __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 577, __pyx_L1_error)
27067     __Pyx_GOTREF(__pyx_t_2);
27068     __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__21, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 577, __pyx_L1_error)
27069     __Pyx_GOTREF(__pyx_t_3);
27070     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27071     __pyx_r = __pyx_t_3;
27072     __pyx_t_3 = 0;
27073     goto __pyx_L0;
27074 
27075     /* "View.MemoryView":576
27076  *     @property
27077  *     def suboffsets(self):
27078  *         if self.view.suboffsets == NULL:             # <<<<<<<<<<<<<<
27079  *             return (-1,) * self.view.ndim
27080  *
27081  */
27082   }
27083 
27084   /* "View.MemoryView":579
27085  *             return (-1,) * self.view.ndim
27086  *
27087  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])             # <<<<<<<<<<<<<<
27088  *
27089  *     @property
27090  */
27091   __Pyx_XDECREF(__pyx_r);
27092   __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 579, __pyx_L1_error)
27093   __Pyx_GOTREF(__pyx_t_3);
27094   __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim);
27095   for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) {
27096     __pyx_t_4 = __pyx_t_6;
27097     __pyx_v_suboffset = (__pyx_t_4[0]);
27098     __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 579, __pyx_L1_error)
27099     __Pyx_GOTREF(__pyx_t_2);
27100     if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(2, 579, __pyx_L1_error)
27101     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27102   }
27103   __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 579, __pyx_L1_error)
27104   __Pyx_GOTREF(__pyx_t_2);
27105   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
27106   __pyx_r = __pyx_t_2;
27107   __pyx_t_2 = 0;
27108   goto __pyx_L0;
27109 
27110   /* "View.MemoryView":575
27111  *
27112  *     @property
27113  *     def suboffsets(self):             # <<<<<<<<<<<<<<
27114  *         if self.view.suboffsets == NULL:
27115  *             return (-1,) * self.view.ndim
27116  */
27117 
27118   /* function exit code */
27119   __pyx_L1_error:;
27120   __Pyx_XDECREF(__pyx_t_2);
27121   __Pyx_XDECREF(__pyx_t_3);
27122   __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
27123   __pyx_r = NULL;
27124   __pyx_L0:;
27125   __Pyx_XGIVEREF(__pyx_r);
27126   __Pyx_RefNannyFinishContext();
27127   return __pyx_r;
27128 }
27129 
27130 /* "View.MemoryView":582
27131  *
27132  *     @property
27133  *     def ndim(self):             # <<<<<<<<<<<<<<
27134  *         return self.view.ndim
27135  *
27136  */
27137 
27138 /* Python wrapper */
27139 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)27140 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) {
27141   PyObject *__pyx_r = 0;
27142   __Pyx_RefNannyDeclarations
27143   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
27144   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
27145 
27146   /* function exit code */
27147   __Pyx_RefNannyFinishContext();
27148   return __pyx_r;
27149 }
27150 
__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj * __pyx_v_self)27151 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
27152   PyObject *__pyx_r = NULL;
27153   __Pyx_RefNannyDeclarations
27154   PyObject *__pyx_t_1 = NULL;
27155   int __pyx_lineno = 0;
27156   const char *__pyx_filename = NULL;
27157   int __pyx_clineno = 0;
27158   __Pyx_RefNannySetupContext("__get__", 0);
27159 
27160   /* "View.MemoryView":583
27161  *     @property
27162  *     def ndim(self):
27163  *         return self.view.ndim             # <<<<<<<<<<<<<<
27164  *
27165  *     @property
27166  */
27167   __Pyx_XDECREF(__pyx_r);
27168   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 583, __pyx_L1_error)
27169   __Pyx_GOTREF(__pyx_t_1);
27170   __pyx_r = __pyx_t_1;
27171   __pyx_t_1 = 0;
27172   goto __pyx_L0;
27173 
27174   /* "View.MemoryView":582
27175  *
27176  *     @property
27177  *     def ndim(self):             # <<<<<<<<<<<<<<
27178  *         return self.view.ndim
27179  *
27180  */
27181 
27182   /* function exit code */
27183   __pyx_L1_error:;
27184   __Pyx_XDECREF(__pyx_t_1);
27185   __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
27186   __pyx_r = NULL;
27187   __pyx_L0:;
27188   __Pyx_XGIVEREF(__pyx_r);
27189   __Pyx_RefNannyFinishContext();
27190   return __pyx_r;
27191 }
27192 
27193 /* "View.MemoryView":586
27194  *
27195  *     @property
27196  *     def itemsize(self):             # <<<<<<<<<<<<<<
27197  *         return self.view.itemsize
27198  *
27199  */
27200 
27201 /* Python wrapper */
27202 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)27203 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) {
27204   PyObject *__pyx_r = 0;
27205   __Pyx_RefNannyDeclarations
27206   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
27207   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
27208 
27209   /* function exit code */
27210   __Pyx_RefNannyFinishContext();
27211   return __pyx_r;
27212 }
27213 
__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj * __pyx_v_self)27214 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
27215   PyObject *__pyx_r = NULL;
27216   __Pyx_RefNannyDeclarations
27217   PyObject *__pyx_t_1 = NULL;
27218   int __pyx_lineno = 0;
27219   const char *__pyx_filename = NULL;
27220   int __pyx_clineno = 0;
27221   __Pyx_RefNannySetupContext("__get__", 0);
27222 
27223   /* "View.MemoryView":587
27224  *     @property
27225  *     def itemsize(self):
27226  *         return self.view.itemsize             # <<<<<<<<<<<<<<
27227  *
27228  *     @property
27229  */
27230   __Pyx_XDECREF(__pyx_r);
27231   __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 587, __pyx_L1_error)
27232   __Pyx_GOTREF(__pyx_t_1);
27233   __pyx_r = __pyx_t_1;
27234   __pyx_t_1 = 0;
27235   goto __pyx_L0;
27236 
27237   /* "View.MemoryView":586
27238  *
27239  *     @property
27240  *     def itemsize(self):             # <<<<<<<<<<<<<<
27241  *         return self.view.itemsize
27242  *
27243  */
27244 
27245   /* function exit code */
27246   __pyx_L1_error:;
27247   __Pyx_XDECREF(__pyx_t_1);
27248   __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
27249   __pyx_r = NULL;
27250   __pyx_L0:;
27251   __Pyx_XGIVEREF(__pyx_r);
27252   __Pyx_RefNannyFinishContext();
27253   return __pyx_r;
27254 }
27255 
27256 /* "View.MemoryView":590
27257  *
27258  *     @property
27259  *     def nbytes(self):             # <<<<<<<<<<<<<<
27260  *         return self.size * self.view.itemsize
27261  *
27262  */
27263 
27264 /* Python wrapper */
27265 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)27266 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) {
27267   PyObject *__pyx_r = 0;
27268   __Pyx_RefNannyDeclarations
27269   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
27270   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
27271 
27272   /* function exit code */
27273   __Pyx_RefNannyFinishContext();
27274   return __pyx_r;
27275 }
27276 
__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj * __pyx_v_self)27277 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
27278   PyObject *__pyx_r = NULL;
27279   __Pyx_RefNannyDeclarations
27280   PyObject *__pyx_t_1 = NULL;
27281   PyObject *__pyx_t_2 = NULL;
27282   PyObject *__pyx_t_3 = NULL;
27283   int __pyx_lineno = 0;
27284   const char *__pyx_filename = NULL;
27285   int __pyx_clineno = 0;
27286   __Pyx_RefNannySetupContext("__get__", 0);
27287 
27288   /* "View.MemoryView":591
27289  *     @property
27290  *     def nbytes(self):
27291  *         return self.size * self.view.itemsize             # <<<<<<<<<<<<<<
27292  *
27293  *     @property
27294  */
27295   __Pyx_XDECREF(__pyx_r);
27296   __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)
27297   __Pyx_GOTREF(__pyx_t_1);
27298   __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 591, __pyx_L1_error)
27299   __Pyx_GOTREF(__pyx_t_2);
27300   __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 591, __pyx_L1_error)
27301   __Pyx_GOTREF(__pyx_t_3);
27302   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
27303   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27304   __pyx_r = __pyx_t_3;
27305   __pyx_t_3 = 0;
27306   goto __pyx_L0;
27307 
27308   /* "View.MemoryView":590
27309  *
27310  *     @property
27311  *     def nbytes(self):             # <<<<<<<<<<<<<<
27312  *         return self.size * self.view.itemsize
27313  *
27314  */
27315 
27316   /* function exit code */
27317   __pyx_L1_error:;
27318   __Pyx_XDECREF(__pyx_t_1);
27319   __Pyx_XDECREF(__pyx_t_2);
27320   __Pyx_XDECREF(__pyx_t_3);
27321   __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
27322   __pyx_r = NULL;
27323   __pyx_L0:;
27324   __Pyx_XGIVEREF(__pyx_r);
27325   __Pyx_RefNannyFinishContext();
27326   return __pyx_r;
27327 }
27328 
27329 /* "View.MemoryView":594
27330  *
27331  *     @property
27332  *     def size(self):             # <<<<<<<<<<<<<<
27333  *         if self._size is None:
27334  *             result = 1
27335  */
27336 
27337 /* Python wrapper */
27338 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)27339 static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) {
27340   PyObject *__pyx_r = 0;
27341   __Pyx_RefNannyDeclarations
27342   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
27343   __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
27344 
27345   /* function exit code */
27346   __Pyx_RefNannyFinishContext();
27347   return __pyx_r;
27348 }
27349 
__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj * __pyx_v_self)27350 static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
27351   PyObject *__pyx_v_result = NULL;
27352   PyObject *__pyx_v_length = NULL;
27353   PyObject *__pyx_r = NULL;
27354   __Pyx_RefNannyDeclarations
27355   int __pyx_t_1;
27356   int __pyx_t_2;
27357   Py_ssize_t *__pyx_t_3;
27358   Py_ssize_t *__pyx_t_4;
27359   Py_ssize_t *__pyx_t_5;
27360   PyObject *__pyx_t_6 = NULL;
27361   int __pyx_lineno = 0;
27362   const char *__pyx_filename = NULL;
27363   int __pyx_clineno = 0;
27364   __Pyx_RefNannySetupContext("__get__", 0);
27365 
27366   /* "View.MemoryView":595
27367  *     @property
27368  *     def size(self):
27369  *         if self._size is None:             # <<<<<<<<<<<<<<
27370  *             result = 1
27371  *
27372  */
27373   __pyx_t_1 = (__pyx_v_self->_size == Py_None);
27374   __pyx_t_2 = (__pyx_t_1 != 0);
27375   if (__pyx_t_2) {
27376 
27377     /* "View.MemoryView":596
27378  *     def size(self):
27379  *         if self._size is None:
27380  *             result = 1             # <<<<<<<<<<<<<<
27381  *
27382  *             for length in self.view.shape[:self.view.ndim]:
27383  */
27384     __Pyx_INCREF(__pyx_int_1);
27385     __pyx_v_result = __pyx_int_1;
27386 
27387     /* "View.MemoryView":598
27388  *             result = 1
27389  *
27390  *             for length in self.view.shape[:self.view.ndim]:             # <<<<<<<<<<<<<<
27391  *                 result *= length
27392  *
27393  */
27394     __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
27395     for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
27396       __pyx_t_3 = __pyx_t_5;
27397       __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 598, __pyx_L1_error)
27398       __Pyx_GOTREF(__pyx_t_6);
27399       __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
27400       __pyx_t_6 = 0;
27401 
27402       /* "View.MemoryView":599
27403  *
27404  *             for length in self.view.shape[:self.view.ndim]:
27405  *                 result *= length             # <<<<<<<<<<<<<<
27406  *
27407  *             self._size = result
27408  */
27409       __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 599, __pyx_L1_error)
27410       __Pyx_GOTREF(__pyx_t_6);
27411       __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
27412       __pyx_t_6 = 0;
27413     }
27414 
27415     /* "View.MemoryView":601
27416  *                 result *= length
27417  *
27418  *             self._size = result             # <<<<<<<<<<<<<<
27419  *
27420  *         return self._size
27421  */
27422     __Pyx_INCREF(__pyx_v_result);
27423     __Pyx_GIVEREF(__pyx_v_result);
27424     __Pyx_GOTREF(__pyx_v_self->_size);
27425     __Pyx_DECREF(__pyx_v_self->_size);
27426     __pyx_v_self->_size = __pyx_v_result;
27427 
27428     /* "View.MemoryView":595
27429  *     @property
27430  *     def size(self):
27431  *         if self._size is None:             # <<<<<<<<<<<<<<
27432  *             result = 1
27433  *
27434  */
27435   }
27436 
27437   /* "View.MemoryView":603
27438  *             self._size = result
27439  *
27440  *         return self._size             # <<<<<<<<<<<<<<
27441  *
27442  *     def __len__(self):
27443  */
27444   __Pyx_XDECREF(__pyx_r);
27445   __Pyx_INCREF(__pyx_v_self->_size);
27446   __pyx_r = __pyx_v_self->_size;
27447   goto __pyx_L0;
27448 
27449   /* "View.MemoryView":594
27450  *
27451  *     @property
27452  *     def size(self):             # <<<<<<<<<<<<<<
27453  *         if self._size is None:
27454  *             result = 1
27455  */
27456 
27457   /* function exit code */
27458   __pyx_L1_error:;
27459   __Pyx_XDECREF(__pyx_t_6);
27460   __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
27461   __pyx_r = NULL;
27462   __pyx_L0:;
27463   __Pyx_XDECREF(__pyx_v_result);
27464   __Pyx_XDECREF(__pyx_v_length);
27465   __Pyx_XGIVEREF(__pyx_r);
27466   __Pyx_RefNannyFinishContext();
27467   return __pyx_r;
27468 }
27469 
27470 /* "View.MemoryView":605
27471  *         return self._size
27472  *
27473  *     def __len__(self):             # <<<<<<<<<<<<<<
27474  *         if self.view.ndim >= 1:
27475  *             return self.view.shape[0]
27476  */
27477 
27478 /* Python wrapper */
27479 static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___len__(PyObject * __pyx_v_self)27480 static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
27481   Py_ssize_t __pyx_r;
27482   __Pyx_RefNannyDeclarations
27483   __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
27484   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self));
27485 
27486   /* function exit code */
27487   __Pyx_RefNannyFinishContext();
27488   return __pyx_r;
27489 }
27490 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj * __pyx_v_self)27491 static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) {
27492   Py_ssize_t __pyx_r;
27493   __Pyx_RefNannyDeclarations
27494   int __pyx_t_1;
27495   __Pyx_RefNannySetupContext("__len__", 0);
27496 
27497   /* "View.MemoryView":606
27498  *
27499  *     def __len__(self):
27500  *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
27501  *             return self.view.shape[0]
27502  *
27503  */
27504   __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0);
27505   if (__pyx_t_1) {
27506 
27507     /* "View.MemoryView":607
27508  *     def __len__(self):
27509  *         if self.view.ndim >= 1:
27510  *             return self.view.shape[0]             # <<<<<<<<<<<<<<
27511  *
27512  *         return 0
27513  */
27514     __pyx_r = (__pyx_v_self->view.shape[0]);
27515     goto __pyx_L0;
27516 
27517     /* "View.MemoryView":606
27518  *
27519  *     def __len__(self):
27520  *         if self.view.ndim >= 1:             # <<<<<<<<<<<<<<
27521  *             return self.view.shape[0]
27522  *
27523  */
27524   }
27525 
27526   /* "View.MemoryView":609
27527  *             return self.view.shape[0]
27528  *
27529  *         return 0             # <<<<<<<<<<<<<<
27530  *
27531  *     def __repr__(self):
27532  */
27533   __pyx_r = 0;
27534   goto __pyx_L0;
27535 
27536   /* "View.MemoryView":605
27537  *         return self._size
27538  *
27539  *     def __len__(self):             # <<<<<<<<<<<<<<
27540  *         if self.view.ndim >= 1:
27541  *             return self.view.shape[0]
27542  */
27543 
27544   /* function exit code */
27545   __pyx_L0:;
27546   __Pyx_RefNannyFinishContext();
27547   return __pyx_r;
27548 }
27549 
27550 /* "View.MemoryView":611
27551  *         return 0
27552  *
27553  *     def __repr__(self):             # <<<<<<<<<<<<<<
27554  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
27555  *                                                id(self))
27556  */
27557 
27558 /* Python wrapper */
27559 static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___repr__(PyObject * __pyx_v_self)27560 static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
27561   PyObject *__pyx_r = 0;
27562   __Pyx_RefNannyDeclarations
27563   __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
27564   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self));
27565 
27566   /* function exit code */
27567   __Pyx_RefNannyFinishContext();
27568   return __pyx_r;
27569 }
27570 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj * __pyx_v_self)27571 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) {
27572   PyObject *__pyx_r = NULL;
27573   __Pyx_RefNannyDeclarations
27574   PyObject *__pyx_t_1 = NULL;
27575   PyObject *__pyx_t_2 = NULL;
27576   PyObject *__pyx_t_3 = NULL;
27577   int __pyx_lineno = 0;
27578   const char *__pyx_filename = NULL;
27579   int __pyx_clineno = 0;
27580   __Pyx_RefNannySetupContext("__repr__", 0);
27581 
27582   /* "View.MemoryView":612
27583  *
27584  *     def __repr__(self):
27585  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
27586  *                                                id(self))
27587  *
27588  */
27589   __Pyx_XDECREF(__pyx_r);
27590   __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)
27591   __Pyx_GOTREF(__pyx_t_1);
27592   __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)
27593   __Pyx_GOTREF(__pyx_t_2);
27594   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
27595   __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)
27596   __Pyx_GOTREF(__pyx_t_1);
27597   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27598 
27599   /* "View.MemoryView":613
27600  *     def __repr__(self):
27601  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
27602  *                                                id(self))             # <<<<<<<<<<<<<<
27603  *
27604  *     def __str__(self):
27605  */
27606   __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)
27607   __Pyx_GOTREF(__pyx_t_2);
27608 
27609   /* "View.MemoryView":612
27610  *
27611  *     def __repr__(self):
27612  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,             # <<<<<<<<<<<<<<
27613  *                                                id(self))
27614  *
27615  */
27616   __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 612, __pyx_L1_error)
27617   __Pyx_GOTREF(__pyx_t_3);
27618   __Pyx_GIVEREF(__pyx_t_1);
27619   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
27620   __Pyx_GIVEREF(__pyx_t_2);
27621   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
27622   __pyx_t_1 = 0;
27623   __pyx_t_2 = 0;
27624   __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)
27625   __Pyx_GOTREF(__pyx_t_2);
27626   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
27627   __pyx_r = __pyx_t_2;
27628   __pyx_t_2 = 0;
27629   goto __pyx_L0;
27630 
27631   /* "View.MemoryView":611
27632  *         return 0
27633  *
27634  *     def __repr__(self):             # <<<<<<<<<<<<<<
27635  *         return "<MemoryView of %r at 0x%x>" % (self.base.__class__.__name__,
27636  *                                                id(self))
27637  */
27638 
27639   /* function exit code */
27640   __pyx_L1_error:;
27641   __Pyx_XDECREF(__pyx_t_1);
27642   __Pyx_XDECREF(__pyx_t_2);
27643   __Pyx_XDECREF(__pyx_t_3);
27644   __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
27645   __pyx_r = NULL;
27646   __pyx_L0:;
27647   __Pyx_XGIVEREF(__pyx_r);
27648   __Pyx_RefNannyFinishContext();
27649   return __pyx_r;
27650 }
27651 
27652 /* "View.MemoryView":615
27653  *                                                id(self))
27654  *
27655  *     def __str__(self):             # <<<<<<<<<<<<<<
27656  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
27657  *
27658  */
27659 
27660 /* Python wrapper */
27661 static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryview___str__(PyObject * __pyx_v_self)27662 static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
27663   PyObject *__pyx_r = 0;
27664   __Pyx_RefNannyDeclarations
27665   __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
27666   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self));
27667 
27668   /* function exit code */
27669   __Pyx_RefNannyFinishContext();
27670   return __pyx_r;
27671 }
27672 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj * __pyx_v_self)27673 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) {
27674   PyObject *__pyx_r = NULL;
27675   __Pyx_RefNannyDeclarations
27676   PyObject *__pyx_t_1 = NULL;
27677   PyObject *__pyx_t_2 = NULL;
27678   int __pyx_lineno = 0;
27679   const char *__pyx_filename = NULL;
27680   int __pyx_clineno = 0;
27681   __Pyx_RefNannySetupContext("__str__", 0);
27682 
27683   /* "View.MemoryView":616
27684  *
27685  *     def __str__(self):
27686  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)             # <<<<<<<<<<<<<<
27687  *
27688  *
27689  */
27690   __Pyx_XDECREF(__pyx_r);
27691   __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)
27692   __Pyx_GOTREF(__pyx_t_1);
27693   __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)
27694   __Pyx_GOTREF(__pyx_t_2);
27695   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
27696   __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)
27697   __Pyx_GOTREF(__pyx_t_1);
27698   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27699   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 616, __pyx_L1_error)
27700   __Pyx_GOTREF(__pyx_t_2);
27701   __Pyx_GIVEREF(__pyx_t_1);
27702   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
27703   __pyx_t_1 = 0;
27704   __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)
27705   __Pyx_GOTREF(__pyx_t_1);
27706   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27707   __pyx_r = __pyx_t_1;
27708   __pyx_t_1 = 0;
27709   goto __pyx_L0;
27710 
27711   /* "View.MemoryView":615
27712  *                                                id(self))
27713  *
27714  *     def __str__(self):             # <<<<<<<<<<<<<<
27715  *         return "<MemoryView of %r object>" % (self.base.__class__.__name__,)
27716  *
27717  */
27718 
27719   /* function exit code */
27720   __pyx_L1_error:;
27721   __Pyx_XDECREF(__pyx_t_1);
27722   __Pyx_XDECREF(__pyx_t_2);
27723   __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
27724   __pyx_r = NULL;
27725   __pyx_L0:;
27726   __Pyx_XGIVEREF(__pyx_r);
27727   __Pyx_RefNannyFinishContext();
27728   return __pyx_r;
27729 }
27730 
27731 /* "View.MemoryView":619
27732  *
27733  *
27734  *     def is_c_contig(self):             # <<<<<<<<<<<<<<
27735  *         cdef __Pyx_memviewslice *mslice
27736  *         cdef __Pyx_memviewslice tmp
27737  */
27738 
27739 /* Python wrapper */
27740 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)27741 static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
27742   PyObject *__pyx_r = 0;
27743   __Pyx_RefNannyDeclarations
27744   __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0);
27745   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
27746 
27747   /* function exit code */
27748   __Pyx_RefNannyFinishContext();
27749   return __pyx_r;
27750 }
27751 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj * __pyx_v_self)27752 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
27753   __Pyx_memviewslice *__pyx_v_mslice;
27754   __Pyx_memviewslice __pyx_v_tmp;
27755   PyObject *__pyx_r = NULL;
27756   __Pyx_RefNannyDeclarations
27757   __Pyx_memviewslice *__pyx_t_1;
27758   PyObject *__pyx_t_2 = NULL;
27759   int __pyx_lineno = 0;
27760   const char *__pyx_filename = NULL;
27761   int __pyx_clineno = 0;
27762   __Pyx_RefNannySetupContext("is_c_contig", 0);
27763 
27764   /* "View.MemoryView":622
27765  *         cdef __Pyx_memviewslice *mslice
27766  *         cdef __Pyx_memviewslice tmp
27767  *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
27768  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
27769  *
27770  */
27771   __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)
27772   __pyx_v_mslice = __pyx_t_1;
27773 
27774   /* "View.MemoryView":623
27775  *         cdef __Pyx_memviewslice tmp
27776  *         mslice = get_slice_from_memview(self, &tmp)
27777  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)             # <<<<<<<<<<<<<<
27778  *
27779  *     def is_f_contig(self):
27780  */
27781   __Pyx_XDECREF(__pyx_r);
27782   __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)
27783   __Pyx_GOTREF(__pyx_t_2);
27784   __pyx_r = __pyx_t_2;
27785   __pyx_t_2 = 0;
27786   goto __pyx_L0;
27787 
27788   /* "View.MemoryView":619
27789  *
27790  *
27791  *     def is_c_contig(self):             # <<<<<<<<<<<<<<
27792  *         cdef __Pyx_memviewslice *mslice
27793  *         cdef __Pyx_memviewslice tmp
27794  */
27795 
27796   /* function exit code */
27797   __pyx_L1_error:;
27798   __Pyx_XDECREF(__pyx_t_2);
27799   __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
27800   __pyx_r = NULL;
27801   __pyx_L0:;
27802   __Pyx_XGIVEREF(__pyx_r);
27803   __Pyx_RefNannyFinishContext();
27804   return __pyx_r;
27805 }
27806 
27807 /* "View.MemoryView":625
27808  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
27809  *
27810  *     def is_f_contig(self):             # <<<<<<<<<<<<<<
27811  *         cdef __Pyx_memviewslice *mslice
27812  *         cdef __Pyx_memviewslice tmp
27813  */
27814 
27815 /* Python wrapper */
27816 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)27817 static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
27818   PyObject *__pyx_r = 0;
27819   __Pyx_RefNannyDeclarations
27820   __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0);
27821   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
27822 
27823   /* function exit code */
27824   __Pyx_RefNannyFinishContext();
27825   return __pyx_r;
27826 }
27827 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj * __pyx_v_self)27828 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
27829   __Pyx_memviewslice *__pyx_v_mslice;
27830   __Pyx_memviewslice __pyx_v_tmp;
27831   PyObject *__pyx_r = NULL;
27832   __Pyx_RefNannyDeclarations
27833   __Pyx_memviewslice *__pyx_t_1;
27834   PyObject *__pyx_t_2 = NULL;
27835   int __pyx_lineno = 0;
27836   const char *__pyx_filename = NULL;
27837   int __pyx_clineno = 0;
27838   __Pyx_RefNannySetupContext("is_f_contig", 0);
27839 
27840   /* "View.MemoryView":628
27841  *         cdef __Pyx_memviewslice *mslice
27842  *         cdef __Pyx_memviewslice tmp
27843  *         mslice = get_slice_from_memview(self, &tmp)             # <<<<<<<<<<<<<<
27844  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
27845  *
27846  */
27847   __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)
27848   __pyx_v_mslice = __pyx_t_1;
27849 
27850   /* "View.MemoryView":629
27851  *         cdef __Pyx_memviewslice tmp
27852  *         mslice = get_slice_from_memview(self, &tmp)
27853  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)             # <<<<<<<<<<<<<<
27854  *
27855  *     def copy(self):
27856  */
27857   __Pyx_XDECREF(__pyx_r);
27858   __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)
27859   __Pyx_GOTREF(__pyx_t_2);
27860   __pyx_r = __pyx_t_2;
27861   __pyx_t_2 = 0;
27862   goto __pyx_L0;
27863 
27864   /* "View.MemoryView":625
27865  *         return slice_is_contig(mslice[0], 'C', self.view.ndim)
27866  *
27867  *     def is_f_contig(self):             # <<<<<<<<<<<<<<
27868  *         cdef __Pyx_memviewslice *mslice
27869  *         cdef __Pyx_memviewslice tmp
27870  */
27871 
27872   /* function exit code */
27873   __pyx_L1_error:;
27874   __Pyx_XDECREF(__pyx_t_2);
27875   __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
27876   __pyx_r = NULL;
27877   __pyx_L0:;
27878   __Pyx_XGIVEREF(__pyx_r);
27879   __Pyx_RefNannyFinishContext();
27880   return __pyx_r;
27881 }
27882 
27883 /* "View.MemoryView":631
27884  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
27885  *
27886  *     def copy(self):             # <<<<<<<<<<<<<<
27887  *         cdef __Pyx_memviewslice mslice
27888  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
27889  */
27890 
27891 /* Python wrapper */
27892 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)27893 static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
27894   PyObject *__pyx_r = 0;
27895   __Pyx_RefNannyDeclarations
27896   __Pyx_RefNannySetupContext("copy (wrapper)", 0);
27897   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self));
27898 
27899   /* function exit code */
27900   __Pyx_RefNannyFinishContext();
27901   return __pyx_r;
27902 }
27903 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj * __pyx_v_self)27904 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) {
27905   __Pyx_memviewslice __pyx_v_mslice;
27906   int __pyx_v_flags;
27907   PyObject *__pyx_r = NULL;
27908   __Pyx_RefNannyDeclarations
27909   __Pyx_memviewslice __pyx_t_1;
27910   PyObject *__pyx_t_2 = NULL;
27911   int __pyx_lineno = 0;
27912   const char *__pyx_filename = NULL;
27913   int __pyx_clineno = 0;
27914   __Pyx_RefNannySetupContext("copy", 0);
27915 
27916   /* "View.MemoryView":633
27917  *     def copy(self):
27918  *         cdef __Pyx_memviewslice mslice
27919  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS             # <<<<<<<<<<<<<<
27920  *
27921  *         slice_copy(self, &mslice)
27922  */
27923   __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS));
27924 
27925   /* "View.MemoryView":635
27926  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
27927  *
27928  *         slice_copy(self, &mslice)             # <<<<<<<<<<<<<<
27929  *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,
27930  *                                    self.view.itemsize,
27931  */
27932   __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice));
27933 
27934   /* "View.MemoryView":636
27935  *
27936  *         slice_copy(self, &mslice)
27937  *         mslice = slice_copy_contig(&mslice, "c", self.view.ndim,             # <<<<<<<<<<<<<<
27938  *                                    self.view.itemsize,
27939  *                                    flags|PyBUF_C_CONTIGUOUS,
27940  */
27941   __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)
27942   __pyx_v_mslice = __pyx_t_1;
27943 
27944   /* "View.MemoryView":641
27945  *                                    self.dtype_is_object)
27946  *
27947  *         return memoryview_copy_from_slice(self, &mslice)             # <<<<<<<<<<<<<<
27948  *
27949  *     def copy_fortran(self):
27950  */
27951   __Pyx_XDECREF(__pyx_r);
27952   __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)
27953   __Pyx_GOTREF(__pyx_t_2);
27954   __pyx_r = __pyx_t_2;
27955   __pyx_t_2 = 0;
27956   goto __pyx_L0;
27957 
27958   /* "View.MemoryView":631
27959  *         return slice_is_contig(mslice[0], 'F', self.view.ndim)
27960  *
27961  *     def copy(self):             # <<<<<<<<<<<<<<
27962  *         cdef __Pyx_memviewslice mslice
27963  *         cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
27964  */
27965 
27966   /* function exit code */
27967   __pyx_L1_error:;
27968   __Pyx_XDECREF(__pyx_t_2);
27969   __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
27970   __pyx_r = NULL;
27971   __pyx_L0:;
27972   __Pyx_XGIVEREF(__pyx_r);
27973   __Pyx_RefNannyFinishContext();
27974   return __pyx_r;
27975 }
27976 
27977 /* "View.MemoryView":643
27978  *         return memoryview_copy_from_slice(self, &mslice)
27979  *
27980  *     def copy_fortran(self):             # <<<<<<<<<<<<<<
27981  *         cdef __Pyx_memviewslice src, dst
27982  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
27983  */
27984 
27985 /* Python wrapper */
27986 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)27987 static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
27988   PyObject *__pyx_r = 0;
27989   __Pyx_RefNannyDeclarations
27990   __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0);
27991   __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self));
27992 
27993   /* function exit code */
27994   __Pyx_RefNannyFinishContext();
27995   return __pyx_r;
27996 }
27997 
__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj * __pyx_v_self)27998 static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) {
27999   __Pyx_memviewslice __pyx_v_src;
28000   __Pyx_memviewslice __pyx_v_dst;
28001   int __pyx_v_flags;
28002   PyObject *__pyx_r = NULL;
28003   __Pyx_RefNannyDeclarations
28004   __Pyx_memviewslice __pyx_t_1;
28005   PyObject *__pyx_t_2 = NULL;
28006   int __pyx_lineno = 0;
28007   const char *__pyx_filename = NULL;
28008   int __pyx_clineno = 0;
28009   __Pyx_RefNannySetupContext("copy_fortran", 0);
28010 
28011   /* "View.MemoryView":645
28012  *     def copy_fortran(self):
28013  *         cdef __Pyx_memviewslice src, dst
28014  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS             # <<<<<<<<<<<<<<
28015  *
28016  *         slice_copy(self, &src)
28017  */
28018   __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS));
28019 
28020   /* "View.MemoryView":647
28021  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
28022  *
28023  *         slice_copy(self, &src)             # <<<<<<<<<<<<<<
28024  *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,
28025  *                                 self.view.itemsize,
28026  */
28027   __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src));
28028 
28029   /* "View.MemoryView":648
28030  *
28031  *         slice_copy(self, &src)
28032  *         dst = slice_copy_contig(&src, "fortran", self.view.ndim,             # <<<<<<<<<<<<<<
28033  *                                 self.view.itemsize,
28034  *                                 flags|PyBUF_F_CONTIGUOUS,
28035  */
28036   __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)
28037   __pyx_v_dst = __pyx_t_1;
28038 
28039   /* "View.MemoryView":653
28040  *                                 self.dtype_is_object)
28041  *
28042  *         return memoryview_copy_from_slice(self, &dst)             # <<<<<<<<<<<<<<
28043  *
28044  *
28045  */
28046   __Pyx_XDECREF(__pyx_r);
28047   __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)
28048   __Pyx_GOTREF(__pyx_t_2);
28049   __pyx_r = __pyx_t_2;
28050   __pyx_t_2 = 0;
28051   goto __pyx_L0;
28052 
28053   /* "View.MemoryView":643
28054  *         return memoryview_copy_from_slice(self, &mslice)
28055  *
28056  *     def copy_fortran(self):             # <<<<<<<<<<<<<<
28057  *         cdef __Pyx_memviewslice src, dst
28058  *         cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
28059  */
28060 
28061   /* function exit code */
28062   __pyx_L1_error:;
28063   __Pyx_XDECREF(__pyx_t_2);
28064   __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename);
28065   __pyx_r = NULL;
28066   __pyx_L0:;
28067   __Pyx_XGIVEREF(__pyx_r);
28068   __Pyx_RefNannyFinishContext();
28069   return __pyx_r;
28070 }
28071 
28072 /* "(tree fragment)":1
28073  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
28074  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28075  * def __setstate_cython__(self, __pyx_state):
28076  */
28077 
28078 /* Python wrapper */
28079 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)28080 static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
28081   PyObject *__pyx_r = 0;
28082   __Pyx_RefNannyDeclarations
28083   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
28084   __pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self));
28085 
28086   /* function exit code */
28087   __Pyx_RefNannyFinishContext();
28088   return __pyx_r;
28089 }
28090 
__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj * __pyx_v_self)28091 static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) {
28092   PyObject *__pyx_r = NULL;
28093   __Pyx_RefNannyDeclarations
28094   PyObject *__pyx_t_1 = NULL;
28095   int __pyx_lineno = 0;
28096   const char *__pyx_filename = NULL;
28097   int __pyx_clineno = 0;
28098   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
28099 
28100   /* "(tree fragment)":2
28101  * def __reduce_cython__(self):
28102  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
28103  * def __setstate_cython__(self, __pyx_state):
28104  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28105  */
28106   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
28107   __Pyx_GOTREF(__pyx_t_1);
28108   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
28109   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28110   __PYX_ERR(2, 2, __pyx_L1_error)
28111 
28112   /* "(tree fragment)":1
28113  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
28114  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28115  * def __setstate_cython__(self, __pyx_state):
28116  */
28117 
28118   /* function exit code */
28119   __pyx_L1_error:;
28120   __Pyx_XDECREF(__pyx_t_1);
28121   __Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
28122   __pyx_r = NULL;
28123   __Pyx_XGIVEREF(__pyx_r);
28124   __Pyx_RefNannyFinishContext();
28125   return __pyx_r;
28126 }
28127 
28128 /* "(tree fragment)":3
28129  * def __reduce_cython__(self):
28130  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28131  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
28132  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28133  */
28134 
28135 /* Python wrapper */
28136 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)28137 static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
28138   PyObject *__pyx_r = 0;
28139   __Pyx_RefNannyDeclarations
28140   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
28141   __pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
28142 
28143   /* function exit code */
28144   __Pyx_RefNannyFinishContext();
28145   return __pyx_r;
28146 }
28147 
__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)28148 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) {
28149   PyObject *__pyx_r = NULL;
28150   __Pyx_RefNannyDeclarations
28151   PyObject *__pyx_t_1 = NULL;
28152   int __pyx_lineno = 0;
28153   const char *__pyx_filename = NULL;
28154   int __pyx_clineno = 0;
28155   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
28156 
28157   /* "(tree fragment)":4
28158  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28159  * def __setstate_cython__(self, __pyx_state):
28160  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
28161  */
28162   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
28163   __Pyx_GOTREF(__pyx_t_1);
28164   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
28165   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28166   __PYX_ERR(2, 4, __pyx_L1_error)
28167 
28168   /* "(tree fragment)":3
28169  * def __reduce_cython__(self):
28170  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28171  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
28172  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
28173  */
28174 
28175   /* function exit code */
28176   __pyx_L1_error:;
28177   __Pyx_XDECREF(__pyx_t_1);
28178   __Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
28179   __pyx_r = NULL;
28180   __Pyx_XGIVEREF(__pyx_r);
28181   __Pyx_RefNannyFinishContext();
28182   return __pyx_r;
28183 }
28184 
28185 /* "View.MemoryView":657
28186  *
28187  * @cname('__pyx_memoryview_new')
28188  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
28189  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
28190  *     result.typeinfo = typeinfo
28191  */
28192 
__pyx_memoryview_new(PyObject * __pyx_v_o,int __pyx_v_flags,int __pyx_v_dtype_is_object,__Pyx_TypeInfo * __pyx_v_typeinfo)28193 static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) {
28194   struct __pyx_memoryview_obj *__pyx_v_result = 0;
28195   PyObject *__pyx_r = NULL;
28196   __Pyx_RefNannyDeclarations
28197   PyObject *__pyx_t_1 = NULL;
28198   PyObject *__pyx_t_2 = NULL;
28199   PyObject *__pyx_t_3 = NULL;
28200   int __pyx_lineno = 0;
28201   const char *__pyx_filename = NULL;
28202   int __pyx_clineno = 0;
28203   __Pyx_RefNannySetupContext("memoryview_cwrapper", 0);
28204 
28205   /* "View.MemoryView":658
28206  * @cname('__pyx_memoryview_new')
28207  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
28208  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)             # <<<<<<<<<<<<<<
28209  *     result.typeinfo = typeinfo
28210  *     return result
28211  */
28212   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 658, __pyx_L1_error)
28213   __Pyx_GOTREF(__pyx_t_1);
28214   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 658, __pyx_L1_error)
28215   __Pyx_GOTREF(__pyx_t_2);
28216   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 658, __pyx_L1_error)
28217   __Pyx_GOTREF(__pyx_t_3);
28218   __Pyx_INCREF(__pyx_v_o);
28219   __Pyx_GIVEREF(__pyx_v_o);
28220   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
28221   __Pyx_GIVEREF(__pyx_t_1);
28222   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
28223   __Pyx_GIVEREF(__pyx_t_2);
28224   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
28225   __pyx_t_1 = 0;
28226   __pyx_t_2 = 0;
28227   __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)
28228   __Pyx_GOTREF(__pyx_t_2);
28229   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
28230   __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2);
28231   __pyx_t_2 = 0;
28232 
28233   /* "View.MemoryView":659
28234  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
28235  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
28236  *     result.typeinfo = typeinfo             # <<<<<<<<<<<<<<
28237  *     return result
28238  *
28239  */
28240   __pyx_v_result->typeinfo = __pyx_v_typeinfo;
28241 
28242   /* "View.MemoryView":660
28243  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
28244  *     result.typeinfo = typeinfo
28245  *     return result             # <<<<<<<<<<<<<<
28246  *
28247  * @cname('__pyx_memoryview_check')
28248  */
28249   __Pyx_XDECREF(__pyx_r);
28250   __Pyx_INCREF(((PyObject *)__pyx_v_result));
28251   __pyx_r = ((PyObject *)__pyx_v_result);
28252   goto __pyx_L0;
28253 
28254   /* "View.MemoryView":657
28255  *
28256  * @cname('__pyx_memoryview_new')
28257  * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):             # <<<<<<<<<<<<<<
28258  *     cdef memoryview result = memoryview(o, flags, dtype_is_object)
28259  *     result.typeinfo = typeinfo
28260  */
28261 
28262   /* function exit code */
28263   __pyx_L1_error:;
28264   __Pyx_XDECREF(__pyx_t_1);
28265   __Pyx_XDECREF(__pyx_t_2);
28266   __Pyx_XDECREF(__pyx_t_3);
28267   __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
28268   __pyx_r = 0;
28269   __pyx_L0:;
28270   __Pyx_XDECREF((PyObject *)__pyx_v_result);
28271   __Pyx_XGIVEREF(__pyx_r);
28272   __Pyx_RefNannyFinishContext();
28273   return __pyx_r;
28274 }
28275 
28276 /* "View.MemoryView":663
28277  *
28278  * @cname('__pyx_memoryview_check')
28279  * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
28280  *     return isinstance(o, memoryview)
28281  *
28282  */
28283 
__pyx_memoryview_check(PyObject * __pyx_v_o)28284 static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
28285   int __pyx_r;
28286   __Pyx_RefNannyDeclarations
28287   int __pyx_t_1;
28288   __Pyx_RefNannySetupContext("memoryview_check", 0);
28289 
28290   /* "View.MemoryView":664
28291  * @cname('__pyx_memoryview_check')
28292  * cdef inline bint memoryview_check(object o):
28293  *     return isinstance(o, memoryview)             # <<<<<<<<<<<<<<
28294  *
28295  * cdef tuple _unellipsify(object index, int ndim):
28296  */
28297   __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type);
28298   __pyx_r = __pyx_t_1;
28299   goto __pyx_L0;
28300 
28301   /* "View.MemoryView":663
28302  *
28303  * @cname('__pyx_memoryview_check')
28304  * cdef inline bint memoryview_check(object o):             # <<<<<<<<<<<<<<
28305  *     return isinstance(o, memoryview)
28306  *
28307  */
28308 
28309   /* function exit code */
28310   __pyx_L0:;
28311   __Pyx_RefNannyFinishContext();
28312   return __pyx_r;
28313 }
28314 
28315 /* "View.MemoryView":666
28316  *     return isinstance(o, memoryview)
28317  *
28318  * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
28319  *     """
28320  *     Replace all ellipses with full slices and fill incomplete indices with
28321  */
28322 
_unellipsify(PyObject * __pyx_v_index,int __pyx_v_ndim)28323 static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
28324   PyObject *__pyx_v_tup = NULL;
28325   PyObject *__pyx_v_result = NULL;
28326   int __pyx_v_have_slices;
28327   int __pyx_v_seen_ellipsis;
28328   CYTHON_UNUSED PyObject *__pyx_v_idx = NULL;
28329   PyObject *__pyx_v_item = NULL;
28330   Py_ssize_t __pyx_v_nslices;
28331   PyObject *__pyx_r = NULL;
28332   __Pyx_RefNannyDeclarations
28333   int __pyx_t_1;
28334   int __pyx_t_2;
28335   PyObject *__pyx_t_3 = NULL;
28336   PyObject *__pyx_t_4 = NULL;
28337   Py_ssize_t __pyx_t_5;
28338   PyObject *(*__pyx_t_6)(PyObject *);
28339   PyObject *__pyx_t_7 = NULL;
28340   Py_ssize_t __pyx_t_8;
28341   int __pyx_t_9;
28342   int __pyx_t_10;
28343   PyObject *__pyx_t_11 = NULL;
28344   int __pyx_lineno = 0;
28345   const char *__pyx_filename = NULL;
28346   int __pyx_clineno = 0;
28347   __Pyx_RefNannySetupContext("_unellipsify", 0);
28348 
28349   /* "View.MemoryView":671
28350  *     full slices.
28351  *     """
28352  *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
28353  *         tup = (index,)
28354  *     else:
28355  */
28356   __pyx_t_1 = PyTuple_Check(__pyx_v_index);
28357   __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
28358   if (__pyx_t_2) {
28359 
28360     /* "View.MemoryView":672
28361  *     """
28362  *     if not isinstance(index, tuple):
28363  *         tup = (index,)             # <<<<<<<<<<<<<<
28364  *     else:
28365  *         tup = index
28366  */
28367     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 672, __pyx_L1_error)
28368     __Pyx_GOTREF(__pyx_t_3);
28369     __Pyx_INCREF(__pyx_v_index);
28370     __Pyx_GIVEREF(__pyx_v_index);
28371     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index);
28372     __pyx_v_tup = __pyx_t_3;
28373     __pyx_t_3 = 0;
28374 
28375     /* "View.MemoryView":671
28376  *     full slices.
28377  *     """
28378  *     if not isinstance(index, tuple):             # <<<<<<<<<<<<<<
28379  *         tup = (index,)
28380  *     else:
28381  */
28382     goto __pyx_L3;
28383   }
28384 
28385   /* "View.MemoryView":674
28386  *         tup = (index,)
28387  *     else:
28388  *         tup = index             # <<<<<<<<<<<<<<
28389  *
28390  *     result = []
28391  */
28392   /*else*/ {
28393     __Pyx_INCREF(__pyx_v_index);
28394     __pyx_v_tup = __pyx_v_index;
28395   }
28396   __pyx_L3:;
28397 
28398   /* "View.MemoryView":676
28399  *         tup = index
28400  *
28401  *     result = []             # <<<<<<<<<<<<<<
28402  *     have_slices = False
28403  *     seen_ellipsis = False
28404  */
28405   __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 676, __pyx_L1_error)
28406   __Pyx_GOTREF(__pyx_t_3);
28407   __pyx_v_result = ((PyObject*)__pyx_t_3);
28408   __pyx_t_3 = 0;
28409 
28410   /* "View.MemoryView":677
28411  *
28412  *     result = []
28413  *     have_slices = False             # <<<<<<<<<<<<<<
28414  *     seen_ellipsis = False
28415  *     for idx, item in enumerate(tup):
28416  */
28417   __pyx_v_have_slices = 0;
28418 
28419   /* "View.MemoryView":678
28420  *     result = []
28421  *     have_slices = False
28422  *     seen_ellipsis = False             # <<<<<<<<<<<<<<
28423  *     for idx, item in enumerate(tup):
28424  *         if item is Ellipsis:
28425  */
28426   __pyx_v_seen_ellipsis = 0;
28427 
28428   /* "View.MemoryView":679
28429  *     have_slices = False
28430  *     seen_ellipsis = False
28431  *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
28432  *         if item is Ellipsis:
28433  *             if not seen_ellipsis:
28434  */
28435   __Pyx_INCREF(__pyx_int_0);
28436   __pyx_t_3 = __pyx_int_0;
28437   if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
28438     __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
28439     __pyx_t_6 = NULL;
28440   } else {
28441     __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 679, __pyx_L1_error)
28442     __Pyx_GOTREF(__pyx_t_4);
28443     __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 679, __pyx_L1_error)
28444   }
28445   for (;;) {
28446     if (likely(!__pyx_t_6)) {
28447       if (likely(PyList_CheckExact(__pyx_t_4))) {
28448         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
28449         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
28450         __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)
28451         #else
28452         __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)
28453         __Pyx_GOTREF(__pyx_t_7);
28454         #endif
28455       } else {
28456         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
28457         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
28458         __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)
28459         #else
28460         __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)
28461         __Pyx_GOTREF(__pyx_t_7);
28462         #endif
28463       }
28464     } else {
28465       __pyx_t_7 = __pyx_t_6(__pyx_t_4);
28466       if (unlikely(!__pyx_t_7)) {
28467         PyObject* exc_type = PyErr_Occurred();
28468         if (exc_type) {
28469           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
28470           else __PYX_ERR(2, 679, __pyx_L1_error)
28471         }
28472         break;
28473       }
28474       __Pyx_GOTREF(__pyx_t_7);
28475     }
28476     __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
28477     __pyx_t_7 = 0;
28478     __Pyx_INCREF(__pyx_t_3);
28479     __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
28480     __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)
28481     __Pyx_GOTREF(__pyx_t_7);
28482     __Pyx_DECREF(__pyx_t_3);
28483     __pyx_t_3 = __pyx_t_7;
28484     __pyx_t_7 = 0;
28485 
28486     /* "View.MemoryView":680
28487  *     seen_ellipsis = False
28488  *     for idx, item in enumerate(tup):
28489  *         if item is Ellipsis:             # <<<<<<<<<<<<<<
28490  *             if not seen_ellipsis:
28491  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
28492  */
28493     __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis);
28494     __pyx_t_1 = (__pyx_t_2 != 0);
28495     if (__pyx_t_1) {
28496 
28497       /* "View.MemoryView":681
28498  *     for idx, item in enumerate(tup):
28499  *         if item is Ellipsis:
28500  *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
28501  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
28502  *                 seen_ellipsis = True
28503  */
28504       __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0);
28505       if (__pyx_t_1) {
28506 
28507         /* "View.MemoryView":682
28508  *         if item is Ellipsis:
28509  *             if not seen_ellipsis:
28510  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
28511  *                 seen_ellipsis = True
28512  *             else:
28513  */
28514         __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(2, 682, __pyx_L1_error)
28515         __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)
28516         __Pyx_GOTREF(__pyx_t_7);
28517         { Py_ssize_t __pyx_temp;
28518           for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) {
28519             __Pyx_INCREF(__pyx_slice__24);
28520             __Pyx_GIVEREF(__pyx_slice__24);
28521             PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__24);
28522           }
28523         }
28524         __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)
28525         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
28526 
28527         /* "View.MemoryView":683
28528  *             if not seen_ellipsis:
28529  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
28530  *                 seen_ellipsis = True             # <<<<<<<<<<<<<<
28531  *             else:
28532  *                 result.append(slice(None))
28533  */
28534         __pyx_v_seen_ellipsis = 1;
28535 
28536         /* "View.MemoryView":681
28537  *     for idx, item in enumerate(tup):
28538  *         if item is Ellipsis:
28539  *             if not seen_ellipsis:             # <<<<<<<<<<<<<<
28540  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
28541  *                 seen_ellipsis = True
28542  */
28543         goto __pyx_L7;
28544       }
28545 
28546       /* "View.MemoryView":685
28547  *                 seen_ellipsis = True
28548  *             else:
28549  *                 result.append(slice(None))             # <<<<<<<<<<<<<<
28550  *             have_slices = True
28551  *         else:
28552  */
28553       /*else*/ {
28554         __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__24); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(2, 685, __pyx_L1_error)
28555       }
28556       __pyx_L7:;
28557 
28558       /* "View.MemoryView":686
28559  *             else:
28560  *                 result.append(slice(None))
28561  *             have_slices = True             # <<<<<<<<<<<<<<
28562  *         else:
28563  *             if not isinstance(item, slice) and not PyIndex_Check(item):
28564  */
28565       __pyx_v_have_slices = 1;
28566 
28567       /* "View.MemoryView":680
28568  *     seen_ellipsis = False
28569  *     for idx, item in enumerate(tup):
28570  *         if item is Ellipsis:             # <<<<<<<<<<<<<<
28571  *             if not seen_ellipsis:
28572  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))
28573  */
28574       goto __pyx_L6;
28575     }
28576 
28577     /* "View.MemoryView":688
28578  *             have_slices = True
28579  *         else:
28580  *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
28581  *                 raise TypeError("Cannot index with type '%s'" % type(item))
28582  *
28583  */
28584     /*else*/ {
28585       __pyx_t_2 = PySlice_Check(__pyx_v_item);
28586       __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0);
28587       if (__pyx_t_10) {
28588       } else {
28589         __pyx_t_1 = __pyx_t_10;
28590         goto __pyx_L9_bool_binop_done;
28591       }
28592       __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0);
28593       __pyx_t_1 = __pyx_t_10;
28594       __pyx_L9_bool_binop_done:;
28595       if (unlikely(__pyx_t_1)) {
28596 
28597         /* "View.MemoryView":689
28598  *         else:
28599  *             if not isinstance(item, slice) and not PyIndex_Check(item):
28600  *                 raise TypeError("Cannot index with type '%s'" % type(item))             # <<<<<<<<<<<<<<
28601  *
28602  *             have_slices = have_slices or isinstance(item, slice)
28603  */
28604         __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)
28605         __Pyx_GOTREF(__pyx_t_7);
28606         __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 689, __pyx_L1_error)
28607         __Pyx_GOTREF(__pyx_t_11);
28608         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
28609         __Pyx_Raise(__pyx_t_11, 0, 0, 0);
28610         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
28611         __PYX_ERR(2, 689, __pyx_L1_error)
28612 
28613         /* "View.MemoryView":688
28614  *             have_slices = True
28615  *         else:
28616  *             if not isinstance(item, slice) and not PyIndex_Check(item):             # <<<<<<<<<<<<<<
28617  *                 raise TypeError("Cannot index with type '%s'" % type(item))
28618  *
28619  */
28620       }
28621 
28622       /* "View.MemoryView":691
28623  *                 raise TypeError("Cannot index with type '%s'" % type(item))
28624  *
28625  *             have_slices = have_slices or isinstance(item, slice)             # <<<<<<<<<<<<<<
28626  *             result.append(item)
28627  *
28628  */
28629       __pyx_t_10 = (__pyx_v_have_slices != 0);
28630       if (!__pyx_t_10) {
28631       } else {
28632         __pyx_t_1 = __pyx_t_10;
28633         goto __pyx_L11_bool_binop_done;
28634       }
28635       __pyx_t_10 = PySlice_Check(__pyx_v_item);
28636       __pyx_t_2 = (__pyx_t_10 != 0);
28637       __pyx_t_1 = __pyx_t_2;
28638       __pyx_L11_bool_binop_done:;
28639       __pyx_v_have_slices = __pyx_t_1;
28640 
28641       /* "View.MemoryView":692
28642  *
28643  *             have_slices = have_slices or isinstance(item, slice)
28644  *             result.append(item)             # <<<<<<<<<<<<<<
28645  *
28646  *     nslices = ndim - len(result)
28647  */
28648       __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)
28649     }
28650     __pyx_L6:;
28651 
28652     /* "View.MemoryView":679
28653  *     have_slices = False
28654  *     seen_ellipsis = False
28655  *     for idx, item in enumerate(tup):             # <<<<<<<<<<<<<<
28656  *         if item is Ellipsis:
28657  *             if not seen_ellipsis:
28658  */
28659   }
28660   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
28661   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
28662 
28663   /* "View.MemoryView":694
28664  *             result.append(item)
28665  *
28666  *     nslices = ndim - len(result)             # <<<<<<<<<<<<<<
28667  *     if nslices:
28668  *         result.extend([slice(None)] * nslices)
28669  */
28670   __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)
28671   __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);
28672 
28673   /* "View.MemoryView":695
28674  *
28675  *     nslices = ndim - len(result)
28676  *     if nslices:             # <<<<<<<<<<<<<<
28677  *         result.extend([slice(None)] * nslices)
28678  *
28679  */
28680   __pyx_t_1 = (__pyx_v_nslices != 0);
28681   if (__pyx_t_1) {
28682 
28683     /* "View.MemoryView":696
28684  *     nslices = ndim - len(result)
28685  *     if nslices:
28686  *         result.extend([slice(None)] * nslices)             # <<<<<<<<<<<<<<
28687  *
28688  *     return have_slices or nslices, tuple(result)
28689  */
28690     __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)
28691     __Pyx_GOTREF(__pyx_t_3);
28692     { Py_ssize_t __pyx_temp;
28693       for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) {
28694         __Pyx_INCREF(__pyx_slice__24);
28695         __Pyx_GIVEREF(__pyx_slice__24);
28696         PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__24);
28697       }
28698     }
28699     __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)
28700     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
28701 
28702     /* "View.MemoryView":695
28703  *
28704  *     nslices = ndim - len(result)
28705  *     if nslices:             # <<<<<<<<<<<<<<
28706  *         result.extend([slice(None)] * nslices)
28707  *
28708  */
28709   }
28710 
28711   /* "View.MemoryView":698
28712  *         result.extend([slice(None)] * nslices)
28713  *
28714  *     return have_slices or nslices, tuple(result)             # <<<<<<<<<<<<<<
28715  *
28716  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
28717  */
28718   __Pyx_XDECREF(__pyx_r);
28719   if (!__pyx_v_have_slices) {
28720   } else {
28721     __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 698, __pyx_L1_error)
28722     __Pyx_GOTREF(__pyx_t_4);
28723     __pyx_t_3 = __pyx_t_4;
28724     __pyx_t_4 = 0;
28725     goto __pyx_L14_bool_binop_done;
28726   }
28727   __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 698, __pyx_L1_error)
28728   __Pyx_GOTREF(__pyx_t_4);
28729   __pyx_t_3 = __pyx_t_4;
28730   __pyx_t_4 = 0;
28731   __pyx_L14_bool_binop_done:;
28732   __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 698, __pyx_L1_error)
28733   __Pyx_GOTREF(__pyx_t_4);
28734   __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 698, __pyx_L1_error)
28735   __Pyx_GOTREF(__pyx_t_11);
28736   __Pyx_GIVEREF(__pyx_t_3);
28737   PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
28738   __Pyx_GIVEREF(__pyx_t_4);
28739   PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
28740   __pyx_t_3 = 0;
28741   __pyx_t_4 = 0;
28742   __pyx_r = ((PyObject*)__pyx_t_11);
28743   __pyx_t_11 = 0;
28744   goto __pyx_L0;
28745 
28746   /* "View.MemoryView":666
28747  *     return isinstance(o, memoryview)
28748  *
28749  * cdef tuple _unellipsify(object index, int ndim):             # <<<<<<<<<<<<<<
28750  *     """
28751  *     Replace all ellipses with full slices and fill incomplete indices with
28752  */
28753 
28754   /* function exit code */
28755   __pyx_L1_error:;
28756   __Pyx_XDECREF(__pyx_t_3);
28757   __Pyx_XDECREF(__pyx_t_4);
28758   __Pyx_XDECREF(__pyx_t_7);
28759   __Pyx_XDECREF(__pyx_t_11);
28760   __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename);
28761   __pyx_r = 0;
28762   __pyx_L0:;
28763   __Pyx_XDECREF(__pyx_v_tup);
28764   __Pyx_XDECREF(__pyx_v_result);
28765   __Pyx_XDECREF(__pyx_v_idx);
28766   __Pyx_XDECREF(__pyx_v_item);
28767   __Pyx_XGIVEREF(__pyx_r);
28768   __Pyx_RefNannyFinishContext();
28769   return __pyx_r;
28770 }
28771 
28772 /* "View.MemoryView":700
28773  *     return have_slices or nslices, tuple(result)
28774  *
28775  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
28776  *     for suboffset in suboffsets[:ndim]:
28777  *         if suboffset >= 0:
28778  */
28779 
assert_direct_dimensions(Py_ssize_t * __pyx_v_suboffsets,int __pyx_v_ndim)28780 static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) {
28781   Py_ssize_t __pyx_v_suboffset;
28782   PyObject *__pyx_r = NULL;
28783   __Pyx_RefNannyDeclarations
28784   Py_ssize_t *__pyx_t_1;
28785   Py_ssize_t *__pyx_t_2;
28786   Py_ssize_t *__pyx_t_3;
28787   int __pyx_t_4;
28788   PyObject *__pyx_t_5 = NULL;
28789   int __pyx_lineno = 0;
28790   const char *__pyx_filename = NULL;
28791   int __pyx_clineno = 0;
28792   __Pyx_RefNannySetupContext("assert_direct_dimensions", 0);
28793 
28794   /* "View.MemoryView":701
28795  *
28796  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
28797  *     for suboffset in suboffsets[:ndim]:             # <<<<<<<<<<<<<<
28798  *         if suboffset >= 0:
28799  *             raise ValueError("Indirect dimensions not supported")
28800  */
28801   __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim);
28802   for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) {
28803     __pyx_t_1 = __pyx_t_3;
28804     __pyx_v_suboffset = (__pyx_t_1[0]);
28805 
28806     /* "View.MemoryView":702
28807  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
28808  *     for suboffset in suboffsets[:ndim]:
28809  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
28810  *             raise ValueError("Indirect dimensions not supported")
28811  *
28812  */
28813     __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0);
28814     if (unlikely(__pyx_t_4)) {
28815 
28816       /* "View.MemoryView":703
28817  *     for suboffset in suboffsets[:ndim]:
28818  *         if suboffset >= 0:
28819  *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
28820  *
28821  *
28822  */
28823       __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 703, __pyx_L1_error)
28824       __Pyx_GOTREF(__pyx_t_5);
28825       __Pyx_Raise(__pyx_t_5, 0, 0, 0);
28826       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
28827       __PYX_ERR(2, 703, __pyx_L1_error)
28828 
28829       /* "View.MemoryView":702
28830  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
28831  *     for suboffset in suboffsets[:ndim]:
28832  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
28833  *             raise ValueError("Indirect dimensions not supported")
28834  *
28835  */
28836     }
28837   }
28838 
28839   /* "View.MemoryView":700
28840  *     return have_slices or nslices, tuple(result)
28841  *
28842  * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):             # <<<<<<<<<<<<<<
28843  *     for suboffset in suboffsets[:ndim]:
28844  *         if suboffset >= 0:
28845  */
28846 
28847   /* function exit code */
28848   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28849   goto __pyx_L0;
28850   __pyx_L1_error:;
28851   __Pyx_XDECREF(__pyx_t_5);
28852   __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
28853   __pyx_r = 0;
28854   __pyx_L0:;
28855   __Pyx_XGIVEREF(__pyx_r);
28856   __Pyx_RefNannyFinishContext();
28857   return __pyx_r;
28858 }
28859 
28860 /* "View.MemoryView":710
28861  *
28862  * @cname('__pyx_memview_slice')
28863  * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
28864  *     cdef int new_ndim = 0, suboffset_dim = -1, dim
28865  *     cdef bint negative_step
28866  */
28867 
__pyx_memview_slice(struct __pyx_memoryview_obj * __pyx_v_memview,PyObject * __pyx_v_indices)28868 static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) {
28869   int __pyx_v_new_ndim;
28870   int __pyx_v_suboffset_dim;
28871   int __pyx_v_dim;
28872   __Pyx_memviewslice __pyx_v_src;
28873   __Pyx_memviewslice __pyx_v_dst;
28874   __Pyx_memviewslice *__pyx_v_p_src;
28875   struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0;
28876   __Pyx_memviewslice *__pyx_v_p_dst;
28877   int *__pyx_v_p_suboffset_dim;
28878   Py_ssize_t __pyx_v_start;
28879   Py_ssize_t __pyx_v_stop;
28880   Py_ssize_t __pyx_v_step;
28881   int __pyx_v_have_start;
28882   int __pyx_v_have_stop;
28883   int __pyx_v_have_step;
28884   PyObject *__pyx_v_index = NULL;
28885   struct __pyx_memoryview_obj *__pyx_r = NULL;
28886   __Pyx_RefNannyDeclarations
28887   int __pyx_t_1;
28888   int __pyx_t_2;
28889   PyObject *__pyx_t_3 = NULL;
28890   struct __pyx_memoryview_obj *__pyx_t_4;
28891   char *__pyx_t_5;
28892   int __pyx_t_6;
28893   Py_ssize_t __pyx_t_7;
28894   PyObject *(*__pyx_t_8)(PyObject *);
28895   PyObject *__pyx_t_9 = NULL;
28896   Py_ssize_t __pyx_t_10;
28897   int __pyx_t_11;
28898   Py_ssize_t __pyx_t_12;
28899   int __pyx_lineno = 0;
28900   const char *__pyx_filename = NULL;
28901   int __pyx_clineno = 0;
28902   __Pyx_RefNannySetupContext("memview_slice", 0);
28903 
28904   /* "View.MemoryView":711
28905  * @cname('__pyx_memview_slice')
28906  * cdef memoryview memview_slice(memoryview memview, object indices):
28907  *     cdef int new_ndim = 0, suboffset_dim = -1, dim             # <<<<<<<<<<<<<<
28908  *     cdef bint negative_step
28909  *     cdef __Pyx_memviewslice src, dst
28910  */
28911   __pyx_v_new_ndim = 0;
28912   __pyx_v_suboffset_dim = -1;
28913 
28914   /* "View.MemoryView":718
28915  *
28916  *
28917  *     memset(&dst, 0, sizeof(dst))             # <<<<<<<<<<<<<<
28918  *
28919  *     cdef _memoryviewslice memviewsliceobj
28920  */
28921   (void)(memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))));
28922 
28923   /* "View.MemoryView":722
28924  *     cdef _memoryviewslice memviewsliceobj
28925  *
28926  *     assert memview.view.ndim > 0             # <<<<<<<<<<<<<<
28927  *
28928  *     if isinstance(memview, _memoryviewslice):
28929  */
28930   #ifndef CYTHON_WITHOUT_ASSERTIONS
28931   if (unlikely(!Py_OptimizeFlag)) {
28932     if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) {
28933       PyErr_SetNone(PyExc_AssertionError);
28934       __PYX_ERR(2, 722, __pyx_L1_error)
28935     }
28936   }
28937   #endif
28938 
28939   /* "View.MemoryView":724
28940  *     assert memview.view.ndim > 0
28941  *
28942  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
28943  *         memviewsliceobj = memview
28944  *         p_src = &memviewsliceobj.from_slice
28945  */
28946   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
28947   __pyx_t_2 = (__pyx_t_1 != 0);
28948   if (__pyx_t_2) {
28949 
28950     /* "View.MemoryView":725
28951  *
28952  *     if isinstance(memview, _memoryviewslice):
28953  *         memviewsliceobj = memview             # <<<<<<<<<<<<<<
28954  *         p_src = &memviewsliceobj.from_slice
28955  *     else:
28956  */
28957     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)
28958     __pyx_t_3 = ((PyObject *)__pyx_v_memview);
28959     __Pyx_INCREF(__pyx_t_3);
28960     __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
28961     __pyx_t_3 = 0;
28962 
28963     /* "View.MemoryView":726
28964  *     if isinstance(memview, _memoryviewslice):
28965  *         memviewsliceobj = memview
28966  *         p_src = &memviewsliceobj.from_slice             # <<<<<<<<<<<<<<
28967  *     else:
28968  *         slice_copy(memview, &src)
28969  */
28970     __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice);
28971 
28972     /* "View.MemoryView":724
28973  *     assert memview.view.ndim > 0
28974  *
28975  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
28976  *         memviewsliceobj = memview
28977  *         p_src = &memviewsliceobj.from_slice
28978  */
28979     goto __pyx_L3;
28980   }
28981 
28982   /* "View.MemoryView":728
28983  *         p_src = &memviewsliceobj.from_slice
28984  *     else:
28985  *         slice_copy(memview, &src)             # <<<<<<<<<<<<<<
28986  *         p_src = &src
28987  *
28988  */
28989   /*else*/ {
28990     __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src));
28991 
28992     /* "View.MemoryView":729
28993  *     else:
28994  *         slice_copy(memview, &src)
28995  *         p_src = &src             # <<<<<<<<<<<<<<
28996  *
28997  *
28998  */
28999     __pyx_v_p_src = (&__pyx_v_src);
29000   }
29001   __pyx_L3:;
29002 
29003   /* "View.MemoryView":735
29004  *
29005  *
29006  *     dst.memview = p_src.memview             # <<<<<<<<<<<<<<
29007  *     dst.data = p_src.data
29008  *
29009  */
29010   __pyx_t_4 = __pyx_v_p_src->memview;
29011   __pyx_v_dst.memview = __pyx_t_4;
29012 
29013   /* "View.MemoryView":736
29014  *
29015  *     dst.memview = p_src.memview
29016  *     dst.data = p_src.data             # <<<<<<<<<<<<<<
29017  *
29018  *
29019  */
29020   __pyx_t_5 = __pyx_v_p_src->data;
29021   __pyx_v_dst.data = __pyx_t_5;
29022 
29023   /* "View.MemoryView":741
29024  *
29025  *
29026  *     cdef __Pyx_memviewslice *p_dst = &dst             # <<<<<<<<<<<<<<
29027  *     cdef int *p_suboffset_dim = &suboffset_dim
29028  *     cdef Py_ssize_t start, stop, step
29029  */
29030   __pyx_v_p_dst = (&__pyx_v_dst);
29031 
29032   /* "View.MemoryView":742
29033  *
29034  *     cdef __Pyx_memviewslice *p_dst = &dst
29035  *     cdef int *p_suboffset_dim = &suboffset_dim             # <<<<<<<<<<<<<<
29036  *     cdef Py_ssize_t start, stop, step
29037  *     cdef bint have_start, have_stop, have_step
29038  */
29039   __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim);
29040 
29041   /* "View.MemoryView":746
29042  *     cdef bint have_start, have_stop, have_step
29043  *
29044  *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
29045  *         if PyIndex_Check(index):
29046  *             slice_memviewslice(
29047  */
29048   __pyx_t_6 = 0;
29049   if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
29050     __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
29051     __pyx_t_8 = NULL;
29052   } else {
29053     __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 746, __pyx_L1_error)
29054     __Pyx_GOTREF(__pyx_t_3);
29055     __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 746, __pyx_L1_error)
29056   }
29057   for (;;) {
29058     if (likely(!__pyx_t_8)) {
29059       if (likely(PyList_CheckExact(__pyx_t_3))) {
29060         if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
29061         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
29062         __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)
29063         #else
29064         __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)
29065         __Pyx_GOTREF(__pyx_t_9);
29066         #endif
29067       } else {
29068         if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
29069         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
29070         __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)
29071         #else
29072         __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)
29073         __Pyx_GOTREF(__pyx_t_9);
29074         #endif
29075       }
29076     } else {
29077       __pyx_t_9 = __pyx_t_8(__pyx_t_3);
29078       if (unlikely(!__pyx_t_9)) {
29079         PyObject* exc_type = PyErr_Occurred();
29080         if (exc_type) {
29081           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
29082           else __PYX_ERR(2, 746, __pyx_L1_error)
29083         }
29084         break;
29085       }
29086       __Pyx_GOTREF(__pyx_t_9);
29087     }
29088     __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9);
29089     __pyx_t_9 = 0;
29090     __pyx_v_dim = __pyx_t_6;
29091     __pyx_t_6 = (__pyx_t_6 + 1);
29092 
29093     /* "View.MemoryView":747
29094  *
29095  *     for dim, index in enumerate(indices):
29096  *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
29097  *             slice_memviewslice(
29098  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
29099  */
29100     __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0);
29101     if (__pyx_t_2) {
29102 
29103       /* "View.MemoryView":751
29104  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
29105  *                 dim, new_ndim, p_suboffset_dim,
29106  *                 index, 0, 0, # start, stop, step             # <<<<<<<<<<<<<<
29107  *                 0, 0, 0, # have_{start,stop,step}
29108  *                 False)
29109  */
29110       __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)
29111 
29112       /* "View.MemoryView":748
29113  *     for dim, index in enumerate(indices):
29114  *         if PyIndex_Check(index):
29115  *             slice_memviewslice(             # <<<<<<<<<<<<<<
29116  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
29117  *                 dim, new_ndim, p_suboffset_dim,
29118  */
29119       __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)
29120 
29121       /* "View.MemoryView":747
29122  *
29123  *     for dim, index in enumerate(indices):
29124  *         if PyIndex_Check(index):             # <<<<<<<<<<<<<<
29125  *             slice_memviewslice(
29126  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
29127  */
29128       goto __pyx_L6;
29129     }
29130 
29131     /* "View.MemoryView":754
29132  *                 0, 0, 0, # have_{start,stop,step}
29133  *                 False)
29134  *         elif index is None:             # <<<<<<<<<<<<<<
29135  *             p_dst.shape[new_ndim] = 1
29136  *             p_dst.strides[new_ndim] = 0
29137  */
29138     __pyx_t_2 = (__pyx_v_index == Py_None);
29139     __pyx_t_1 = (__pyx_t_2 != 0);
29140     if (__pyx_t_1) {
29141 
29142       /* "View.MemoryView":755
29143  *                 False)
29144  *         elif index is None:
29145  *             p_dst.shape[new_ndim] = 1             # <<<<<<<<<<<<<<
29146  *             p_dst.strides[new_ndim] = 0
29147  *             p_dst.suboffsets[new_ndim] = -1
29148  */
29149       (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1;
29150 
29151       /* "View.MemoryView":756
29152  *         elif index is None:
29153  *             p_dst.shape[new_ndim] = 1
29154  *             p_dst.strides[new_ndim] = 0             # <<<<<<<<<<<<<<
29155  *             p_dst.suboffsets[new_ndim] = -1
29156  *             new_ndim += 1
29157  */
29158       (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0;
29159 
29160       /* "View.MemoryView":757
29161  *             p_dst.shape[new_ndim] = 1
29162  *             p_dst.strides[new_ndim] = 0
29163  *             p_dst.suboffsets[new_ndim] = -1             # <<<<<<<<<<<<<<
29164  *             new_ndim += 1
29165  *         else:
29166  */
29167       (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L;
29168 
29169       /* "View.MemoryView":758
29170  *             p_dst.strides[new_ndim] = 0
29171  *             p_dst.suboffsets[new_ndim] = -1
29172  *             new_ndim += 1             # <<<<<<<<<<<<<<
29173  *         else:
29174  *             start = index.start or 0
29175  */
29176       __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
29177 
29178       /* "View.MemoryView":754
29179  *                 0, 0, 0, # have_{start,stop,step}
29180  *                 False)
29181  *         elif index is None:             # <<<<<<<<<<<<<<
29182  *             p_dst.shape[new_ndim] = 1
29183  *             p_dst.strides[new_ndim] = 0
29184  */
29185       goto __pyx_L6;
29186     }
29187 
29188     /* "View.MemoryView":760
29189  *             new_ndim += 1
29190  *         else:
29191  *             start = index.start or 0             # <<<<<<<<<<<<<<
29192  *             stop = index.stop or 0
29193  *             step = index.step or 0
29194  */
29195     /*else*/ {
29196       __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)
29197       __Pyx_GOTREF(__pyx_t_9);
29198       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 760, __pyx_L1_error)
29199       if (!__pyx_t_1) {
29200         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
29201       } else {
29202         __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)
29203         __pyx_t_10 = __pyx_t_12;
29204         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
29205         goto __pyx_L7_bool_binop_done;
29206       }
29207       __pyx_t_10 = 0;
29208       __pyx_L7_bool_binop_done:;
29209       __pyx_v_start = __pyx_t_10;
29210 
29211       /* "View.MemoryView":761
29212  *         else:
29213  *             start = index.start or 0
29214  *             stop = index.stop or 0             # <<<<<<<<<<<<<<
29215  *             step = index.step or 0
29216  *
29217  */
29218       __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)
29219       __Pyx_GOTREF(__pyx_t_9);
29220       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 761, __pyx_L1_error)
29221       if (!__pyx_t_1) {
29222         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
29223       } else {
29224         __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)
29225         __pyx_t_10 = __pyx_t_12;
29226         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
29227         goto __pyx_L9_bool_binop_done;
29228       }
29229       __pyx_t_10 = 0;
29230       __pyx_L9_bool_binop_done:;
29231       __pyx_v_stop = __pyx_t_10;
29232 
29233       /* "View.MemoryView":762
29234  *             start = index.start or 0
29235  *             stop = index.stop or 0
29236  *             step = index.step or 0             # <<<<<<<<<<<<<<
29237  *
29238  *             have_start = index.start is not None
29239  */
29240       __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)
29241       __Pyx_GOTREF(__pyx_t_9);
29242       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(2, 762, __pyx_L1_error)
29243       if (!__pyx_t_1) {
29244         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
29245       } else {
29246         __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)
29247         __pyx_t_10 = __pyx_t_12;
29248         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
29249         goto __pyx_L11_bool_binop_done;
29250       }
29251       __pyx_t_10 = 0;
29252       __pyx_L11_bool_binop_done:;
29253       __pyx_v_step = __pyx_t_10;
29254 
29255       /* "View.MemoryView":764
29256  *             step = index.step or 0
29257  *
29258  *             have_start = index.start is not None             # <<<<<<<<<<<<<<
29259  *             have_stop = index.stop is not None
29260  *             have_step = index.step is not None
29261  */
29262       __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)
29263       __Pyx_GOTREF(__pyx_t_9);
29264       __pyx_t_1 = (__pyx_t_9 != Py_None);
29265       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
29266       __pyx_v_have_start = __pyx_t_1;
29267 
29268       /* "View.MemoryView":765
29269  *
29270  *             have_start = index.start is not None
29271  *             have_stop = index.stop is not None             # <<<<<<<<<<<<<<
29272  *             have_step = index.step is not None
29273  *
29274  */
29275       __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)
29276       __Pyx_GOTREF(__pyx_t_9);
29277       __pyx_t_1 = (__pyx_t_9 != Py_None);
29278       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
29279       __pyx_v_have_stop = __pyx_t_1;
29280 
29281       /* "View.MemoryView":766
29282  *             have_start = index.start is not None
29283  *             have_stop = index.stop is not None
29284  *             have_step = index.step is not None             # <<<<<<<<<<<<<<
29285  *
29286  *             slice_memviewslice(
29287  */
29288       __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)
29289       __Pyx_GOTREF(__pyx_t_9);
29290       __pyx_t_1 = (__pyx_t_9 != Py_None);
29291       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
29292       __pyx_v_have_step = __pyx_t_1;
29293 
29294       /* "View.MemoryView":768
29295  *             have_step = index.step is not None
29296  *
29297  *             slice_memviewslice(             # <<<<<<<<<<<<<<
29298  *                 p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
29299  *                 dim, new_ndim, p_suboffset_dim,
29300  */
29301       __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)
29302 
29303       /* "View.MemoryView":774
29304  *                 have_start, have_stop, have_step,
29305  *                 True)
29306  *             new_ndim += 1             # <<<<<<<<<<<<<<
29307  *
29308  *     if isinstance(memview, _memoryviewslice):
29309  */
29310       __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
29311     }
29312     __pyx_L6:;
29313 
29314     /* "View.MemoryView":746
29315  *     cdef bint have_start, have_stop, have_step
29316  *
29317  *     for dim, index in enumerate(indices):             # <<<<<<<<<<<<<<
29318  *         if PyIndex_Check(index):
29319  *             slice_memviewslice(
29320  */
29321   }
29322   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
29323 
29324   /* "View.MemoryView":776
29325  *             new_ndim += 1
29326  *
29327  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
29328  *         return memoryview_fromslice(dst, new_ndim,
29329  *                                     memviewsliceobj.to_object_func,
29330  */
29331   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
29332   __pyx_t_2 = (__pyx_t_1 != 0);
29333   if (__pyx_t_2) {
29334 
29335     /* "View.MemoryView":777
29336  *
29337  *     if isinstance(memview, _memoryviewslice):
29338  *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
29339  *                                     memviewsliceobj.to_object_func,
29340  *                                     memviewsliceobj.to_dtype_func,
29341  */
29342     __Pyx_XDECREF(((PyObject *)__pyx_r));
29343 
29344     /* "View.MemoryView":778
29345  *     if isinstance(memview, _memoryviewslice):
29346  *         return memoryview_fromslice(dst, new_ndim,
29347  *                                     memviewsliceobj.to_object_func,             # <<<<<<<<<<<<<<
29348  *                                     memviewsliceobj.to_dtype_func,
29349  *                                     memview.dtype_is_object)
29350  */
29351     if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 778, __pyx_L1_error) }
29352 
29353     /* "View.MemoryView":779
29354  *         return memoryview_fromslice(dst, new_ndim,
29355  *                                     memviewsliceobj.to_object_func,
29356  *                                     memviewsliceobj.to_dtype_func,             # <<<<<<<<<<<<<<
29357  *                                     memview.dtype_is_object)
29358  *     else:
29359  */
29360     if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(2, 779, __pyx_L1_error) }
29361 
29362     /* "View.MemoryView":777
29363  *
29364  *     if isinstance(memview, _memoryviewslice):
29365  *         return memoryview_fromslice(dst, new_ndim,             # <<<<<<<<<<<<<<
29366  *                                     memviewsliceobj.to_object_func,
29367  *                                     memviewsliceobj.to_dtype_func,
29368  */
29369     __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)
29370     __Pyx_GOTREF(__pyx_t_3);
29371     if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 777, __pyx_L1_error)
29372     __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
29373     __pyx_t_3 = 0;
29374     goto __pyx_L0;
29375 
29376     /* "View.MemoryView":776
29377  *             new_ndim += 1
29378  *
29379  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
29380  *         return memoryview_fromslice(dst, new_ndim,
29381  *                                     memviewsliceobj.to_object_func,
29382  */
29383   }
29384 
29385   /* "View.MemoryView":782
29386  *                                     memview.dtype_is_object)
29387  *     else:
29388  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
29389  *                                     memview.dtype_is_object)
29390  *
29391  */
29392   /*else*/ {
29393     __Pyx_XDECREF(((PyObject *)__pyx_r));
29394 
29395     /* "View.MemoryView":783
29396  *     else:
29397  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,
29398  *                                     memview.dtype_is_object)             # <<<<<<<<<<<<<<
29399  *
29400  *
29401  */
29402     __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)
29403     __Pyx_GOTREF(__pyx_t_3);
29404 
29405     /* "View.MemoryView":782
29406  *                                     memview.dtype_is_object)
29407  *     else:
29408  *         return memoryview_fromslice(dst, new_ndim, NULL, NULL,             # <<<<<<<<<<<<<<
29409  *                                     memview.dtype_is_object)
29410  *
29411  */
29412     if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(2, 782, __pyx_L1_error)
29413     __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
29414     __pyx_t_3 = 0;
29415     goto __pyx_L0;
29416   }
29417 
29418   /* "View.MemoryView":710
29419  *
29420  * @cname('__pyx_memview_slice')
29421  * cdef memoryview memview_slice(memoryview memview, object indices):             # <<<<<<<<<<<<<<
29422  *     cdef int new_ndim = 0, suboffset_dim = -1, dim
29423  *     cdef bint negative_step
29424  */
29425 
29426   /* function exit code */
29427   __pyx_L1_error:;
29428   __Pyx_XDECREF(__pyx_t_3);
29429   __Pyx_XDECREF(__pyx_t_9);
29430   __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
29431   __pyx_r = 0;
29432   __pyx_L0:;
29433   __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj);
29434   __Pyx_XDECREF(__pyx_v_index);
29435   __Pyx_XGIVEREF((PyObject *)__pyx_r);
29436   __Pyx_RefNannyFinishContext();
29437   return __pyx_r;
29438 }
29439 
29440 /* "View.MemoryView":807
29441  *
29442  * @cname('__pyx_memoryview_slice_memviewslice')
29443  * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
29444  *         __Pyx_memviewslice *dst,
29445  *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
29446  */
29447 
__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)29448 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) {
29449   Py_ssize_t __pyx_v_new_shape;
29450   int __pyx_v_negative_step;
29451   int __pyx_r;
29452   int __pyx_t_1;
29453   int __pyx_t_2;
29454   int __pyx_t_3;
29455   int __pyx_lineno = 0;
29456   const char *__pyx_filename = NULL;
29457   int __pyx_clineno = 0;
29458 
29459   /* "View.MemoryView":827
29460  *     cdef bint negative_step
29461  *
29462  *     if not is_slice:             # <<<<<<<<<<<<<<
29463  *
29464  *         if start < 0:
29465  */
29466   __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0);
29467   if (__pyx_t_1) {
29468 
29469     /* "View.MemoryView":829
29470  *     if not is_slice:
29471  *
29472  *         if start < 0:             # <<<<<<<<<<<<<<
29473  *             start += shape
29474  *         if not 0 <= start < shape:
29475  */
29476     __pyx_t_1 = ((__pyx_v_start < 0) != 0);
29477     if (__pyx_t_1) {
29478 
29479       /* "View.MemoryView":830
29480  *
29481  *         if start < 0:
29482  *             start += shape             # <<<<<<<<<<<<<<
29483  *         if not 0 <= start < shape:
29484  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
29485  */
29486       __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
29487 
29488       /* "View.MemoryView":829
29489  *     if not is_slice:
29490  *
29491  *         if start < 0:             # <<<<<<<<<<<<<<
29492  *             start += shape
29493  *         if not 0 <= start < shape:
29494  */
29495     }
29496 
29497     /* "View.MemoryView":831
29498  *         if start < 0:
29499  *             start += shape
29500  *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
29501  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
29502  *     else:
29503  */
29504     __pyx_t_1 = (0 <= __pyx_v_start);
29505     if (__pyx_t_1) {
29506       __pyx_t_1 = (__pyx_v_start < __pyx_v_shape);
29507     }
29508     __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
29509     if (__pyx_t_2) {
29510 
29511       /* "View.MemoryView":832
29512  *             start += shape
29513  *         if not 0 <= start < shape:
29514  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)             # <<<<<<<<<<<<<<
29515  *     else:
29516  *
29517  */
29518       __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)
29519 
29520       /* "View.MemoryView":831
29521  *         if start < 0:
29522  *             start += shape
29523  *         if not 0 <= start < shape:             # <<<<<<<<<<<<<<
29524  *             _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
29525  *     else:
29526  */
29527     }
29528 
29529     /* "View.MemoryView":827
29530  *     cdef bint negative_step
29531  *
29532  *     if not is_slice:             # <<<<<<<<<<<<<<
29533  *
29534  *         if start < 0:
29535  */
29536     goto __pyx_L3;
29537   }
29538 
29539   /* "View.MemoryView":835
29540  *     else:
29541  *
29542  *         negative_step = have_step != 0 and step < 0             # <<<<<<<<<<<<<<
29543  *
29544  *         if have_step and step == 0:
29545  */
29546   /*else*/ {
29547     __pyx_t_1 = ((__pyx_v_have_step != 0) != 0);
29548     if (__pyx_t_1) {
29549     } else {
29550       __pyx_t_2 = __pyx_t_1;
29551       goto __pyx_L6_bool_binop_done;
29552     }
29553     __pyx_t_1 = ((__pyx_v_step < 0) != 0);
29554     __pyx_t_2 = __pyx_t_1;
29555     __pyx_L6_bool_binop_done:;
29556     __pyx_v_negative_step = __pyx_t_2;
29557 
29558     /* "View.MemoryView":837
29559  *         negative_step = have_step != 0 and step < 0
29560  *
29561  *         if have_step and step == 0:             # <<<<<<<<<<<<<<
29562  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
29563  *
29564  */
29565     __pyx_t_1 = (__pyx_v_have_step != 0);
29566     if (__pyx_t_1) {
29567     } else {
29568       __pyx_t_2 = __pyx_t_1;
29569       goto __pyx_L9_bool_binop_done;
29570     }
29571     __pyx_t_1 = ((__pyx_v_step == 0) != 0);
29572     __pyx_t_2 = __pyx_t_1;
29573     __pyx_L9_bool_binop_done:;
29574     if (__pyx_t_2) {
29575 
29576       /* "View.MemoryView":838
29577  *
29578  *         if have_step and step == 0:
29579  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)             # <<<<<<<<<<<<<<
29580  *
29581  *
29582  */
29583       __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)
29584 
29585       /* "View.MemoryView":837
29586  *         negative_step = have_step != 0 and step < 0
29587  *
29588  *         if have_step and step == 0:             # <<<<<<<<<<<<<<
29589  *             _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
29590  *
29591  */
29592     }
29593 
29594     /* "View.MemoryView":841
29595  *
29596  *
29597  *         if have_start:             # <<<<<<<<<<<<<<
29598  *             if start < 0:
29599  *                 start += shape
29600  */
29601     __pyx_t_2 = (__pyx_v_have_start != 0);
29602     if (__pyx_t_2) {
29603 
29604       /* "View.MemoryView":842
29605  *
29606  *         if have_start:
29607  *             if start < 0:             # <<<<<<<<<<<<<<
29608  *                 start += shape
29609  *                 if start < 0:
29610  */
29611       __pyx_t_2 = ((__pyx_v_start < 0) != 0);
29612       if (__pyx_t_2) {
29613 
29614         /* "View.MemoryView":843
29615  *         if have_start:
29616  *             if start < 0:
29617  *                 start += shape             # <<<<<<<<<<<<<<
29618  *                 if start < 0:
29619  *                     start = 0
29620  */
29621         __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
29622 
29623         /* "View.MemoryView":844
29624  *             if start < 0:
29625  *                 start += shape
29626  *                 if start < 0:             # <<<<<<<<<<<<<<
29627  *                     start = 0
29628  *             elif start >= shape:
29629  */
29630         __pyx_t_2 = ((__pyx_v_start < 0) != 0);
29631         if (__pyx_t_2) {
29632 
29633           /* "View.MemoryView":845
29634  *                 start += shape
29635  *                 if start < 0:
29636  *                     start = 0             # <<<<<<<<<<<<<<
29637  *             elif start >= shape:
29638  *                 if negative_step:
29639  */
29640           __pyx_v_start = 0;
29641 
29642           /* "View.MemoryView":844
29643  *             if start < 0:
29644  *                 start += shape
29645  *                 if start < 0:             # <<<<<<<<<<<<<<
29646  *                     start = 0
29647  *             elif start >= shape:
29648  */
29649         }
29650 
29651         /* "View.MemoryView":842
29652  *
29653  *         if have_start:
29654  *             if start < 0:             # <<<<<<<<<<<<<<
29655  *                 start += shape
29656  *                 if start < 0:
29657  */
29658         goto __pyx_L12;
29659       }
29660 
29661       /* "View.MemoryView":846
29662  *                 if start < 0:
29663  *                     start = 0
29664  *             elif start >= shape:             # <<<<<<<<<<<<<<
29665  *                 if negative_step:
29666  *                     start = shape - 1
29667  */
29668       __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0);
29669       if (__pyx_t_2) {
29670 
29671         /* "View.MemoryView":847
29672  *                     start = 0
29673  *             elif start >= shape:
29674  *                 if negative_step:             # <<<<<<<<<<<<<<
29675  *                     start = shape - 1
29676  *                 else:
29677  */
29678         __pyx_t_2 = (__pyx_v_negative_step != 0);
29679         if (__pyx_t_2) {
29680 
29681           /* "View.MemoryView":848
29682  *             elif start >= shape:
29683  *                 if negative_step:
29684  *                     start = shape - 1             # <<<<<<<<<<<<<<
29685  *                 else:
29686  *                     start = shape
29687  */
29688           __pyx_v_start = (__pyx_v_shape - 1);
29689 
29690           /* "View.MemoryView":847
29691  *                     start = 0
29692  *             elif start >= shape:
29693  *                 if negative_step:             # <<<<<<<<<<<<<<
29694  *                     start = shape - 1
29695  *                 else:
29696  */
29697           goto __pyx_L14;
29698         }
29699 
29700         /* "View.MemoryView":850
29701  *                     start = shape - 1
29702  *                 else:
29703  *                     start = shape             # <<<<<<<<<<<<<<
29704  *         else:
29705  *             if negative_step:
29706  */
29707         /*else*/ {
29708           __pyx_v_start = __pyx_v_shape;
29709         }
29710         __pyx_L14:;
29711 
29712         /* "View.MemoryView":846
29713  *                 if start < 0:
29714  *                     start = 0
29715  *             elif start >= shape:             # <<<<<<<<<<<<<<
29716  *                 if negative_step:
29717  *                     start = shape - 1
29718  */
29719       }
29720       __pyx_L12:;
29721 
29722       /* "View.MemoryView":841
29723  *
29724  *
29725  *         if have_start:             # <<<<<<<<<<<<<<
29726  *             if start < 0:
29727  *                 start += shape
29728  */
29729       goto __pyx_L11;
29730     }
29731 
29732     /* "View.MemoryView":852
29733  *                     start = shape
29734  *         else:
29735  *             if negative_step:             # <<<<<<<<<<<<<<
29736  *                 start = shape - 1
29737  *             else:
29738  */
29739     /*else*/ {
29740       __pyx_t_2 = (__pyx_v_negative_step != 0);
29741       if (__pyx_t_2) {
29742 
29743         /* "View.MemoryView":853
29744  *         else:
29745  *             if negative_step:
29746  *                 start = shape - 1             # <<<<<<<<<<<<<<
29747  *             else:
29748  *                 start = 0
29749  */
29750         __pyx_v_start = (__pyx_v_shape - 1);
29751 
29752         /* "View.MemoryView":852
29753  *                     start = shape
29754  *         else:
29755  *             if negative_step:             # <<<<<<<<<<<<<<
29756  *                 start = shape - 1
29757  *             else:
29758  */
29759         goto __pyx_L15;
29760       }
29761 
29762       /* "View.MemoryView":855
29763  *                 start = shape - 1
29764  *             else:
29765  *                 start = 0             # <<<<<<<<<<<<<<
29766  *
29767  *         if have_stop:
29768  */
29769       /*else*/ {
29770         __pyx_v_start = 0;
29771       }
29772       __pyx_L15:;
29773     }
29774     __pyx_L11:;
29775 
29776     /* "View.MemoryView":857
29777  *                 start = 0
29778  *
29779  *         if have_stop:             # <<<<<<<<<<<<<<
29780  *             if stop < 0:
29781  *                 stop += shape
29782  */
29783     __pyx_t_2 = (__pyx_v_have_stop != 0);
29784     if (__pyx_t_2) {
29785 
29786       /* "View.MemoryView":858
29787  *
29788  *         if have_stop:
29789  *             if stop < 0:             # <<<<<<<<<<<<<<
29790  *                 stop += shape
29791  *                 if stop < 0:
29792  */
29793       __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
29794       if (__pyx_t_2) {
29795 
29796         /* "View.MemoryView":859
29797  *         if have_stop:
29798  *             if stop < 0:
29799  *                 stop += shape             # <<<<<<<<<<<<<<
29800  *                 if stop < 0:
29801  *                     stop = 0
29802  */
29803         __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);
29804 
29805         /* "View.MemoryView":860
29806  *             if stop < 0:
29807  *                 stop += shape
29808  *                 if stop < 0:             # <<<<<<<<<<<<<<
29809  *                     stop = 0
29810  *             elif stop > shape:
29811  */
29812         __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
29813         if (__pyx_t_2) {
29814 
29815           /* "View.MemoryView":861
29816  *                 stop += shape
29817  *                 if stop < 0:
29818  *                     stop = 0             # <<<<<<<<<<<<<<
29819  *             elif stop > shape:
29820  *                 stop = shape
29821  */
29822           __pyx_v_stop = 0;
29823 
29824           /* "View.MemoryView":860
29825  *             if stop < 0:
29826  *                 stop += shape
29827  *                 if stop < 0:             # <<<<<<<<<<<<<<
29828  *                     stop = 0
29829  *             elif stop > shape:
29830  */
29831         }
29832 
29833         /* "View.MemoryView":858
29834  *
29835  *         if have_stop:
29836  *             if stop < 0:             # <<<<<<<<<<<<<<
29837  *                 stop += shape
29838  *                 if stop < 0:
29839  */
29840         goto __pyx_L17;
29841       }
29842 
29843       /* "View.MemoryView":862
29844  *                 if stop < 0:
29845  *                     stop = 0
29846  *             elif stop > shape:             # <<<<<<<<<<<<<<
29847  *                 stop = shape
29848  *         else:
29849  */
29850       __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0);
29851       if (__pyx_t_2) {
29852 
29853         /* "View.MemoryView":863
29854  *                     stop = 0
29855  *             elif stop > shape:
29856  *                 stop = shape             # <<<<<<<<<<<<<<
29857  *         else:
29858  *             if negative_step:
29859  */
29860         __pyx_v_stop = __pyx_v_shape;
29861 
29862         /* "View.MemoryView":862
29863  *                 if stop < 0:
29864  *                     stop = 0
29865  *             elif stop > shape:             # <<<<<<<<<<<<<<
29866  *                 stop = shape
29867  *         else:
29868  */
29869       }
29870       __pyx_L17:;
29871 
29872       /* "View.MemoryView":857
29873  *                 start = 0
29874  *
29875  *         if have_stop:             # <<<<<<<<<<<<<<
29876  *             if stop < 0:
29877  *                 stop += shape
29878  */
29879       goto __pyx_L16;
29880     }
29881 
29882     /* "View.MemoryView":865
29883  *                 stop = shape
29884  *         else:
29885  *             if negative_step:             # <<<<<<<<<<<<<<
29886  *                 stop = -1
29887  *             else:
29888  */
29889     /*else*/ {
29890       __pyx_t_2 = (__pyx_v_negative_step != 0);
29891       if (__pyx_t_2) {
29892 
29893         /* "View.MemoryView":866
29894  *         else:
29895  *             if negative_step:
29896  *                 stop = -1             # <<<<<<<<<<<<<<
29897  *             else:
29898  *                 stop = shape
29899  */
29900         __pyx_v_stop = -1L;
29901 
29902         /* "View.MemoryView":865
29903  *                 stop = shape
29904  *         else:
29905  *             if negative_step:             # <<<<<<<<<<<<<<
29906  *                 stop = -1
29907  *             else:
29908  */
29909         goto __pyx_L19;
29910       }
29911 
29912       /* "View.MemoryView":868
29913  *                 stop = -1
29914  *             else:
29915  *                 stop = shape             # <<<<<<<<<<<<<<
29916  *
29917  *         if not have_step:
29918  */
29919       /*else*/ {
29920         __pyx_v_stop = __pyx_v_shape;
29921       }
29922       __pyx_L19:;
29923     }
29924     __pyx_L16:;
29925 
29926     /* "View.MemoryView":870
29927  *                 stop = shape
29928  *
29929  *         if not have_step:             # <<<<<<<<<<<<<<
29930  *             step = 1
29931  *
29932  */
29933     __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
29934     if (__pyx_t_2) {
29935 
29936       /* "View.MemoryView":871
29937  *
29938  *         if not have_step:
29939  *             step = 1             # <<<<<<<<<<<<<<
29940  *
29941  *
29942  */
29943       __pyx_v_step = 1;
29944 
29945       /* "View.MemoryView":870
29946  *                 stop = shape
29947  *
29948  *         if not have_step:             # <<<<<<<<<<<<<<
29949  *             step = 1
29950  *
29951  */
29952     }
29953 
29954     /* "View.MemoryView":875
29955  *
29956  *         with cython.cdivision(True):
29957  *             new_shape = (stop - start) // step             # <<<<<<<<<<<<<<
29958  *
29959  *             if (stop - start) - step * new_shape:
29960  */
29961     __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step);
29962 
29963     /* "View.MemoryView":877
29964  *             new_shape = (stop - start) // step
29965  *
29966  *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
29967  *                 new_shape += 1
29968  *
29969  */
29970     __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0);
29971     if (__pyx_t_2) {
29972 
29973       /* "View.MemoryView":878
29974  *
29975  *             if (stop - start) - step * new_shape:
29976  *                 new_shape += 1             # <<<<<<<<<<<<<<
29977  *
29978  *         if new_shape < 0:
29979  */
29980       __pyx_v_new_shape = (__pyx_v_new_shape + 1);
29981 
29982       /* "View.MemoryView":877
29983  *             new_shape = (stop - start) // step
29984  *
29985  *             if (stop - start) - step * new_shape:             # <<<<<<<<<<<<<<
29986  *                 new_shape += 1
29987  *
29988  */
29989     }
29990 
29991     /* "View.MemoryView":880
29992  *                 new_shape += 1
29993  *
29994  *         if new_shape < 0:             # <<<<<<<<<<<<<<
29995  *             new_shape = 0
29996  *
29997  */
29998     __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0);
29999     if (__pyx_t_2) {
30000 
30001       /* "View.MemoryView":881
30002  *
30003  *         if new_shape < 0:
30004  *             new_shape = 0             # <<<<<<<<<<<<<<
30005  *
30006  *
30007  */
30008       __pyx_v_new_shape = 0;
30009 
30010       /* "View.MemoryView":880
30011  *                 new_shape += 1
30012  *
30013  *         if new_shape < 0:             # <<<<<<<<<<<<<<
30014  *             new_shape = 0
30015  *
30016  */
30017     }
30018 
30019     /* "View.MemoryView":884
30020  *
30021  *
30022  *         dst.strides[new_ndim] = stride * step             # <<<<<<<<<<<<<<
30023  *         dst.shape[new_ndim] = new_shape
30024  *         dst.suboffsets[new_ndim] = suboffset
30025  */
30026     (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step);
30027 
30028     /* "View.MemoryView":885
30029  *
30030  *         dst.strides[new_ndim] = stride * step
30031  *         dst.shape[new_ndim] = new_shape             # <<<<<<<<<<<<<<
30032  *         dst.suboffsets[new_ndim] = suboffset
30033  *
30034  */
30035     (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape;
30036 
30037     /* "View.MemoryView":886
30038  *         dst.strides[new_ndim] = stride * step
30039  *         dst.shape[new_ndim] = new_shape
30040  *         dst.suboffsets[new_ndim] = suboffset             # <<<<<<<<<<<<<<
30041  *
30042  *
30043  */
30044     (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset;
30045   }
30046   __pyx_L3:;
30047 
30048   /* "View.MemoryView":889
30049  *
30050  *
30051  *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
30052  *         dst.data += start * stride
30053  *     else:
30054  */
30055   __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0);
30056   if (__pyx_t_2) {
30057 
30058     /* "View.MemoryView":890
30059  *
30060  *     if suboffset_dim[0] < 0:
30061  *         dst.data += start * stride             # <<<<<<<<<<<<<<
30062  *     else:
30063  *         dst.suboffsets[suboffset_dim[0]] += start * stride
30064  */
30065     __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride));
30066 
30067     /* "View.MemoryView":889
30068  *
30069  *
30070  *     if suboffset_dim[0] < 0:             # <<<<<<<<<<<<<<
30071  *         dst.data += start * stride
30072  *     else:
30073  */
30074     goto __pyx_L23;
30075   }
30076 
30077   /* "View.MemoryView":892
30078  *         dst.data += start * stride
30079  *     else:
30080  *         dst.suboffsets[suboffset_dim[0]] += start * stride             # <<<<<<<<<<<<<<
30081  *
30082  *     if suboffset >= 0:
30083  */
30084   /*else*/ {
30085     __pyx_t_3 = (__pyx_v_suboffset_dim[0]);
30086     (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride));
30087   }
30088   __pyx_L23:;
30089 
30090   /* "View.MemoryView":894
30091  *         dst.suboffsets[suboffset_dim[0]] += start * stride
30092  *
30093  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
30094  *         if not is_slice:
30095  *             if new_ndim == 0:
30096  */
30097   __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
30098   if (__pyx_t_2) {
30099 
30100     /* "View.MemoryView":895
30101  *
30102  *     if suboffset >= 0:
30103  *         if not is_slice:             # <<<<<<<<<<<<<<
30104  *             if new_ndim == 0:
30105  *                 dst.data = (<char **> dst.data)[0] + suboffset
30106  */
30107     __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
30108     if (__pyx_t_2) {
30109 
30110       /* "View.MemoryView":896
30111  *     if suboffset >= 0:
30112  *         if not is_slice:
30113  *             if new_ndim == 0:             # <<<<<<<<<<<<<<
30114  *                 dst.data = (<char **> dst.data)[0] + suboffset
30115  *             else:
30116  */
30117       __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
30118       if (__pyx_t_2) {
30119 
30120         /* "View.MemoryView":897
30121  *         if not is_slice:
30122  *             if new_ndim == 0:
30123  *                 dst.data = (<char **> dst.data)[0] + suboffset             # <<<<<<<<<<<<<<
30124  *             else:
30125  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
30126  */
30127         __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset);
30128 
30129         /* "View.MemoryView":896
30130  *     if suboffset >= 0:
30131  *         if not is_slice:
30132  *             if new_ndim == 0:             # <<<<<<<<<<<<<<
30133  *                 dst.data = (<char **> dst.data)[0] + suboffset
30134  *             else:
30135  */
30136         goto __pyx_L26;
30137       }
30138 
30139       /* "View.MemoryView":899
30140  *                 dst.data = (<char **> dst.data)[0] + suboffset
30141  *             else:
30142  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "             # <<<<<<<<<<<<<<
30143  *                                      "must be indexed and not sliced", dim)
30144  *         else:
30145  */
30146       /*else*/ {
30147 
30148         /* "View.MemoryView":900
30149  *             else:
30150  *                 _err_dim(IndexError, "All dimensions preceding dimension %d "
30151  *                                      "must be indexed and not sliced", dim)             # <<<<<<<<<<<<<<
30152  *         else:
30153  *             suboffset_dim[0] = new_ndim
30154  */
30155         __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)
30156       }
30157       __pyx_L26:;
30158 
30159       /* "View.MemoryView":895
30160  *
30161  *     if suboffset >= 0:
30162  *         if not is_slice:             # <<<<<<<<<<<<<<
30163  *             if new_ndim == 0:
30164  *                 dst.data = (<char **> dst.data)[0] + suboffset
30165  */
30166       goto __pyx_L25;
30167     }
30168 
30169     /* "View.MemoryView":902
30170  *                                      "must be indexed and not sliced", dim)
30171  *         else:
30172  *             suboffset_dim[0] = new_ndim             # <<<<<<<<<<<<<<
30173  *
30174  *     return 0
30175  */
30176     /*else*/ {
30177       (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim;
30178     }
30179     __pyx_L25:;
30180 
30181     /* "View.MemoryView":894
30182  *         dst.suboffsets[suboffset_dim[0]] += start * stride
30183  *
30184  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
30185  *         if not is_slice:
30186  *             if new_ndim == 0:
30187  */
30188   }
30189 
30190   /* "View.MemoryView":904
30191  *             suboffset_dim[0] = new_ndim
30192  *
30193  *     return 0             # <<<<<<<<<<<<<<
30194  *
30195  *
30196  */
30197   __pyx_r = 0;
30198   goto __pyx_L0;
30199 
30200   /* "View.MemoryView":807
30201  *
30202  * @cname('__pyx_memoryview_slice_memviewslice')
30203  * cdef int slice_memviewslice(             # <<<<<<<<<<<<<<
30204  *         __Pyx_memviewslice *dst,
30205  *         Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
30206  */
30207 
30208   /* function exit code */
30209   __pyx_L1_error:;
30210   {
30211     #ifdef WITH_THREAD
30212     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
30213     #endif
30214     __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
30215     #ifdef WITH_THREAD
30216     __Pyx_PyGILState_Release(__pyx_gilstate_save);
30217     #endif
30218   }
30219   __pyx_r = -1;
30220   __pyx_L0:;
30221   return __pyx_r;
30222 }
30223 
30224 /* "View.MemoryView":910
30225  *
30226  * @cname('__pyx_pybuffer_index')
30227  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
30228  *                           Py_ssize_t dim) except NULL:
30229  *     cdef Py_ssize_t shape, stride, suboffset = -1
30230  */
30231 
__pyx_pybuffer_index(Py_buffer * __pyx_v_view,char * __pyx_v_bufp,Py_ssize_t __pyx_v_index,Py_ssize_t __pyx_v_dim)30232 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) {
30233   Py_ssize_t __pyx_v_shape;
30234   Py_ssize_t __pyx_v_stride;
30235   Py_ssize_t __pyx_v_suboffset;
30236   Py_ssize_t __pyx_v_itemsize;
30237   char *__pyx_v_resultp;
30238   char *__pyx_r;
30239   __Pyx_RefNannyDeclarations
30240   Py_ssize_t __pyx_t_1;
30241   int __pyx_t_2;
30242   PyObject *__pyx_t_3 = NULL;
30243   PyObject *__pyx_t_4 = NULL;
30244   int __pyx_lineno = 0;
30245   const char *__pyx_filename = NULL;
30246   int __pyx_clineno = 0;
30247   __Pyx_RefNannySetupContext("pybuffer_index", 0);
30248 
30249   /* "View.MemoryView":912
30250  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
30251  *                           Py_ssize_t dim) except NULL:
30252  *     cdef Py_ssize_t shape, stride, suboffset = -1             # <<<<<<<<<<<<<<
30253  *     cdef Py_ssize_t itemsize = view.itemsize
30254  *     cdef char *resultp
30255  */
30256   __pyx_v_suboffset = -1L;
30257 
30258   /* "View.MemoryView":913
30259  *                           Py_ssize_t dim) except NULL:
30260  *     cdef Py_ssize_t shape, stride, suboffset = -1
30261  *     cdef Py_ssize_t itemsize = view.itemsize             # <<<<<<<<<<<<<<
30262  *     cdef char *resultp
30263  *
30264  */
30265   __pyx_t_1 = __pyx_v_view->itemsize;
30266   __pyx_v_itemsize = __pyx_t_1;
30267 
30268   /* "View.MemoryView":916
30269  *     cdef char *resultp
30270  *
30271  *     if view.ndim == 0:             # <<<<<<<<<<<<<<
30272  *         shape = view.len / itemsize
30273  *         stride = itemsize
30274  */
30275   __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0);
30276   if (__pyx_t_2) {
30277 
30278     /* "View.MemoryView":917
30279  *
30280  *     if view.ndim == 0:
30281  *         shape = view.len / itemsize             # <<<<<<<<<<<<<<
30282  *         stride = itemsize
30283  *     else:
30284  */
30285     if (unlikely(__pyx_v_itemsize == 0)) {
30286       PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
30287       __PYX_ERR(2, 917, __pyx_L1_error)
30288     }
30289     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))) {
30290       PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
30291       __PYX_ERR(2, 917, __pyx_L1_error)
30292     }
30293     __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);
30294 
30295     /* "View.MemoryView":918
30296  *     if view.ndim == 0:
30297  *         shape = view.len / itemsize
30298  *         stride = itemsize             # <<<<<<<<<<<<<<
30299  *     else:
30300  *         shape = view.shape[dim]
30301  */
30302     __pyx_v_stride = __pyx_v_itemsize;
30303 
30304     /* "View.MemoryView":916
30305  *     cdef char *resultp
30306  *
30307  *     if view.ndim == 0:             # <<<<<<<<<<<<<<
30308  *         shape = view.len / itemsize
30309  *         stride = itemsize
30310  */
30311     goto __pyx_L3;
30312   }
30313 
30314   /* "View.MemoryView":920
30315  *         stride = itemsize
30316  *     else:
30317  *         shape = view.shape[dim]             # <<<<<<<<<<<<<<
30318  *         stride = view.strides[dim]
30319  *         if view.suboffsets != NULL:
30320  */
30321   /*else*/ {
30322     __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]);
30323 
30324     /* "View.MemoryView":921
30325  *     else:
30326  *         shape = view.shape[dim]
30327  *         stride = view.strides[dim]             # <<<<<<<<<<<<<<
30328  *         if view.suboffsets != NULL:
30329  *             suboffset = view.suboffsets[dim]
30330  */
30331     __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]);
30332 
30333     /* "View.MemoryView":922
30334  *         shape = view.shape[dim]
30335  *         stride = view.strides[dim]
30336  *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
30337  *             suboffset = view.suboffsets[dim]
30338  *
30339  */
30340     __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0);
30341     if (__pyx_t_2) {
30342 
30343       /* "View.MemoryView":923
30344  *         stride = view.strides[dim]
30345  *         if view.suboffsets != NULL:
30346  *             suboffset = view.suboffsets[dim]             # <<<<<<<<<<<<<<
30347  *
30348  *     if index < 0:
30349  */
30350       __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]);
30351 
30352       /* "View.MemoryView":922
30353  *         shape = view.shape[dim]
30354  *         stride = view.strides[dim]
30355  *         if view.suboffsets != NULL:             # <<<<<<<<<<<<<<
30356  *             suboffset = view.suboffsets[dim]
30357  *
30358  */
30359     }
30360   }
30361   __pyx_L3:;
30362 
30363   /* "View.MemoryView":925
30364  *             suboffset = view.suboffsets[dim]
30365  *
30366  *     if index < 0:             # <<<<<<<<<<<<<<
30367  *         index += view.shape[dim]
30368  *         if index < 0:
30369  */
30370   __pyx_t_2 = ((__pyx_v_index < 0) != 0);
30371   if (__pyx_t_2) {
30372 
30373     /* "View.MemoryView":926
30374  *
30375  *     if index < 0:
30376  *         index += view.shape[dim]             # <<<<<<<<<<<<<<
30377  *         if index < 0:
30378  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
30379  */
30380     __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim]));
30381 
30382     /* "View.MemoryView":927
30383  *     if index < 0:
30384  *         index += view.shape[dim]
30385  *         if index < 0:             # <<<<<<<<<<<<<<
30386  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
30387  *
30388  */
30389     __pyx_t_2 = ((__pyx_v_index < 0) != 0);
30390     if (unlikely(__pyx_t_2)) {
30391 
30392       /* "View.MemoryView":928
30393  *         index += view.shape[dim]
30394  *         if index < 0:
30395  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
30396  *
30397  *     if index >= shape:
30398  */
30399       __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 928, __pyx_L1_error)
30400       __Pyx_GOTREF(__pyx_t_3);
30401       __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)
30402       __Pyx_GOTREF(__pyx_t_4);
30403       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
30404       __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 928, __pyx_L1_error)
30405       __Pyx_GOTREF(__pyx_t_3);
30406       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
30407       __Pyx_Raise(__pyx_t_3, 0, 0, 0);
30408       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
30409       __PYX_ERR(2, 928, __pyx_L1_error)
30410 
30411       /* "View.MemoryView":927
30412  *     if index < 0:
30413  *         index += view.shape[dim]
30414  *         if index < 0:             # <<<<<<<<<<<<<<
30415  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
30416  *
30417  */
30418     }
30419 
30420     /* "View.MemoryView":925
30421  *             suboffset = view.suboffsets[dim]
30422  *
30423  *     if index < 0:             # <<<<<<<<<<<<<<
30424  *         index += view.shape[dim]
30425  *         if index < 0:
30426  */
30427   }
30428 
30429   /* "View.MemoryView":930
30430  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
30431  *
30432  *     if index >= shape:             # <<<<<<<<<<<<<<
30433  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
30434  *
30435  */
30436   __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0);
30437   if (unlikely(__pyx_t_2)) {
30438 
30439     /* "View.MemoryView":931
30440  *
30441  *     if index >= shape:
30442  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)             # <<<<<<<<<<<<<<
30443  *
30444  *     resultp = bufp + index * stride
30445  */
30446     __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 931, __pyx_L1_error)
30447     __Pyx_GOTREF(__pyx_t_3);
30448     __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)
30449     __Pyx_GOTREF(__pyx_t_4);
30450     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
30451     __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 931, __pyx_L1_error)
30452     __Pyx_GOTREF(__pyx_t_3);
30453     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
30454     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
30455     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
30456     __PYX_ERR(2, 931, __pyx_L1_error)
30457 
30458     /* "View.MemoryView":930
30459  *             raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
30460  *
30461  *     if index >= shape:             # <<<<<<<<<<<<<<
30462  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
30463  *
30464  */
30465   }
30466 
30467   /* "View.MemoryView":933
30468  *         raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
30469  *
30470  *     resultp = bufp + index * stride             # <<<<<<<<<<<<<<
30471  *     if suboffset >= 0:
30472  *         resultp = (<char **> resultp)[0] + suboffset
30473  */
30474   __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));
30475 
30476   /* "View.MemoryView":934
30477  *
30478  *     resultp = bufp + index * stride
30479  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
30480  *         resultp = (<char **> resultp)[0] + suboffset
30481  *
30482  */
30483   __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
30484   if (__pyx_t_2) {
30485 
30486     /* "View.MemoryView":935
30487  *     resultp = bufp + index * stride
30488  *     if suboffset >= 0:
30489  *         resultp = (<char **> resultp)[0] + suboffset             # <<<<<<<<<<<<<<
30490  *
30491  *     return resultp
30492  */
30493     __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);
30494 
30495     /* "View.MemoryView":934
30496  *
30497  *     resultp = bufp + index * stride
30498  *     if suboffset >= 0:             # <<<<<<<<<<<<<<
30499  *         resultp = (<char **> resultp)[0] + suboffset
30500  *
30501  */
30502   }
30503 
30504   /* "View.MemoryView":937
30505  *         resultp = (<char **> resultp)[0] + suboffset
30506  *
30507  *     return resultp             # <<<<<<<<<<<<<<
30508  *
30509  *
30510  */
30511   __pyx_r = __pyx_v_resultp;
30512   goto __pyx_L0;
30513 
30514   /* "View.MemoryView":910
30515  *
30516  * @cname('__pyx_pybuffer_index')
30517  * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,             # <<<<<<<<<<<<<<
30518  *                           Py_ssize_t dim) except NULL:
30519  *     cdef Py_ssize_t shape, stride, suboffset = -1
30520  */
30521 
30522   /* function exit code */
30523   __pyx_L1_error:;
30524   __Pyx_XDECREF(__pyx_t_3);
30525   __Pyx_XDECREF(__pyx_t_4);
30526   __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
30527   __pyx_r = NULL;
30528   __pyx_L0:;
30529   __Pyx_RefNannyFinishContext();
30530   return __pyx_r;
30531 }
30532 
30533 /* "View.MemoryView":943
30534  *
30535  * @cname('__pyx_memslice_transpose')
30536  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
30537  *     cdef int ndim = memslice.memview.view.ndim
30538  *
30539  */
30540 
__pyx_memslice_transpose(__Pyx_memviewslice * __pyx_v_memslice)30541 static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
30542   int __pyx_v_ndim;
30543   Py_ssize_t *__pyx_v_shape;
30544   Py_ssize_t *__pyx_v_strides;
30545   int __pyx_v_i;
30546   int __pyx_v_j;
30547   int __pyx_r;
30548   int __pyx_t_1;
30549   Py_ssize_t *__pyx_t_2;
30550   long __pyx_t_3;
30551   long __pyx_t_4;
30552   Py_ssize_t __pyx_t_5;
30553   Py_ssize_t __pyx_t_6;
30554   int __pyx_t_7;
30555   int __pyx_t_8;
30556   int __pyx_t_9;
30557   int __pyx_lineno = 0;
30558   const char *__pyx_filename = NULL;
30559   int __pyx_clineno = 0;
30560 
30561   /* "View.MemoryView":944
30562  * @cname('__pyx_memslice_transpose')
30563  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:
30564  *     cdef int ndim = memslice.memview.view.ndim             # <<<<<<<<<<<<<<
30565  *
30566  *     cdef Py_ssize_t *shape = memslice.shape
30567  */
30568   __pyx_t_1 = __pyx_v_memslice->memview->view.ndim;
30569   __pyx_v_ndim = __pyx_t_1;
30570 
30571   /* "View.MemoryView":946
30572  *     cdef int ndim = memslice.memview.view.ndim
30573  *
30574  *     cdef Py_ssize_t *shape = memslice.shape             # <<<<<<<<<<<<<<
30575  *     cdef Py_ssize_t *strides = memslice.strides
30576  *
30577  */
30578   __pyx_t_2 = __pyx_v_memslice->shape;
30579   __pyx_v_shape = __pyx_t_2;
30580 
30581   /* "View.MemoryView":947
30582  *
30583  *     cdef Py_ssize_t *shape = memslice.shape
30584  *     cdef Py_ssize_t *strides = memslice.strides             # <<<<<<<<<<<<<<
30585  *
30586  *
30587  */
30588   __pyx_t_2 = __pyx_v_memslice->strides;
30589   __pyx_v_strides = __pyx_t_2;
30590 
30591   /* "View.MemoryView":951
30592  *
30593  *     cdef int i, j
30594  *     for i in range(ndim / 2):             # <<<<<<<<<<<<<<
30595  *         j = ndim - 1 - i
30596  *         strides[i], strides[j] = strides[j], strides[i]
30597  */
30598   __pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2);
30599   __pyx_t_4 = __pyx_t_3;
30600   for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_4; __pyx_t_1+=1) {
30601     __pyx_v_i = __pyx_t_1;
30602 
30603     /* "View.MemoryView":952
30604  *     cdef int i, j
30605  *     for i in range(ndim / 2):
30606  *         j = ndim - 1 - i             # <<<<<<<<<<<<<<
30607  *         strides[i], strides[j] = strides[j], strides[i]
30608  *         shape[i], shape[j] = shape[j], shape[i]
30609  */
30610     __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i);
30611 
30612     /* "View.MemoryView":953
30613  *     for i in range(ndim / 2):
30614  *         j = ndim - 1 - i
30615  *         strides[i], strides[j] = strides[j], strides[i]             # <<<<<<<<<<<<<<
30616  *         shape[i], shape[j] = shape[j], shape[i]
30617  *
30618  */
30619     __pyx_t_5 = (__pyx_v_strides[__pyx_v_j]);
30620     __pyx_t_6 = (__pyx_v_strides[__pyx_v_i]);
30621     (__pyx_v_strides[__pyx_v_i]) = __pyx_t_5;
30622     (__pyx_v_strides[__pyx_v_j]) = __pyx_t_6;
30623 
30624     /* "View.MemoryView":954
30625  *         j = ndim - 1 - i
30626  *         strides[i], strides[j] = strides[j], strides[i]
30627  *         shape[i], shape[j] = shape[j], shape[i]             # <<<<<<<<<<<<<<
30628  *
30629  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
30630  */
30631     __pyx_t_6 = (__pyx_v_shape[__pyx_v_j]);
30632     __pyx_t_5 = (__pyx_v_shape[__pyx_v_i]);
30633     (__pyx_v_shape[__pyx_v_i]) = __pyx_t_6;
30634     (__pyx_v_shape[__pyx_v_j]) = __pyx_t_5;
30635 
30636     /* "View.MemoryView":956
30637  *         shape[i], shape[j] = shape[j], shape[i]
30638  *
30639  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
30640  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
30641  *
30642  */
30643     __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
30644     if (!__pyx_t_8) {
30645     } else {
30646       __pyx_t_7 = __pyx_t_8;
30647       goto __pyx_L6_bool_binop_done;
30648     }
30649     __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
30650     __pyx_t_7 = __pyx_t_8;
30651     __pyx_L6_bool_binop_done:;
30652     if (__pyx_t_7) {
30653 
30654       /* "View.MemoryView":957
30655  *
30656  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
30657  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")             # <<<<<<<<<<<<<<
30658  *
30659  *     return 1
30660  */
30661       __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)
30662 
30663       /* "View.MemoryView":956
30664  *         shape[i], shape[j] = shape[j], shape[i]
30665  *
30666  *         if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:             # <<<<<<<<<<<<<<
30667  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
30668  *
30669  */
30670     }
30671   }
30672 
30673   /* "View.MemoryView":959
30674  *             _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
30675  *
30676  *     return 1             # <<<<<<<<<<<<<<
30677  *
30678  *
30679  */
30680   __pyx_r = 1;
30681   goto __pyx_L0;
30682 
30683   /* "View.MemoryView":943
30684  *
30685  * @cname('__pyx_memslice_transpose')
30686  * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:             # <<<<<<<<<<<<<<
30687  *     cdef int ndim = memslice.memview.view.ndim
30688  *
30689  */
30690 
30691   /* function exit code */
30692   __pyx_L1_error:;
30693   {
30694     #ifdef WITH_THREAD
30695     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
30696     #endif
30697     __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
30698     #ifdef WITH_THREAD
30699     __Pyx_PyGILState_Release(__pyx_gilstate_save);
30700     #endif
30701   }
30702   __pyx_r = 0;
30703   __pyx_L0:;
30704   return __pyx_r;
30705 }
30706 
30707 /* "View.MemoryView":976
30708  *     cdef int (*to_dtype_func)(char *, object) except 0
30709  *
30710  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
30711  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
30712  *
30713  */
30714 
30715 /* Python wrapper */
30716 static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/
__pyx_memoryviewslice___dealloc__(PyObject * __pyx_v_self)30717 static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
30718   __Pyx_RefNannyDeclarations
30719   __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
30720   __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
30721 
30722   /* function exit code */
30723   __Pyx_RefNannyFinishContext();
30724 }
30725 
__pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj * __pyx_v_self)30726 static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
30727   __Pyx_RefNannyDeclarations
30728   __Pyx_RefNannySetupContext("__dealloc__", 0);
30729 
30730   /* "View.MemoryView":977
30731  *
30732  *     def __dealloc__(self):
30733  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)             # <<<<<<<<<<<<<<
30734  *
30735  *     cdef convert_item_to_object(self, char *itemp):
30736  */
30737   __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1);
30738 
30739   /* "View.MemoryView":976
30740  *     cdef int (*to_dtype_func)(char *, object) except 0
30741  *
30742  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
30743  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
30744  *
30745  */
30746 
30747   /* function exit code */
30748   __Pyx_RefNannyFinishContext();
30749 }
30750 
30751 /* "View.MemoryView":979
30752  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
30753  *
30754  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
30755  *         if self.to_object_func != NULL:
30756  *             return self.to_object_func(itemp)
30757  */
30758 
__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj * __pyx_v_self,char * __pyx_v_itemp)30759 static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) {
30760   PyObject *__pyx_r = NULL;
30761   __Pyx_RefNannyDeclarations
30762   int __pyx_t_1;
30763   PyObject *__pyx_t_2 = NULL;
30764   int __pyx_lineno = 0;
30765   const char *__pyx_filename = NULL;
30766   int __pyx_clineno = 0;
30767   __Pyx_RefNannySetupContext("convert_item_to_object", 0);
30768 
30769   /* "View.MemoryView":980
30770  *
30771  *     cdef convert_item_to_object(self, char *itemp):
30772  *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
30773  *             return self.to_object_func(itemp)
30774  *         else:
30775  */
30776   __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0);
30777   if (__pyx_t_1) {
30778 
30779     /* "View.MemoryView":981
30780  *     cdef convert_item_to_object(self, char *itemp):
30781  *         if self.to_object_func != NULL:
30782  *             return self.to_object_func(itemp)             # <<<<<<<<<<<<<<
30783  *         else:
30784  *             return memoryview.convert_item_to_object(self, itemp)
30785  */
30786     __Pyx_XDECREF(__pyx_r);
30787     __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 981, __pyx_L1_error)
30788     __Pyx_GOTREF(__pyx_t_2);
30789     __pyx_r = __pyx_t_2;
30790     __pyx_t_2 = 0;
30791     goto __pyx_L0;
30792 
30793     /* "View.MemoryView":980
30794  *
30795  *     cdef convert_item_to_object(self, char *itemp):
30796  *         if self.to_object_func != NULL:             # <<<<<<<<<<<<<<
30797  *             return self.to_object_func(itemp)
30798  *         else:
30799  */
30800   }
30801 
30802   /* "View.MemoryView":983
30803  *             return self.to_object_func(itemp)
30804  *         else:
30805  *             return memoryview.convert_item_to_object(self, itemp)             # <<<<<<<<<<<<<<
30806  *
30807  *     cdef assign_item_from_object(self, char *itemp, object value):
30808  */
30809   /*else*/ {
30810     __Pyx_XDECREF(__pyx_r);
30811     __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)
30812     __Pyx_GOTREF(__pyx_t_2);
30813     __pyx_r = __pyx_t_2;
30814     __pyx_t_2 = 0;
30815     goto __pyx_L0;
30816   }
30817 
30818   /* "View.MemoryView":979
30819  *         __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
30820  *
30821  *     cdef convert_item_to_object(self, char *itemp):             # <<<<<<<<<<<<<<
30822  *         if self.to_object_func != NULL:
30823  *             return self.to_object_func(itemp)
30824  */
30825 
30826   /* function exit code */
30827   __pyx_L1_error:;
30828   __Pyx_XDECREF(__pyx_t_2);
30829   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
30830   __pyx_r = 0;
30831   __pyx_L0:;
30832   __Pyx_XGIVEREF(__pyx_r);
30833   __Pyx_RefNannyFinishContext();
30834   return __pyx_r;
30835 }
30836 
30837 /* "View.MemoryView":985
30838  *             return memoryview.convert_item_to_object(self, itemp)
30839  *
30840  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
30841  *         if self.to_dtype_func != NULL:
30842  *             self.to_dtype_func(itemp, value)
30843  */
30844 
__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj * __pyx_v_self,char * __pyx_v_itemp,PyObject * __pyx_v_value)30845 static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
30846   PyObject *__pyx_r = NULL;
30847   __Pyx_RefNannyDeclarations
30848   int __pyx_t_1;
30849   int __pyx_t_2;
30850   PyObject *__pyx_t_3 = NULL;
30851   int __pyx_lineno = 0;
30852   const char *__pyx_filename = NULL;
30853   int __pyx_clineno = 0;
30854   __Pyx_RefNannySetupContext("assign_item_from_object", 0);
30855 
30856   /* "View.MemoryView":986
30857  *
30858  *     cdef assign_item_from_object(self, char *itemp, object value):
30859  *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
30860  *             self.to_dtype_func(itemp, value)
30861  *         else:
30862  */
30863   __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0);
30864   if (__pyx_t_1) {
30865 
30866     /* "View.MemoryView":987
30867  *     cdef assign_item_from_object(self, char *itemp, object value):
30868  *         if self.to_dtype_func != NULL:
30869  *             self.to_dtype_func(itemp, value)             # <<<<<<<<<<<<<<
30870  *         else:
30871  *             memoryview.assign_item_from_object(self, itemp, value)
30872  */
30873     __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)
30874 
30875     /* "View.MemoryView":986
30876  *
30877  *     cdef assign_item_from_object(self, char *itemp, object value):
30878  *         if self.to_dtype_func != NULL:             # <<<<<<<<<<<<<<
30879  *             self.to_dtype_func(itemp, value)
30880  *         else:
30881  */
30882     goto __pyx_L3;
30883   }
30884 
30885   /* "View.MemoryView":989
30886  *             self.to_dtype_func(itemp, value)
30887  *         else:
30888  *             memoryview.assign_item_from_object(self, itemp, value)             # <<<<<<<<<<<<<<
30889  *
30890  *     @property
30891  */
30892   /*else*/ {
30893     __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)
30894     __Pyx_GOTREF(__pyx_t_3);
30895     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
30896   }
30897   __pyx_L3:;
30898 
30899   /* "View.MemoryView":985
30900  *             return memoryview.convert_item_to_object(self, itemp)
30901  *
30902  *     cdef assign_item_from_object(self, char *itemp, object value):             # <<<<<<<<<<<<<<
30903  *         if self.to_dtype_func != NULL:
30904  *             self.to_dtype_func(itemp, value)
30905  */
30906 
30907   /* function exit code */
30908   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
30909   goto __pyx_L0;
30910   __pyx_L1_error:;
30911   __Pyx_XDECREF(__pyx_t_3);
30912   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
30913   __pyx_r = 0;
30914   __pyx_L0:;
30915   __Pyx_XGIVEREF(__pyx_r);
30916   __Pyx_RefNannyFinishContext();
30917   return __pyx_r;
30918 }
30919 
30920 /* "View.MemoryView":992
30921  *
30922  *     @property
30923  *     def base(self):             # <<<<<<<<<<<<<<
30924  *         return self.from_object
30925  *
30926  */
30927 
30928 /* Python wrapper */
30929 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)30930 static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) {
30931   PyObject *__pyx_r = 0;
30932   __Pyx_RefNannyDeclarations
30933   __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
30934   __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
30935 
30936   /* function exit code */
30937   __Pyx_RefNannyFinishContext();
30938   return __pyx_r;
30939 }
30940 
__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj * __pyx_v_self)30941 static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
30942   PyObject *__pyx_r = NULL;
30943   __Pyx_RefNannyDeclarations
30944   __Pyx_RefNannySetupContext("__get__", 0);
30945 
30946   /* "View.MemoryView":993
30947  *     @property
30948  *     def base(self):
30949  *         return self.from_object             # <<<<<<<<<<<<<<
30950  *
30951  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
30952  */
30953   __Pyx_XDECREF(__pyx_r);
30954   __Pyx_INCREF(__pyx_v_self->from_object);
30955   __pyx_r = __pyx_v_self->from_object;
30956   goto __pyx_L0;
30957 
30958   /* "View.MemoryView":992
30959  *
30960  *     @property
30961  *     def base(self):             # <<<<<<<<<<<<<<
30962  *         return self.from_object
30963  *
30964  */
30965 
30966   /* function exit code */
30967   __pyx_L0:;
30968   __Pyx_XGIVEREF(__pyx_r);
30969   __Pyx_RefNannyFinishContext();
30970   return __pyx_r;
30971 }
30972 
30973 /* "(tree fragment)":1
30974  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
30975  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
30976  * def __setstate_cython__(self, __pyx_state):
30977  */
30978 
30979 /* Python wrapper */
30980 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)30981 static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
30982   PyObject *__pyx_r = 0;
30983   __Pyx_RefNannyDeclarations
30984   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
30985   __pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
30986 
30987   /* function exit code */
30988   __Pyx_RefNannyFinishContext();
30989   return __pyx_r;
30990 }
30991 
__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj * __pyx_v_self)30992 static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) {
30993   PyObject *__pyx_r = NULL;
30994   __Pyx_RefNannyDeclarations
30995   PyObject *__pyx_t_1 = NULL;
30996   int __pyx_lineno = 0;
30997   const char *__pyx_filename = NULL;
30998   int __pyx_clineno = 0;
30999   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
31000 
31001   /* "(tree fragment)":2
31002  * def __reduce_cython__(self):
31003  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
31004  * def __setstate_cython__(self, __pyx_state):
31005  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
31006  */
31007   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 2, __pyx_L1_error)
31008   __Pyx_GOTREF(__pyx_t_1);
31009   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
31010   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
31011   __PYX_ERR(2, 2, __pyx_L1_error)
31012 
31013   /* "(tree fragment)":1
31014  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
31015  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
31016  * def __setstate_cython__(self, __pyx_state):
31017  */
31018 
31019   /* function exit code */
31020   __pyx_L1_error:;
31021   __Pyx_XDECREF(__pyx_t_1);
31022   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
31023   __pyx_r = NULL;
31024   __Pyx_XGIVEREF(__pyx_r);
31025   __Pyx_RefNannyFinishContext();
31026   return __pyx_r;
31027 }
31028 
31029 /* "(tree fragment)":3
31030  * def __reduce_cython__(self):
31031  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
31032  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
31033  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
31034  */
31035 
31036 /* Python wrapper */
31037 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)31038 static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
31039   PyObject *__pyx_r = 0;
31040   __Pyx_RefNannyDeclarations
31041   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
31042   __pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
31043 
31044   /* function exit code */
31045   __Pyx_RefNannyFinishContext();
31046   return __pyx_r;
31047 }
31048 
__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)31049 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) {
31050   PyObject *__pyx_r = NULL;
31051   __Pyx_RefNannyDeclarations
31052   PyObject *__pyx_t_1 = NULL;
31053   int __pyx_lineno = 0;
31054   const char *__pyx_filename = NULL;
31055   int __pyx_clineno = 0;
31056   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
31057 
31058   /* "(tree fragment)":4
31059  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
31060  * def __setstate_cython__(self, __pyx_state):
31061  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
31062  */
31063   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
31064   __Pyx_GOTREF(__pyx_t_1);
31065   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
31066   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
31067   __PYX_ERR(2, 4, __pyx_L1_error)
31068 
31069   /* "(tree fragment)":3
31070  * def __reduce_cython__(self):
31071  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
31072  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
31073  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
31074  */
31075 
31076   /* function exit code */
31077   __pyx_L1_error:;
31078   __Pyx_XDECREF(__pyx_t_1);
31079   __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
31080   __pyx_r = NULL;
31081   __Pyx_XGIVEREF(__pyx_r);
31082   __Pyx_RefNannyFinishContext();
31083   return __pyx_r;
31084 }
31085 
31086 /* "View.MemoryView":999
31087  *
31088  * @cname('__pyx_memoryview_fromslice')
31089  * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
31090  *                           int ndim,
31091  *                           object (*to_object_func)(char *),
31092  */
31093 
__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)31094 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) {
31095   struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
31096   Py_ssize_t __pyx_v_suboffset;
31097   PyObject *__pyx_v_length = NULL;
31098   PyObject *__pyx_r = NULL;
31099   __Pyx_RefNannyDeclarations
31100   int __pyx_t_1;
31101   PyObject *__pyx_t_2 = NULL;
31102   PyObject *__pyx_t_3 = NULL;
31103   __Pyx_TypeInfo *__pyx_t_4;
31104   Py_buffer __pyx_t_5;
31105   Py_ssize_t *__pyx_t_6;
31106   Py_ssize_t *__pyx_t_7;
31107   Py_ssize_t *__pyx_t_8;
31108   Py_ssize_t __pyx_t_9;
31109   int __pyx_lineno = 0;
31110   const char *__pyx_filename = NULL;
31111   int __pyx_clineno = 0;
31112   __Pyx_RefNannySetupContext("memoryview_fromslice", 0);
31113 
31114   /* "View.MemoryView":1007
31115  *     cdef _memoryviewslice result
31116  *
31117  *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
31118  *         return None
31119  *
31120  */
31121   __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
31122   if (__pyx_t_1) {
31123 
31124     /* "View.MemoryView":1008
31125  *
31126  *     if <PyObject *> memviewslice.memview == Py_None:
31127  *         return None             # <<<<<<<<<<<<<<
31128  *
31129  *
31130  */
31131     __Pyx_XDECREF(__pyx_r);
31132     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
31133     goto __pyx_L0;
31134 
31135     /* "View.MemoryView":1007
31136  *     cdef _memoryviewslice result
31137  *
31138  *     if <PyObject *> memviewslice.memview == Py_None:             # <<<<<<<<<<<<<<
31139  *         return None
31140  *
31141  */
31142   }
31143 
31144   /* "View.MemoryView":1013
31145  *
31146  *
31147  *     result = _memoryviewslice(None, 0, dtype_is_object)             # <<<<<<<<<<<<<<
31148  *
31149  *     result.from_slice = memviewslice
31150  */
31151   __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1013, __pyx_L1_error)
31152   __Pyx_GOTREF(__pyx_t_2);
31153   __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1013, __pyx_L1_error)
31154   __Pyx_GOTREF(__pyx_t_3);
31155   __Pyx_INCREF(Py_None);
31156   __Pyx_GIVEREF(Py_None);
31157   PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
31158   __Pyx_INCREF(__pyx_int_0);
31159   __Pyx_GIVEREF(__pyx_int_0);
31160   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
31161   __Pyx_GIVEREF(__pyx_t_2);
31162   PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
31163   __pyx_t_2 = 0;
31164   __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)
31165   __Pyx_GOTREF(__pyx_t_2);
31166   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
31167   __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2);
31168   __pyx_t_2 = 0;
31169 
31170   /* "View.MemoryView":1015
31171  *     result = _memoryviewslice(None, 0, dtype_is_object)
31172  *
31173  *     result.from_slice = memviewslice             # <<<<<<<<<<<<<<
31174  *     __PYX_INC_MEMVIEW(&memviewslice, 1)
31175  *
31176  */
31177   __pyx_v_result->from_slice = __pyx_v_memviewslice;
31178 
31179   /* "View.MemoryView":1016
31180  *
31181  *     result.from_slice = memviewslice
31182  *     __PYX_INC_MEMVIEW(&memviewslice, 1)             # <<<<<<<<<<<<<<
31183  *
31184  *     result.from_object = (<memoryview> memviewslice.memview).base
31185  */
31186   __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);
31187 
31188   /* "View.MemoryView":1018
31189  *     __PYX_INC_MEMVIEW(&memviewslice, 1)
31190  *
31191  *     result.from_object = (<memoryview> memviewslice.memview).base             # <<<<<<<<<<<<<<
31192  *     result.typeinfo = memviewslice.memview.typeinfo
31193  *
31194  */
31195   __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)
31196   __Pyx_GOTREF(__pyx_t_2);
31197   __Pyx_GIVEREF(__pyx_t_2);
31198   __Pyx_GOTREF(__pyx_v_result->from_object);
31199   __Pyx_DECREF(__pyx_v_result->from_object);
31200   __pyx_v_result->from_object = __pyx_t_2;
31201   __pyx_t_2 = 0;
31202 
31203   /* "View.MemoryView":1019
31204  *
31205  *     result.from_object = (<memoryview> memviewslice.memview).base
31206  *     result.typeinfo = memviewslice.memview.typeinfo             # <<<<<<<<<<<<<<
31207  *
31208  *     result.view = memviewslice.memview.view
31209  */
31210   __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo;
31211   __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4;
31212 
31213   /* "View.MemoryView":1021
31214  *     result.typeinfo = memviewslice.memview.typeinfo
31215  *
31216  *     result.view = memviewslice.memview.view             # <<<<<<<<<<<<<<
31217  *     result.view.buf = <void *> memviewslice.data
31218  *     result.view.ndim = ndim
31219  */
31220   __pyx_t_5 = __pyx_v_memviewslice.memview->view;
31221   __pyx_v_result->__pyx_base.view = __pyx_t_5;
31222 
31223   /* "View.MemoryView":1022
31224  *
31225  *     result.view = memviewslice.memview.view
31226  *     result.view.buf = <void *> memviewslice.data             # <<<<<<<<<<<<<<
31227  *     result.view.ndim = ndim
31228  *     (<__pyx_buffer *> &result.view).obj = Py_None
31229  */
31230   __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data);
31231 
31232   /* "View.MemoryView":1023
31233  *     result.view = memviewslice.memview.view
31234  *     result.view.buf = <void *> memviewslice.data
31235  *     result.view.ndim = ndim             # <<<<<<<<<<<<<<
31236  *     (<__pyx_buffer *> &result.view).obj = Py_None
31237  *     Py_INCREF(Py_None)
31238  */
31239   __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim;
31240 
31241   /* "View.MemoryView":1024
31242  *     result.view.buf = <void *> memviewslice.data
31243  *     result.view.ndim = ndim
31244  *     (<__pyx_buffer *> &result.view).obj = Py_None             # <<<<<<<<<<<<<<
31245  *     Py_INCREF(Py_None)
31246  *
31247  */
31248   ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None;
31249 
31250   /* "View.MemoryView":1025
31251  *     result.view.ndim = ndim
31252  *     (<__pyx_buffer *> &result.view).obj = Py_None
31253  *     Py_INCREF(Py_None)             # <<<<<<<<<<<<<<
31254  *
31255  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
31256  */
31257   Py_INCREF(Py_None);
31258 
31259   /* "View.MemoryView":1027
31260  *     Py_INCREF(Py_None)
31261  *
31262  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
31263  *         result.flags = PyBUF_RECORDS
31264  *     else:
31265  */
31266   __pyx_t_1 = ((((struct __pyx_memoryview_obj *)__pyx_v_memviewslice.memview)->flags & PyBUF_WRITABLE) != 0);
31267   if (__pyx_t_1) {
31268 
31269     /* "View.MemoryView":1028
31270  *
31271  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:
31272  *         result.flags = PyBUF_RECORDS             # <<<<<<<<<<<<<<
31273  *     else:
31274  *         result.flags = PyBUF_RECORDS_RO
31275  */
31276     __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;
31277 
31278     /* "View.MemoryView":1027
31279  *     Py_INCREF(Py_None)
31280  *
31281  *     if (<memoryview>memviewslice.memview).flags & PyBUF_WRITABLE:             # <<<<<<<<<<<<<<
31282  *         result.flags = PyBUF_RECORDS
31283  *     else:
31284  */
31285     goto __pyx_L4;
31286   }
31287 
31288   /* "View.MemoryView":1030
31289  *         result.flags = PyBUF_RECORDS
31290  *     else:
31291  *         result.flags = PyBUF_RECORDS_RO             # <<<<<<<<<<<<<<
31292  *
31293  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
31294  */
31295   /*else*/ {
31296     __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS_RO;
31297   }
31298   __pyx_L4:;
31299 
31300   /* "View.MemoryView":1032
31301  *         result.flags = PyBUF_RECORDS_RO
31302  *
31303  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape             # <<<<<<<<<<<<<<
31304  *     result.view.strides = <Py_ssize_t *> result.from_slice.strides
31305  *
31306  */
31307   __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);
31308 
31309   /* "View.MemoryView":1033
31310  *
31311  *     result.view.shape = <Py_ssize_t *> result.from_slice.shape
31312  *     result.view.strides = <Py_ssize_t *> result.from_slice.strides             # <<<<<<<<<<<<<<
31313  *
31314  *
31315  */
31316   __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);
31317 
31318   /* "View.MemoryView":1036
31319  *
31320  *
31321  *     result.view.suboffsets = NULL             # <<<<<<<<<<<<<<
31322  *     for suboffset in result.from_slice.suboffsets[:ndim]:
31323  *         if suboffset >= 0:
31324  */
31325   __pyx_v_result->__pyx_base.view.suboffsets = NULL;
31326 
31327   /* "View.MemoryView":1037
31328  *
31329  *     result.view.suboffsets = NULL
31330  *     for suboffset in result.from_slice.suboffsets[:ndim]:             # <<<<<<<<<<<<<<
31331  *         if suboffset >= 0:
31332  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
31333  */
31334   __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim);
31335   for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
31336     __pyx_t_6 = __pyx_t_8;
31337     __pyx_v_suboffset = (__pyx_t_6[0]);
31338 
31339     /* "View.MemoryView":1038
31340  *     result.view.suboffsets = NULL
31341  *     for suboffset in result.from_slice.suboffsets[:ndim]:
31342  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
31343  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
31344  *             break
31345  */
31346     __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0);
31347     if (__pyx_t_1) {
31348 
31349       /* "View.MemoryView":1039
31350  *     for suboffset in result.from_slice.suboffsets[:ndim]:
31351  *         if suboffset >= 0:
31352  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets             # <<<<<<<<<<<<<<
31353  *             break
31354  *
31355  */
31356       __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);
31357 
31358       /* "View.MemoryView":1040
31359  *         if suboffset >= 0:
31360  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
31361  *             break             # <<<<<<<<<<<<<<
31362  *
31363  *     result.view.len = result.view.itemsize
31364  */
31365       goto __pyx_L6_break;
31366 
31367       /* "View.MemoryView":1038
31368  *     result.view.suboffsets = NULL
31369  *     for suboffset in result.from_slice.suboffsets[:ndim]:
31370  *         if suboffset >= 0:             # <<<<<<<<<<<<<<
31371  *             result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
31372  *             break
31373  */
31374     }
31375   }
31376   __pyx_L6_break:;
31377 
31378   /* "View.MemoryView":1042
31379  *             break
31380  *
31381  *     result.view.len = result.view.itemsize             # <<<<<<<<<<<<<<
31382  *     for length in result.view.shape[:ndim]:
31383  *         result.view.len *= length
31384  */
31385   __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize;
31386   __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
31387 
31388   /* "View.MemoryView":1043
31389  *
31390  *     result.view.len = result.view.itemsize
31391  *     for length in result.view.shape[:ndim]:             # <<<<<<<<<<<<<<
31392  *         result.view.len *= length
31393  *
31394  */
31395   __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim);
31396   for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
31397     __pyx_t_6 = __pyx_t_8;
31398     __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1043, __pyx_L1_error)
31399     __Pyx_GOTREF(__pyx_t_2);
31400     __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
31401     __pyx_t_2 = 0;
31402 
31403     /* "View.MemoryView":1044
31404  *     result.view.len = result.view.itemsize
31405  *     for length in result.view.shape[:ndim]:
31406  *         result.view.len *= length             # <<<<<<<<<<<<<<
31407  *
31408  *     result.to_object_func = to_object_func
31409  */
31410     __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)
31411     __Pyx_GOTREF(__pyx_t_2);
31412     __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1044, __pyx_L1_error)
31413     __Pyx_GOTREF(__pyx_t_3);
31414     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
31415     __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)
31416     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
31417     __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
31418   }
31419 
31420   /* "View.MemoryView":1046
31421  *         result.view.len *= length
31422  *
31423  *     result.to_object_func = to_object_func             # <<<<<<<<<<<<<<
31424  *     result.to_dtype_func = to_dtype_func
31425  *
31426  */
31427   __pyx_v_result->to_object_func = __pyx_v_to_object_func;
31428 
31429   /* "View.MemoryView":1047
31430  *
31431  *     result.to_object_func = to_object_func
31432  *     result.to_dtype_func = to_dtype_func             # <<<<<<<<<<<<<<
31433  *
31434  *     return result
31435  */
31436   __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func;
31437 
31438   /* "View.MemoryView":1049
31439  *     result.to_dtype_func = to_dtype_func
31440  *
31441  *     return result             # <<<<<<<<<<<<<<
31442  *
31443  * @cname('__pyx_memoryview_get_slice_from_memoryview')
31444  */
31445   __Pyx_XDECREF(__pyx_r);
31446   __Pyx_INCREF(((PyObject *)__pyx_v_result));
31447   __pyx_r = ((PyObject *)__pyx_v_result);
31448   goto __pyx_L0;
31449 
31450   /* "View.MemoryView":999
31451  *
31452  * @cname('__pyx_memoryview_fromslice')
31453  * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice,             # <<<<<<<<<<<<<<
31454  *                           int ndim,
31455  *                           object (*to_object_func)(char *),
31456  */
31457 
31458   /* function exit code */
31459   __pyx_L1_error:;
31460   __Pyx_XDECREF(__pyx_t_2);
31461   __Pyx_XDECREF(__pyx_t_3);
31462   __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
31463   __pyx_r = 0;
31464   __pyx_L0:;
31465   __Pyx_XDECREF((PyObject *)__pyx_v_result);
31466   __Pyx_XDECREF(__pyx_v_length);
31467   __Pyx_XGIVEREF(__pyx_r);
31468   __Pyx_RefNannyFinishContext();
31469   return __pyx_r;
31470 }
31471 
31472 /* "View.MemoryView":1052
31473  *
31474  * @cname('__pyx_memoryview_get_slice_from_memoryview')
31475  * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
31476  *                                                    __Pyx_memviewslice *mslice) except NULL:
31477  *     cdef _memoryviewslice obj
31478  */
31479 
__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_mslice)31480 static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) {
31481   struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0;
31482   __Pyx_memviewslice *__pyx_r;
31483   __Pyx_RefNannyDeclarations
31484   int __pyx_t_1;
31485   int __pyx_t_2;
31486   PyObject *__pyx_t_3 = NULL;
31487   int __pyx_lineno = 0;
31488   const char *__pyx_filename = NULL;
31489   int __pyx_clineno = 0;
31490   __Pyx_RefNannySetupContext("get_slice_from_memview", 0);
31491 
31492   /* "View.MemoryView":1055
31493  *                                                    __Pyx_memviewslice *mslice) except NULL:
31494  *     cdef _memoryviewslice obj
31495  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
31496  *         obj = memview
31497  *         return &obj.from_slice
31498  */
31499   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
31500   __pyx_t_2 = (__pyx_t_1 != 0);
31501   if (__pyx_t_2) {
31502 
31503     /* "View.MemoryView":1056
31504  *     cdef _memoryviewslice obj
31505  *     if isinstance(memview, _memoryviewslice):
31506  *         obj = memview             # <<<<<<<<<<<<<<
31507  *         return &obj.from_slice
31508  *     else:
31509  */
31510     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)
31511     __pyx_t_3 = ((PyObject *)__pyx_v_memview);
31512     __Pyx_INCREF(__pyx_t_3);
31513     __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
31514     __pyx_t_3 = 0;
31515 
31516     /* "View.MemoryView":1057
31517  *     if isinstance(memview, _memoryviewslice):
31518  *         obj = memview
31519  *         return &obj.from_slice             # <<<<<<<<<<<<<<
31520  *     else:
31521  *         slice_copy(memview, mslice)
31522  */
31523     __pyx_r = (&__pyx_v_obj->from_slice);
31524     goto __pyx_L0;
31525 
31526     /* "View.MemoryView":1055
31527  *                                                    __Pyx_memviewslice *mslice) except NULL:
31528  *     cdef _memoryviewslice obj
31529  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
31530  *         obj = memview
31531  *         return &obj.from_slice
31532  */
31533   }
31534 
31535   /* "View.MemoryView":1059
31536  *         return &obj.from_slice
31537  *     else:
31538  *         slice_copy(memview, mslice)             # <<<<<<<<<<<<<<
31539  *         return mslice
31540  *
31541  */
31542   /*else*/ {
31543     __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);
31544 
31545     /* "View.MemoryView":1060
31546  *     else:
31547  *         slice_copy(memview, mslice)
31548  *         return mslice             # <<<<<<<<<<<<<<
31549  *
31550  * @cname('__pyx_memoryview_slice_copy')
31551  */
31552     __pyx_r = __pyx_v_mslice;
31553     goto __pyx_L0;
31554   }
31555 
31556   /* "View.MemoryView":1052
31557  *
31558  * @cname('__pyx_memoryview_get_slice_from_memoryview')
31559  * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview,             # <<<<<<<<<<<<<<
31560  *                                                    __Pyx_memviewslice *mslice) except NULL:
31561  *     cdef _memoryviewslice obj
31562  */
31563 
31564   /* function exit code */
31565   __pyx_L1_error:;
31566   __Pyx_XDECREF(__pyx_t_3);
31567   __Pyx_AddTraceback("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
31568   __pyx_r = NULL;
31569   __pyx_L0:;
31570   __Pyx_XDECREF((PyObject *)__pyx_v_obj);
31571   __Pyx_RefNannyFinishContext();
31572   return __pyx_r;
31573 }
31574 
31575 /* "View.MemoryView":1063
31576  *
31577  * @cname('__pyx_memoryview_slice_copy')
31578  * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
31579  *     cdef int dim
31580  *     cdef (Py_ssize_t*) shape, strides, suboffsets
31581  */
31582 
__pyx_memoryview_slice_copy(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_dst)31583 static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) {
31584   int __pyx_v_dim;
31585   Py_ssize_t *__pyx_v_shape;
31586   Py_ssize_t *__pyx_v_strides;
31587   Py_ssize_t *__pyx_v_suboffsets;
31588   __Pyx_RefNannyDeclarations
31589   Py_ssize_t *__pyx_t_1;
31590   int __pyx_t_2;
31591   int __pyx_t_3;
31592   int __pyx_t_4;
31593   Py_ssize_t __pyx_t_5;
31594   __Pyx_RefNannySetupContext("slice_copy", 0);
31595 
31596   /* "View.MemoryView":1067
31597  *     cdef (Py_ssize_t*) shape, strides, suboffsets
31598  *
31599  *     shape = memview.view.shape             # <<<<<<<<<<<<<<
31600  *     strides = memview.view.strides
31601  *     suboffsets = memview.view.suboffsets
31602  */
31603   __pyx_t_1 = __pyx_v_memview->view.shape;
31604   __pyx_v_shape = __pyx_t_1;
31605 
31606   /* "View.MemoryView":1068
31607  *
31608  *     shape = memview.view.shape
31609  *     strides = memview.view.strides             # <<<<<<<<<<<<<<
31610  *     suboffsets = memview.view.suboffsets
31611  *
31612  */
31613   __pyx_t_1 = __pyx_v_memview->view.strides;
31614   __pyx_v_strides = __pyx_t_1;
31615 
31616   /* "View.MemoryView":1069
31617  *     shape = memview.view.shape
31618  *     strides = memview.view.strides
31619  *     suboffsets = memview.view.suboffsets             # <<<<<<<<<<<<<<
31620  *
31621  *     dst.memview = <__pyx_memoryview *> memview
31622  */
31623   __pyx_t_1 = __pyx_v_memview->view.suboffsets;
31624   __pyx_v_suboffsets = __pyx_t_1;
31625 
31626   /* "View.MemoryView":1071
31627  *     suboffsets = memview.view.suboffsets
31628  *
31629  *     dst.memview = <__pyx_memoryview *> memview             # <<<<<<<<<<<<<<
31630  *     dst.data = <char *> memview.view.buf
31631  *
31632  */
31633   __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);
31634 
31635   /* "View.MemoryView":1072
31636  *
31637  *     dst.memview = <__pyx_memoryview *> memview
31638  *     dst.data = <char *> memview.view.buf             # <<<<<<<<<<<<<<
31639  *
31640  *     for dim in range(memview.view.ndim):
31641  */
31642   __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);
31643 
31644   /* "View.MemoryView":1074
31645  *     dst.data = <char *> memview.view.buf
31646  *
31647  *     for dim in range(memview.view.ndim):             # <<<<<<<<<<<<<<
31648  *         dst.shape[dim] = shape[dim]
31649  *         dst.strides[dim] = strides[dim]
31650  */
31651   __pyx_t_2 = __pyx_v_memview->view.ndim;
31652   __pyx_t_3 = __pyx_t_2;
31653   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
31654     __pyx_v_dim = __pyx_t_4;
31655 
31656     /* "View.MemoryView":1075
31657  *
31658  *     for dim in range(memview.view.ndim):
31659  *         dst.shape[dim] = shape[dim]             # <<<<<<<<<<<<<<
31660  *         dst.strides[dim] = strides[dim]
31661  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
31662  */
31663     (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]);
31664 
31665     /* "View.MemoryView":1076
31666  *     for dim in range(memview.view.ndim):
31667  *         dst.shape[dim] = shape[dim]
31668  *         dst.strides[dim] = strides[dim]             # <<<<<<<<<<<<<<
31669  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
31670  *
31671  */
31672     (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]);
31673 
31674     /* "View.MemoryView":1077
31675  *         dst.shape[dim] = shape[dim]
31676  *         dst.strides[dim] = strides[dim]
31677  *         dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1             # <<<<<<<<<<<<<<
31678  *
31679  * @cname('__pyx_memoryview_copy_object')
31680  */
31681     if ((__pyx_v_suboffsets != 0)) {
31682       __pyx_t_5 = (__pyx_v_suboffsets[__pyx_v_dim]);
31683     } else {
31684       __pyx_t_5 = -1L;
31685     }
31686     (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_5;
31687   }
31688 
31689   /* "View.MemoryView":1063
31690  *
31691  * @cname('__pyx_memoryview_slice_copy')
31692  * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst):             # <<<<<<<<<<<<<<
31693  *     cdef int dim
31694  *     cdef (Py_ssize_t*) shape, strides, suboffsets
31695  */
31696 
31697   /* function exit code */
31698   __Pyx_RefNannyFinishContext();
31699 }
31700 
31701 /* "View.MemoryView":1080
31702  *
31703  * @cname('__pyx_memoryview_copy_object')
31704  * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
31705  *     "Create a new memoryview object"
31706  *     cdef __Pyx_memviewslice memviewslice
31707  */
31708 
__pyx_memoryview_copy_object(struct __pyx_memoryview_obj * __pyx_v_memview)31709 static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) {
31710   __Pyx_memviewslice __pyx_v_memviewslice;
31711   PyObject *__pyx_r = NULL;
31712   __Pyx_RefNannyDeclarations
31713   PyObject *__pyx_t_1 = NULL;
31714   int __pyx_lineno = 0;
31715   const char *__pyx_filename = NULL;
31716   int __pyx_clineno = 0;
31717   __Pyx_RefNannySetupContext("memoryview_copy", 0);
31718 
31719   /* "View.MemoryView":1083
31720  *     "Create a new memoryview object"
31721  *     cdef __Pyx_memviewslice memviewslice
31722  *     slice_copy(memview, &memviewslice)             # <<<<<<<<<<<<<<
31723  *     return memoryview_copy_from_slice(memview, &memviewslice)
31724  *
31725  */
31726   __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice));
31727 
31728   /* "View.MemoryView":1084
31729  *     cdef __Pyx_memviewslice memviewslice
31730  *     slice_copy(memview, &memviewslice)
31731  *     return memoryview_copy_from_slice(memview, &memviewslice)             # <<<<<<<<<<<<<<
31732  *
31733  * @cname('__pyx_memoryview_copy_object_from_slice')
31734  */
31735   __Pyx_XDECREF(__pyx_r);
31736   __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)
31737   __Pyx_GOTREF(__pyx_t_1);
31738   __pyx_r = __pyx_t_1;
31739   __pyx_t_1 = 0;
31740   goto __pyx_L0;
31741 
31742   /* "View.MemoryView":1080
31743  *
31744  * @cname('__pyx_memoryview_copy_object')
31745  * cdef memoryview_copy(memoryview memview):             # <<<<<<<<<<<<<<
31746  *     "Create a new memoryview object"
31747  *     cdef __Pyx_memviewslice memviewslice
31748  */
31749 
31750   /* function exit code */
31751   __pyx_L1_error:;
31752   __Pyx_XDECREF(__pyx_t_1);
31753   __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
31754   __pyx_r = 0;
31755   __pyx_L0:;
31756   __Pyx_XGIVEREF(__pyx_r);
31757   __Pyx_RefNannyFinishContext();
31758   return __pyx_r;
31759 }
31760 
31761 /* "View.MemoryView":1087
31762  *
31763  * @cname('__pyx_memoryview_copy_object_from_slice')
31764  * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
31765  *     """
31766  *     Create a new memoryview object from a given memoryview object and slice.
31767  */
31768 
__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj * __pyx_v_memview,__Pyx_memviewslice * __pyx_v_memviewslice)31769 static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) {
31770   PyObject *(*__pyx_v_to_object_func)(char *);
31771   int (*__pyx_v_to_dtype_func)(char *, PyObject *);
31772   PyObject *__pyx_r = NULL;
31773   __Pyx_RefNannyDeclarations
31774   int __pyx_t_1;
31775   int __pyx_t_2;
31776   PyObject *(*__pyx_t_3)(char *);
31777   int (*__pyx_t_4)(char *, PyObject *);
31778   PyObject *__pyx_t_5 = NULL;
31779   int __pyx_lineno = 0;
31780   const char *__pyx_filename = NULL;
31781   int __pyx_clineno = 0;
31782   __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);
31783 
31784   /* "View.MemoryView":1094
31785  *     cdef int (*to_dtype_func)(char *, object) except 0
31786  *
31787  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
31788  *         to_object_func = (<_memoryviewslice> memview).to_object_func
31789  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
31790  */
31791   __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
31792   __pyx_t_2 = (__pyx_t_1 != 0);
31793   if (__pyx_t_2) {
31794 
31795     /* "View.MemoryView":1095
31796  *
31797  *     if isinstance(memview, _memoryviewslice):
31798  *         to_object_func = (<_memoryviewslice> memview).to_object_func             # <<<<<<<<<<<<<<
31799  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
31800  *     else:
31801  */
31802     __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func;
31803     __pyx_v_to_object_func = __pyx_t_3;
31804 
31805     /* "View.MemoryView":1096
31806  *     if isinstance(memview, _memoryviewslice):
31807  *         to_object_func = (<_memoryviewslice> memview).to_object_func
31808  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func             # <<<<<<<<<<<<<<
31809  *     else:
31810  *         to_object_func = NULL
31811  */
31812     __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func;
31813     __pyx_v_to_dtype_func = __pyx_t_4;
31814 
31815     /* "View.MemoryView":1094
31816  *     cdef int (*to_dtype_func)(char *, object) except 0
31817  *
31818  *     if isinstance(memview, _memoryviewslice):             # <<<<<<<<<<<<<<
31819  *         to_object_func = (<_memoryviewslice> memview).to_object_func
31820  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
31821  */
31822     goto __pyx_L3;
31823   }
31824 
31825   /* "View.MemoryView":1098
31826  *         to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
31827  *     else:
31828  *         to_object_func = NULL             # <<<<<<<<<<<<<<
31829  *         to_dtype_func = NULL
31830  *
31831  */
31832   /*else*/ {
31833     __pyx_v_to_object_func = NULL;
31834 
31835     /* "View.MemoryView":1099
31836  *     else:
31837  *         to_object_func = NULL
31838  *         to_dtype_func = NULL             # <<<<<<<<<<<<<<
31839  *
31840  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
31841  */
31842     __pyx_v_to_dtype_func = NULL;
31843   }
31844   __pyx_L3:;
31845 
31846   /* "View.MemoryView":1101
31847  *         to_dtype_func = NULL
31848  *
31849  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,             # <<<<<<<<<<<<<<
31850  *                                 to_object_func, to_dtype_func,
31851  *                                 memview.dtype_is_object)
31852  */
31853   __Pyx_XDECREF(__pyx_r);
31854 
31855   /* "View.MemoryView":1103
31856  *     return memoryview_fromslice(memviewslice[0], memview.view.ndim,
31857  *                                 to_object_func, to_dtype_func,
31858  *                                 memview.dtype_is_object)             # <<<<<<<<<<<<<<
31859  *
31860  *
31861  */
31862   __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)
31863   __Pyx_GOTREF(__pyx_t_5);
31864   __pyx_r = __pyx_t_5;
31865   __pyx_t_5 = 0;
31866   goto __pyx_L0;
31867 
31868   /* "View.MemoryView":1087
31869  *
31870  * @cname('__pyx_memoryview_copy_object_from_slice')
31871  * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice):             # <<<<<<<<<<<<<<
31872  *     """
31873  *     Create a new memoryview object from a given memoryview object and slice.
31874  */
31875 
31876   /* function exit code */
31877   __pyx_L1_error:;
31878   __Pyx_XDECREF(__pyx_t_5);
31879   __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
31880   __pyx_r = 0;
31881   __pyx_L0:;
31882   __Pyx_XGIVEREF(__pyx_r);
31883   __Pyx_RefNannyFinishContext();
31884   return __pyx_r;
31885 }
31886 
31887 /* "View.MemoryView":1109
31888  *
31889  *
31890  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
31891  *     if arg < 0:
31892  *         return -arg
31893  */
31894 
abs_py_ssize_t(Py_ssize_t __pyx_v_arg)31895 static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
31896   Py_ssize_t __pyx_r;
31897   int __pyx_t_1;
31898 
31899   /* "View.MemoryView":1110
31900  *
31901  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
31902  *     if arg < 0:             # <<<<<<<<<<<<<<
31903  *         return -arg
31904  *     else:
31905  */
31906   __pyx_t_1 = ((__pyx_v_arg < 0) != 0);
31907   if (__pyx_t_1) {
31908 
31909     /* "View.MemoryView":1111
31910  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
31911  *     if arg < 0:
31912  *         return -arg             # <<<<<<<<<<<<<<
31913  *     else:
31914  *         return arg
31915  */
31916     __pyx_r = (-__pyx_v_arg);
31917     goto __pyx_L0;
31918 
31919     /* "View.MemoryView":1110
31920  *
31921  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
31922  *     if arg < 0:             # <<<<<<<<<<<<<<
31923  *         return -arg
31924  *     else:
31925  */
31926   }
31927 
31928   /* "View.MemoryView":1113
31929  *         return -arg
31930  *     else:
31931  *         return arg             # <<<<<<<<<<<<<<
31932  *
31933  * @cname('__pyx_get_best_slice_order')
31934  */
31935   /*else*/ {
31936     __pyx_r = __pyx_v_arg;
31937     goto __pyx_L0;
31938   }
31939 
31940   /* "View.MemoryView":1109
31941  *
31942  *
31943  * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:             # <<<<<<<<<<<<<<
31944  *     if arg < 0:
31945  *         return -arg
31946  */
31947 
31948   /* function exit code */
31949   __pyx_L0:;
31950   return __pyx_r;
31951 }
31952 
31953 /* "View.MemoryView":1116
31954  *
31955  * @cname('__pyx_get_best_slice_order')
31956  * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
31957  *     """
31958  *     Figure out the best memory access order for a given slice.
31959  */
31960 
__pyx_get_best_slice_order(__Pyx_memviewslice * __pyx_v_mslice,int __pyx_v_ndim)31961 static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) {
31962   int __pyx_v_i;
31963   Py_ssize_t __pyx_v_c_stride;
31964   Py_ssize_t __pyx_v_f_stride;
31965   char __pyx_r;
31966   int __pyx_t_1;
31967   int __pyx_t_2;
31968   int __pyx_t_3;
31969   int __pyx_t_4;
31970 
31971   /* "View.MemoryView":1121
31972  *     """
31973  *     cdef int i
31974  *     cdef Py_ssize_t c_stride = 0             # <<<<<<<<<<<<<<
31975  *     cdef Py_ssize_t f_stride = 0
31976  *
31977  */
31978   __pyx_v_c_stride = 0;
31979 
31980   /* "View.MemoryView":1122
31981  *     cdef int i
31982  *     cdef Py_ssize_t c_stride = 0
31983  *     cdef Py_ssize_t f_stride = 0             # <<<<<<<<<<<<<<
31984  *
31985  *     for i in range(ndim - 1, -1, -1):
31986  */
31987   __pyx_v_f_stride = 0;
31988 
31989   /* "View.MemoryView":1124
31990  *     cdef Py_ssize_t f_stride = 0
31991  *
31992  *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
31993  *         if mslice.shape[i] > 1:
31994  *             c_stride = mslice.strides[i]
31995  */
31996   for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
31997     __pyx_v_i = __pyx_t_1;
31998 
31999     /* "View.MemoryView":1125
32000  *
32001  *     for i in range(ndim - 1, -1, -1):
32002  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
32003  *             c_stride = mslice.strides[i]
32004  *             break
32005  */
32006     __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
32007     if (__pyx_t_2) {
32008 
32009       /* "View.MemoryView":1126
32010  *     for i in range(ndim - 1, -1, -1):
32011  *         if mslice.shape[i] > 1:
32012  *             c_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
32013  *             break
32014  *
32015  */
32016       __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
32017 
32018       /* "View.MemoryView":1127
32019  *         if mslice.shape[i] > 1:
32020  *             c_stride = mslice.strides[i]
32021  *             break             # <<<<<<<<<<<<<<
32022  *
32023  *     for i in range(ndim):
32024  */
32025       goto __pyx_L4_break;
32026 
32027       /* "View.MemoryView":1125
32028  *
32029  *     for i in range(ndim - 1, -1, -1):
32030  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
32031  *             c_stride = mslice.strides[i]
32032  *             break
32033  */
32034     }
32035   }
32036   __pyx_L4_break:;
32037 
32038   /* "View.MemoryView":1129
32039  *             break
32040  *
32041  *     for i in range(ndim):             # <<<<<<<<<<<<<<
32042  *         if mslice.shape[i] > 1:
32043  *             f_stride = mslice.strides[i]
32044  */
32045   __pyx_t_1 = __pyx_v_ndim;
32046   __pyx_t_3 = __pyx_t_1;
32047   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
32048     __pyx_v_i = __pyx_t_4;
32049 
32050     /* "View.MemoryView":1130
32051  *
32052  *     for i in range(ndim):
32053  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
32054  *             f_stride = mslice.strides[i]
32055  *             break
32056  */
32057     __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
32058     if (__pyx_t_2) {
32059 
32060       /* "View.MemoryView":1131
32061  *     for i in range(ndim):
32062  *         if mslice.shape[i] > 1:
32063  *             f_stride = mslice.strides[i]             # <<<<<<<<<<<<<<
32064  *             break
32065  *
32066  */
32067       __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
32068 
32069       /* "View.MemoryView":1132
32070  *         if mslice.shape[i] > 1:
32071  *             f_stride = mslice.strides[i]
32072  *             break             # <<<<<<<<<<<<<<
32073  *
32074  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
32075  */
32076       goto __pyx_L7_break;
32077 
32078       /* "View.MemoryView":1130
32079  *
32080  *     for i in range(ndim):
32081  *         if mslice.shape[i] > 1:             # <<<<<<<<<<<<<<
32082  *             f_stride = mslice.strides[i]
32083  *             break
32084  */
32085     }
32086   }
32087   __pyx_L7_break:;
32088 
32089   /* "View.MemoryView":1134
32090  *             break
32091  *
32092  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
32093  *         return 'C'
32094  *     else:
32095  */
32096   __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0);
32097   if (__pyx_t_2) {
32098 
32099     /* "View.MemoryView":1135
32100  *
32101  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
32102  *         return 'C'             # <<<<<<<<<<<<<<
32103  *     else:
32104  *         return 'F'
32105  */
32106     __pyx_r = 'C';
32107     goto __pyx_L0;
32108 
32109     /* "View.MemoryView":1134
32110  *             break
32111  *
32112  *     if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):             # <<<<<<<<<<<<<<
32113  *         return 'C'
32114  *     else:
32115  */
32116   }
32117 
32118   /* "View.MemoryView":1137
32119  *         return 'C'
32120  *     else:
32121  *         return 'F'             # <<<<<<<<<<<<<<
32122  *
32123  * @cython.cdivision(True)
32124  */
32125   /*else*/ {
32126     __pyx_r = 'F';
32127     goto __pyx_L0;
32128   }
32129 
32130   /* "View.MemoryView":1116
32131  *
32132  * @cname('__pyx_get_best_slice_order')
32133  * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil:             # <<<<<<<<<<<<<<
32134  *     """
32135  *     Figure out the best memory access order for a given slice.
32136  */
32137 
32138   /* function exit code */
32139   __pyx_L0:;
32140   return __pyx_r;
32141 }
32142 
32143 /* "View.MemoryView":1140
32144  *
32145  * @cython.cdivision(True)
32146  * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
32147  *                                    char *dst_data, Py_ssize_t *dst_strides,
32148  *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
32149  */
32150 
_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)32151 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) {
32152   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
32153   CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent;
32154   Py_ssize_t __pyx_v_dst_extent;
32155   Py_ssize_t __pyx_v_src_stride;
32156   Py_ssize_t __pyx_v_dst_stride;
32157   int __pyx_t_1;
32158   int __pyx_t_2;
32159   int __pyx_t_3;
32160   Py_ssize_t __pyx_t_4;
32161   Py_ssize_t __pyx_t_5;
32162   Py_ssize_t __pyx_t_6;
32163 
32164   /* "View.MemoryView":1147
32165  *
32166  *     cdef Py_ssize_t i
32167  *     cdef Py_ssize_t src_extent = src_shape[0]             # <<<<<<<<<<<<<<
32168  *     cdef Py_ssize_t dst_extent = dst_shape[0]
32169  *     cdef Py_ssize_t src_stride = src_strides[0]
32170  */
32171   __pyx_v_src_extent = (__pyx_v_src_shape[0]);
32172 
32173   /* "View.MemoryView":1148
32174  *     cdef Py_ssize_t i
32175  *     cdef Py_ssize_t src_extent = src_shape[0]
32176  *     cdef Py_ssize_t dst_extent = dst_shape[0]             # <<<<<<<<<<<<<<
32177  *     cdef Py_ssize_t src_stride = src_strides[0]
32178  *     cdef Py_ssize_t dst_stride = dst_strides[0]
32179  */
32180   __pyx_v_dst_extent = (__pyx_v_dst_shape[0]);
32181 
32182   /* "View.MemoryView":1149
32183  *     cdef Py_ssize_t src_extent = src_shape[0]
32184  *     cdef Py_ssize_t dst_extent = dst_shape[0]
32185  *     cdef Py_ssize_t src_stride = src_strides[0]             # <<<<<<<<<<<<<<
32186  *     cdef Py_ssize_t dst_stride = dst_strides[0]
32187  *
32188  */
32189   __pyx_v_src_stride = (__pyx_v_src_strides[0]);
32190 
32191   /* "View.MemoryView":1150
32192  *     cdef Py_ssize_t dst_extent = dst_shape[0]
32193  *     cdef Py_ssize_t src_stride = src_strides[0]
32194  *     cdef Py_ssize_t dst_stride = dst_strides[0]             # <<<<<<<<<<<<<<
32195  *
32196  *     if ndim == 1:
32197  */
32198   __pyx_v_dst_stride = (__pyx_v_dst_strides[0]);
32199 
32200   /* "View.MemoryView":1152
32201  *     cdef Py_ssize_t dst_stride = dst_strides[0]
32202  *
32203  *     if ndim == 1:             # <<<<<<<<<<<<<<
32204  *        if (src_stride > 0 and dst_stride > 0 and
32205  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
32206  */
32207   __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
32208   if (__pyx_t_1) {
32209 
32210     /* "View.MemoryView":1153
32211  *
32212  *     if ndim == 1:
32213  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
32214  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
32215  *            memcpy(dst_data, src_data, itemsize * dst_extent)
32216  */
32217     __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0);
32218     if (__pyx_t_2) {
32219     } else {
32220       __pyx_t_1 = __pyx_t_2;
32221       goto __pyx_L5_bool_binop_done;
32222     }
32223     __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0);
32224     if (__pyx_t_2) {
32225     } else {
32226       __pyx_t_1 = __pyx_t_2;
32227       goto __pyx_L5_bool_binop_done;
32228     }
32229 
32230     /* "View.MemoryView":1154
32231  *     if ndim == 1:
32232  *        if (src_stride > 0 and dst_stride > 0 and
32233  *            <size_t> src_stride == itemsize == <size_t> dst_stride):             # <<<<<<<<<<<<<<
32234  *            memcpy(dst_data, src_data, itemsize * dst_extent)
32235  *        else:
32236  */
32237     __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize);
32238     if (__pyx_t_2) {
32239       __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride));
32240     }
32241     __pyx_t_3 = (__pyx_t_2 != 0);
32242     __pyx_t_1 = __pyx_t_3;
32243     __pyx_L5_bool_binop_done:;
32244 
32245     /* "View.MemoryView":1153
32246  *
32247  *     if ndim == 1:
32248  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
32249  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
32250  *            memcpy(dst_data, src_data, itemsize * dst_extent)
32251  */
32252     if (__pyx_t_1) {
32253 
32254       /* "View.MemoryView":1155
32255  *        if (src_stride > 0 and dst_stride > 0 and
32256  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
32257  *            memcpy(dst_data, src_data, itemsize * dst_extent)             # <<<<<<<<<<<<<<
32258  *        else:
32259  *            for i in range(dst_extent):
32260  */
32261       (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent)));
32262 
32263       /* "View.MemoryView":1153
32264  *
32265  *     if ndim == 1:
32266  *        if (src_stride > 0 and dst_stride > 0 and             # <<<<<<<<<<<<<<
32267  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
32268  *            memcpy(dst_data, src_data, itemsize * dst_extent)
32269  */
32270       goto __pyx_L4;
32271     }
32272 
32273     /* "View.MemoryView":1157
32274  *            memcpy(dst_data, src_data, itemsize * dst_extent)
32275  *        else:
32276  *            for i in range(dst_extent):             # <<<<<<<<<<<<<<
32277  *                memcpy(dst_data, src_data, itemsize)
32278  *                src_data += src_stride
32279  */
32280     /*else*/ {
32281       __pyx_t_4 = __pyx_v_dst_extent;
32282       __pyx_t_5 = __pyx_t_4;
32283       for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
32284         __pyx_v_i = __pyx_t_6;
32285 
32286         /* "View.MemoryView":1158
32287  *        else:
32288  *            for i in range(dst_extent):
32289  *                memcpy(dst_data, src_data, itemsize)             # <<<<<<<<<<<<<<
32290  *                src_data += src_stride
32291  *                dst_data += dst_stride
32292  */
32293         (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize));
32294 
32295         /* "View.MemoryView":1159
32296  *            for i in range(dst_extent):
32297  *                memcpy(dst_data, src_data, itemsize)
32298  *                src_data += src_stride             # <<<<<<<<<<<<<<
32299  *                dst_data += dst_stride
32300  *     else:
32301  */
32302         __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
32303 
32304         /* "View.MemoryView":1160
32305  *                memcpy(dst_data, src_data, itemsize)
32306  *                src_data += src_stride
32307  *                dst_data += dst_stride             # <<<<<<<<<<<<<<
32308  *     else:
32309  *         for i in range(dst_extent):
32310  */
32311         __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
32312       }
32313     }
32314     __pyx_L4:;
32315 
32316     /* "View.MemoryView":1152
32317  *     cdef Py_ssize_t dst_stride = dst_strides[0]
32318  *
32319  *     if ndim == 1:             # <<<<<<<<<<<<<<
32320  *        if (src_stride > 0 and dst_stride > 0 and
32321  *            <size_t> src_stride == itemsize == <size_t> dst_stride):
32322  */
32323     goto __pyx_L3;
32324   }
32325 
32326   /* "View.MemoryView":1162
32327  *                dst_data += dst_stride
32328  *     else:
32329  *         for i in range(dst_extent):             # <<<<<<<<<<<<<<
32330  *             _copy_strided_to_strided(src_data, src_strides + 1,
32331  *                                      dst_data, dst_strides + 1,
32332  */
32333   /*else*/ {
32334     __pyx_t_4 = __pyx_v_dst_extent;
32335     __pyx_t_5 = __pyx_t_4;
32336     for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
32337       __pyx_v_i = __pyx_t_6;
32338 
32339       /* "View.MemoryView":1163
32340  *     else:
32341  *         for i in range(dst_extent):
32342  *             _copy_strided_to_strided(src_data, src_strides + 1,             # <<<<<<<<<<<<<<
32343  *                                      dst_data, dst_strides + 1,
32344  *                                      src_shape + 1, dst_shape + 1,
32345  */
32346       _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);
32347 
32348       /* "View.MemoryView":1167
32349  *                                      src_shape + 1, dst_shape + 1,
32350  *                                      ndim - 1, itemsize)
32351  *             src_data += src_stride             # <<<<<<<<<<<<<<
32352  *             dst_data += dst_stride
32353  *
32354  */
32355       __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
32356 
32357       /* "View.MemoryView":1168
32358  *                                      ndim - 1, itemsize)
32359  *             src_data += src_stride
32360  *             dst_data += dst_stride             # <<<<<<<<<<<<<<
32361  *
32362  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,
32363  */
32364       __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
32365     }
32366   }
32367   __pyx_L3:;
32368 
32369   /* "View.MemoryView":1140
32370  *
32371  * @cython.cdivision(True)
32372  * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides,             # <<<<<<<<<<<<<<
32373  *                                    char *dst_data, Py_ssize_t *dst_strides,
32374  *                                    Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
32375  */
32376 
32377   /* function exit code */
32378 }
32379 
32380 /* "View.MemoryView":1170
32381  *             dst_data += dst_stride
32382  *
32383  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
32384  *                                   __Pyx_memviewslice *dst,
32385  *                                   int ndim, size_t itemsize) nogil:
32386  */
32387 
copy_strided_to_strided(__Pyx_memviewslice * __pyx_v_src,__Pyx_memviewslice * __pyx_v_dst,int __pyx_v_ndim,size_t __pyx_v_itemsize)32388 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) {
32389 
32390   /* "View.MemoryView":1173
32391  *                                   __Pyx_memviewslice *dst,
32392  *                                   int ndim, size_t itemsize) nogil:
32393  *     _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides,             # <<<<<<<<<<<<<<
32394  *                              src.shape, dst.shape, ndim, itemsize)
32395  *
32396  */
32397   _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);
32398 
32399   /* "View.MemoryView":1170
32400  *             dst_data += dst_stride
32401  *
32402  * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
32403  *                                   __Pyx_memviewslice *dst,
32404  *                                   int ndim, size_t itemsize) nogil:
32405  */
32406 
32407   /* function exit code */
32408 }
32409 
32410 /* "View.MemoryView":1177
32411  *
32412  * @cname('__pyx_memoryview_slice_get_size')
32413  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
32414  *     "Return the size of the memory occupied by the slice in number of bytes"
32415  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
32416  */
32417 
__pyx_memoryview_slice_get_size(__Pyx_memviewslice * __pyx_v_src,int __pyx_v_ndim)32418 static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
32419   Py_ssize_t __pyx_v_shape;
32420   Py_ssize_t __pyx_v_size;
32421   Py_ssize_t __pyx_r;
32422   Py_ssize_t __pyx_t_1;
32423   Py_ssize_t *__pyx_t_2;
32424   Py_ssize_t *__pyx_t_3;
32425   Py_ssize_t *__pyx_t_4;
32426 
32427   /* "View.MemoryView":1179
32428  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:
32429  *     "Return the size of the memory occupied by the slice in number of bytes"
32430  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize             # <<<<<<<<<<<<<<
32431  *
32432  *     for shape in src.shape[:ndim]:
32433  */
32434   __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
32435   __pyx_v_size = __pyx_t_1;
32436 
32437   /* "View.MemoryView":1181
32438  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
32439  *
32440  *     for shape in src.shape[:ndim]:             # <<<<<<<<<<<<<<
32441  *         size *= shape
32442  *
32443  */
32444   __pyx_t_3 = (__pyx_v_src->shape + __pyx_v_ndim);
32445   for (__pyx_t_4 = __pyx_v_src->shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
32446     __pyx_t_2 = __pyx_t_4;
32447     __pyx_v_shape = (__pyx_t_2[0]);
32448 
32449     /* "View.MemoryView":1182
32450  *
32451  *     for shape in src.shape[:ndim]:
32452  *         size *= shape             # <<<<<<<<<<<<<<
32453  *
32454  *     return size
32455  */
32456     __pyx_v_size = (__pyx_v_size * __pyx_v_shape);
32457   }
32458 
32459   /* "View.MemoryView":1184
32460  *         size *= shape
32461  *
32462  *     return size             # <<<<<<<<<<<<<<
32463  *
32464  * @cname('__pyx_fill_contig_strides_array')
32465  */
32466   __pyx_r = __pyx_v_size;
32467   goto __pyx_L0;
32468 
32469   /* "View.MemoryView":1177
32470  *
32471  * @cname('__pyx_memoryview_slice_get_size')
32472  * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:             # <<<<<<<<<<<<<<
32473  *     "Return the size of the memory occupied by the slice in number of bytes"
32474  *     cdef Py_ssize_t shape, size = src.memview.view.itemsize
32475  */
32476 
32477   /* function exit code */
32478   __pyx_L0:;
32479   return __pyx_r;
32480 }
32481 
32482 /* "View.MemoryView":1187
32483  *
32484  * @cname('__pyx_fill_contig_strides_array')
32485  * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
32486  *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
32487  *                 int ndim, char order) nogil:
32488  */
32489 
__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)32490 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) {
32491   int __pyx_v_idx;
32492   Py_ssize_t __pyx_r;
32493   int __pyx_t_1;
32494   int __pyx_t_2;
32495   int __pyx_t_3;
32496   int __pyx_t_4;
32497 
32498   /* "View.MemoryView":1196
32499  *     cdef int idx
32500  *
32501  *     if order == 'F':             # <<<<<<<<<<<<<<
32502  *         for idx in range(ndim):
32503  *             strides[idx] = stride
32504  */
32505   __pyx_t_1 = ((__pyx_v_order == 'F') != 0);
32506   if (__pyx_t_1) {
32507 
32508     /* "View.MemoryView":1197
32509  *
32510  *     if order == 'F':
32511  *         for idx in range(ndim):             # <<<<<<<<<<<<<<
32512  *             strides[idx] = stride
32513  *             stride *= shape[idx]
32514  */
32515     __pyx_t_2 = __pyx_v_ndim;
32516     __pyx_t_3 = __pyx_t_2;
32517     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
32518       __pyx_v_idx = __pyx_t_4;
32519 
32520       /* "View.MemoryView":1198
32521  *     if order == 'F':
32522  *         for idx in range(ndim):
32523  *             strides[idx] = stride             # <<<<<<<<<<<<<<
32524  *             stride *= shape[idx]
32525  *     else:
32526  */
32527       (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
32528 
32529       /* "View.MemoryView":1199
32530  *         for idx in range(ndim):
32531  *             strides[idx] = stride
32532  *             stride *= shape[idx]             # <<<<<<<<<<<<<<
32533  *     else:
32534  *         for idx in range(ndim - 1, -1, -1):
32535  */
32536       __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
32537     }
32538 
32539     /* "View.MemoryView":1196
32540  *     cdef int idx
32541  *
32542  *     if order == 'F':             # <<<<<<<<<<<<<<
32543  *         for idx in range(ndim):
32544  *             strides[idx] = stride
32545  */
32546     goto __pyx_L3;
32547   }
32548 
32549   /* "View.MemoryView":1201
32550  *             stride *= shape[idx]
32551  *     else:
32552  *         for idx in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
32553  *             strides[idx] = stride
32554  *             stride *= shape[idx]
32555  */
32556   /*else*/ {
32557     for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) {
32558       __pyx_v_idx = __pyx_t_2;
32559 
32560       /* "View.MemoryView":1202
32561  *     else:
32562  *         for idx in range(ndim - 1, -1, -1):
32563  *             strides[idx] = stride             # <<<<<<<<<<<<<<
32564  *             stride *= shape[idx]
32565  *
32566  */
32567       (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
32568 
32569       /* "View.MemoryView":1203
32570  *         for idx in range(ndim - 1, -1, -1):
32571  *             strides[idx] = stride
32572  *             stride *= shape[idx]             # <<<<<<<<<<<<<<
32573  *
32574  *     return stride
32575  */
32576       __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
32577     }
32578   }
32579   __pyx_L3:;
32580 
32581   /* "View.MemoryView":1205
32582  *             stride *= shape[idx]
32583  *
32584  *     return stride             # <<<<<<<<<<<<<<
32585  *
32586  * @cname('__pyx_memoryview_copy_data_to_temp')
32587  */
32588   __pyx_r = __pyx_v_stride;
32589   goto __pyx_L0;
32590 
32591   /* "View.MemoryView":1187
32592  *
32593  * @cname('__pyx_fill_contig_strides_array')
32594  * cdef Py_ssize_t fill_contig_strides_array(             # <<<<<<<<<<<<<<
32595  *                 Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
32596  *                 int ndim, char order) nogil:
32597  */
32598 
32599   /* function exit code */
32600   __pyx_L0:;
32601   return __pyx_r;
32602 }
32603 
32604 /* "View.MemoryView":1208
32605  *
32606  * @cname('__pyx_memoryview_copy_data_to_temp')
32607  * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
32608  *                              __Pyx_memviewslice *tmpslice,
32609  *                              char order,
32610  */
32611 
__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice * __pyx_v_src,__Pyx_memviewslice * __pyx_v_tmpslice,char __pyx_v_order,int __pyx_v_ndim)32612 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) {
32613   int __pyx_v_i;
32614   void *__pyx_v_result;
32615   size_t __pyx_v_itemsize;
32616   size_t __pyx_v_size;
32617   void *__pyx_r;
32618   Py_ssize_t __pyx_t_1;
32619   int __pyx_t_2;
32620   int __pyx_t_3;
32621   struct __pyx_memoryview_obj *__pyx_t_4;
32622   int __pyx_t_5;
32623   int __pyx_t_6;
32624   int __pyx_lineno = 0;
32625   const char *__pyx_filename = NULL;
32626   int __pyx_clineno = 0;
32627 
32628   /* "View.MemoryView":1219
32629  *     cdef void *result
32630  *
32631  *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
32632  *     cdef size_t size = slice_get_size(src, ndim)
32633  *
32634  */
32635   __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
32636   __pyx_v_itemsize = __pyx_t_1;
32637 
32638   /* "View.MemoryView":1220
32639  *
32640  *     cdef size_t itemsize = src.memview.view.itemsize
32641  *     cdef size_t size = slice_get_size(src, ndim)             # <<<<<<<<<<<<<<
32642  *
32643  *     result = malloc(size)
32644  */
32645   __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim);
32646 
32647   /* "View.MemoryView":1222
32648  *     cdef size_t size = slice_get_size(src, ndim)
32649  *
32650  *     result = malloc(size)             # <<<<<<<<<<<<<<
32651  *     if not result:
32652  *         _err(MemoryError, NULL)
32653  */
32654   __pyx_v_result = malloc(__pyx_v_size);
32655 
32656   /* "View.MemoryView":1223
32657  *
32658  *     result = malloc(size)
32659  *     if not result:             # <<<<<<<<<<<<<<
32660  *         _err(MemoryError, NULL)
32661  *
32662  */
32663   __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
32664   if (__pyx_t_2) {
32665 
32666     /* "View.MemoryView":1224
32667  *     result = malloc(size)
32668  *     if not result:
32669  *         _err(MemoryError, NULL)             # <<<<<<<<<<<<<<
32670  *
32671  *
32672  */
32673     __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(2, 1224, __pyx_L1_error)
32674 
32675     /* "View.MemoryView":1223
32676  *
32677  *     result = malloc(size)
32678  *     if not result:             # <<<<<<<<<<<<<<
32679  *         _err(MemoryError, NULL)
32680  *
32681  */
32682   }
32683 
32684   /* "View.MemoryView":1227
32685  *
32686  *
32687  *     tmpslice.data = <char *> result             # <<<<<<<<<<<<<<
32688  *     tmpslice.memview = src.memview
32689  *     for i in range(ndim):
32690  */
32691   __pyx_v_tmpslice->data = ((char *)__pyx_v_result);
32692 
32693   /* "View.MemoryView":1228
32694  *
32695  *     tmpslice.data = <char *> result
32696  *     tmpslice.memview = src.memview             # <<<<<<<<<<<<<<
32697  *     for i in range(ndim):
32698  *         tmpslice.shape[i] = src.shape[i]
32699  */
32700   __pyx_t_4 = __pyx_v_src->memview;
32701   __pyx_v_tmpslice->memview = __pyx_t_4;
32702 
32703   /* "View.MemoryView":1229
32704  *     tmpslice.data = <char *> result
32705  *     tmpslice.memview = src.memview
32706  *     for i in range(ndim):             # <<<<<<<<<<<<<<
32707  *         tmpslice.shape[i] = src.shape[i]
32708  *         tmpslice.suboffsets[i] = -1
32709  */
32710   __pyx_t_3 = __pyx_v_ndim;
32711   __pyx_t_5 = __pyx_t_3;
32712   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
32713     __pyx_v_i = __pyx_t_6;
32714 
32715     /* "View.MemoryView":1230
32716  *     tmpslice.memview = src.memview
32717  *     for i in range(ndim):
32718  *         tmpslice.shape[i] = src.shape[i]             # <<<<<<<<<<<<<<
32719  *         tmpslice.suboffsets[i] = -1
32720  *
32721  */
32722     (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]);
32723 
32724     /* "View.MemoryView":1231
32725  *     for i in range(ndim):
32726  *         tmpslice.shape[i] = src.shape[i]
32727  *         tmpslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
32728  *
32729  *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,
32730  */
32731     (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L;
32732   }
32733 
32734   /* "View.MemoryView":1233
32735  *         tmpslice.suboffsets[i] = -1
32736  *
32737  *     fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,             # <<<<<<<<<<<<<<
32738  *                               ndim, order)
32739  *
32740  */
32741   (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));
32742 
32743   /* "View.MemoryView":1237
32744  *
32745  *
32746  *     for i in range(ndim):             # <<<<<<<<<<<<<<
32747  *         if tmpslice.shape[i] == 1:
32748  *             tmpslice.strides[i] = 0
32749  */
32750   __pyx_t_3 = __pyx_v_ndim;
32751   __pyx_t_5 = __pyx_t_3;
32752   for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
32753     __pyx_v_i = __pyx_t_6;
32754 
32755     /* "View.MemoryView":1238
32756  *
32757  *     for i in range(ndim):
32758  *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
32759  *             tmpslice.strides[i] = 0
32760  *
32761  */
32762     __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0);
32763     if (__pyx_t_2) {
32764 
32765       /* "View.MemoryView":1239
32766  *     for i in range(ndim):
32767  *         if tmpslice.shape[i] == 1:
32768  *             tmpslice.strides[i] = 0             # <<<<<<<<<<<<<<
32769  *
32770  *     if slice_is_contig(src[0], order, ndim):
32771  */
32772       (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;
32773 
32774       /* "View.MemoryView":1238
32775  *
32776  *     for i in range(ndim):
32777  *         if tmpslice.shape[i] == 1:             # <<<<<<<<<<<<<<
32778  *             tmpslice.strides[i] = 0
32779  *
32780  */
32781     }
32782   }
32783 
32784   /* "View.MemoryView":1241
32785  *             tmpslice.strides[i] = 0
32786  *
32787  *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
32788  *         memcpy(result, src.data, size)
32789  *     else:
32790  */
32791   __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0);
32792   if (__pyx_t_2) {
32793 
32794     /* "View.MemoryView":1242
32795  *
32796  *     if slice_is_contig(src[0], order, ndim):
32797  *         memcpy(result, src.data, size)             # <<<<<<<<<<<<<<
32798  *     else:
32799  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
32800  */
32801     (void)(memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size));
32802 
32803     /* "View.MemoryView":1241
32804  *             tmpslice.strides[i] = 0
32805  *
32806  *     if slice_is_contig(src[0], order, ndim):             # <<<<<<<<<<<<<<
32807  *         memcpy(result, src.data, size)
32808  *     else:
32809  */
32810     goto __pyx_L9;
32811   }
32812 
32813   /* "View.MemoryView":1244
32814  *         memcpy(result, src.data, size)
32815  *     else:
32816  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)             # <<<<<<<<<<<<<<
32817  *
32818  *     return result
32819  */
32820   /*else*/ {
32821     copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize);
32822   }
32823   __pyx_L9:;
32824 
32825   /* "View.MemoryView":1246
32826  *         copy_strided_to_strided(src, tmpslice, ndim, itemsize)
32827  *
32828  *     return result             # <<<<<<<<<<<<<<
32829  *
32830  *
32831  */
32832   __pyx_r = __pyx_v_result;
32833   goto __pyx_L0;
32834 
32835   /* "View.MemoryView":1208
32836  *
32837  * @cname('__pyx_memoryview_copy_data_to_temp')
32838  * cdef void *copy_data_to_temp(__Pyx_memviewslice *src,             # <<<<<<<<<<<<<<
32839  *                              __Pyx_memviewslice *tmpslice,
32840  *                              char order,
32841  */
32842 
32843   /* function exit code */
32844   __pyx_L1_error:;
32845   {
32846     #ifdef WITH_THREAD
32847     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
32848     #endif
32849     __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
32850     #ifdef WITH_THREAD
32851     __Pyx_PyGILState_Release(__pyx_gilstate_save);
32852     #endif
32853   }
32854   __pyx_r = NULL;
32855   __pyx_L0:;
32856   return __pyx_r;
32857 }
32858 
32859 /* "View.MemoryView":1251
32860  *
32861  * @cname('__pyx_memoryview_err_extents')
32862  * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
32863  *                              Py_ssize_t extent2) except -1 with gil:
32864  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
32865  */
32866 
__pyx_memoryview_err_extents(int __pyx_v_i,Py_ssize_t __pyx_v_extent1,Py_ssize_t __pyx_v_extent2)32867 static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) {
32868   int __pyx_r;
32869   __Pyx_RefNannyDeclarations
32870   PyObject *__pyx_t_1 = NULL;
32871   PyObject *__pyx_t_2 = NULL;
32872   PyObject *__pyx_t_3 = NULL;
32873   PyObject *__pyx_t_4 = NULL;
32874   int __pyx_lineno = 0;
32875   const char *__pyx_filename = NULL;
32876   int __pyx_clineno = 0;
32877   #ifdef WITH_THREAD
32878   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
32879   #endif
32880   __Pyx_RefNannySetupContext("_err_extents", 0);
32881 
32882   /* "View.MemoryView":1254
32883  *                              Py_ssize_t extent2) except -1 with gil:
32884  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
32885  *                                                         (i, extent1, extent2))             # <<<<<<<<<<<<<<
32886  *
32887  * @cname('__pyx_memoryview_err_dim')
32888  */
32889   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1254, __pyx_L1_error)
32890   __Pyx_GOTREF(__pyx_t_1);
32891   __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1254, __pyx_L1_error)
32892   __Pyx_GOTREF(__pyx_t_2);
32893   __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1254, __pyx_L1_error)
32894   __Pyx_GOTREF(__pyx_t_3);
32895   __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1254, __pyx_L1_error)
32896   __Pyx_GOTREF(__pyx_t_4);
32897   __Pyx_GIVEREF(__pyx_t_1);
32898   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
32899   __Pyx_GIVEREF(__pyx_t_2);
32900   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
32901   __Pyx_GIVEREF(__pyx_t_3);
32902   PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
32903   __pyx_t_1 = 0;
32904   __pyx_t_2 = 0;
32905   __pyx_t_3 = 0;
32906 
32907   /* "View.MemoryView":1253
32908  * cdef int _err_extents(int i, Py_ssize_t extent1,
32909  *                              Py_ssize_t extent2) except -1 with gil:
32910  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %             # <<<<<<<<<<<<<<
32911  *                                                         (i, extent1, extent2))
32912  *
32913  */
32914   __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)
32915   __Pyx_GOTREF(__pyx_t_3);
32916   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
32917   __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1253, __pyx_L1_error)
32918   __Pyx_GOTREF(__pyx_t_4);
32919   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
32920   __Pyx_Raise(__pyx_t_4, 0, 0, 0);
32921   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
32922   __PYX_ERR(2, 1253, __pyx_L1_error)
32923 
32924   /* "View.MemoryView":1251
32925  *
32926  * @cname('__pyx_memoryview_err_extents')
32927  * cdef int _err_extents(int i, Py_ssize_t extent1,             # <<<<<<<<<<<<<<
32928  *                              Py_ssize_t extent2) except -1 with gil:
32929  *     raise ValueError("got differing extents in dimension %d (got %d and %d)" %
32930  */
32931 
32932   /* function exit code */
32933   __pyx_L1_error:;
32934   __Pyx_XDECREF(__pyx_t_1);
32935   __Pyx_XDECREF(__pyx_t_2);
32936   __Pyx_XDECREF(__pyx_t_3);
32937   __Pyx_XDECREF(__pyx_t_4);
32938   __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename);
32939   __pyx_r = -1;
32940   __Pyx_RefNannyFinishContext();
32941   #ifdef WITH_THREAD
32942   __Pyx_PyGILState_Release(__pyx_gilstate_save);
32943   #endif
32944   return __pyx_r;
32945 }
32946 
32947 /* "View.MemoryView":1257
32948  *
32949  * @cname('__pyx_memoryview_err_dim')
32950  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
32951  *     raise error(msg.decode('ascii') % dim)
32952  *
32953  */
32954 
__pyx_memoryview_err_dim(PyObject * __pyx_v_error,char * __pyx_v_msg,int __pyx_v_dim)32955 static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) {
32956   int __pyx_r;
32957   __Pyx_RefNannyDeclarations
32958   PyObject *__pyx_t_1 = NULL;
32959   PyObject *__pyx_t_2 = NULL;
32960   PyObject *__pyx_t_3 = NULL;
32961   PyObject *__pyx_t_4 = NULL;
32962   int __pyx_lineno = 0;
32963   const char *__pyx_filename = NULL;
32964   int __pyx_clineno = 0;
32965   #ifdef WITH_THREAD
32966   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
32967   #endif
32968   __Pyx_RefNannySetupContext("_err_dim", 0);
32969   __Pyx_INCREF(__pyx_v_error);
32970 
32971   /* "View.MemoryView":1258
32972  * @cname('__pyx_memoryview_err_dim')
32973  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:
32974  *     raise error(msg.decode('ascii') % dim)             # <<<<<<<<<<<<<<
32975  *
32976  * @cname('__pyx_memoryview_err')
32977  */
32978   __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)
32979   __Pyx_GOTREF(__pyx_t_2);
32980   __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 1258, __pyx_L1_error)
32981   __Pyx_GOTREF(__pyx_t_3);
32982   __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 1258, __pyx_L1_error)
32983   __Pyx_GOTREF(__pyx_t_4);
32984   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
32985   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
32986   __Pyx_INCREF(__pyx_v_error);
32987   __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL;
32988   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
32989     __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
32990     if (likely(__pyx_t_2)) {
32991       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
32992       __Pyx_INCREF(__pyx_t_2);
32993       __Pyx_INCREF(function);
32994       __Pyx_DECREF_SET(__pyx_t_3, function);
32995     }
32996   }
32997   __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);
32998   __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
32999   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
33000   if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1258, __pyx_L1_error)
33001   __Pyx_GOTREF(__pyx_t_1);
33002   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
33003   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
33004   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
33005   __PYX_ERR(2, 1258, __pyx_L1_error)
33006 
33007   /* "View.MemoryView":1257
33008  *
33009  * @cname('__pyx_memoryview_err_dim')
33010  * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:             # <<<<<<<<<<<<<<
33011  *     raise error(msg.decode('ascii') % dim)
33012  *
33013  */
33014 
33015   /* function exit code */
33016   __pyx_L1_error:;
33017   __Pyx_XDECREF(__pyx_t_1);
33018   __Pyx_XDECREF(__pyx_t_2);
33019   __Pyx_XDECREF(__pyx_t_3);
33020   __Pyx_XDECREF(__pyx_t_4);
33021   __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
33022   __pyx_r = -1;
33023   __Pyx_XDECREF(__pyx_v_error);
33024   __Pyx_RefNannyFinishContext();
33025   #ifdef WITH_THREAD
33026   __Pyx_PyGILState_Release(__pyx_gilstate_save);
33027   #endif
33028   return __pyx_r;
33029 }
33030 
33031 /* "View.MemoryView":1261
33032  *
33033  * @cname('__pyx_memoryview_err')
33034  * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
33035  *     if msg != NULL:
33036  *         raise error(msg.decode('ascii'))
33037  */
33038 
__pyx_memoryview_err(PyObject * __pyx_v_error,char * __pyx_v_msg)33039 static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) {
33040   int __pyx_r;
33041   __Pyx_RefNannyDeclarations
33042   int __pyx_t_1;
33043   PyObject *__pyx_t_2 = NULL;
33044   PyObject *__pyx_t_3 = NULL;
33045   PyObject *__pyx_t_4 = NULL;
33046   PyObject *__pyx_t_5 = NULL;
33047   int __pyx_lineno = 0;
33048   const char *__pyx_filename = NULL;
33049   int __pyx_clineno = 0;
33050   #ifdef WITH_THREAD
33051   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
33052   #endif
33053   __Pyx_RefNannySetupContext("_err", 0);
33054   __Pyx_INCREF(__pyx_v_error);
33055 
33056   /* "View.MemoryView":1262
33057  * @cname('__pyx_memoryview_err')
33058  * cdef int _err(object error, char *msg) except -1 with gil:
33059  *     if msg != NULL:             # <<<<<<<<<<<<<<
33060  *         raise error(msg.decode('ascii'))
33061  *     else:
33062  */
33063   __pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
33064   if (unlikely(__pyx_t_1)) {
33065 
33066     /* "View.MemoryView":1263
33067  * cdef int _err(object error, char *msg) except -1 with gil:
33068  *     if msg != NULL:
33069  *         raise error(msg.decode('ascii'))             # <<<<<<<<<<<<<<
33070  *     else:
33071  *         raise error
33072  */
33073     __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)
33074     __Pyx_GOTREF(__pyx_t_3);
33075     __Pyx_INCREF(__pyx_v_error);
33076     __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL;
33077     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
33078       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
33079       if (likely(__pyx_t_5)) {
33080         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
33081         __Pyx_INCREF(__pyx_t_5);
33082         __Pyx_INCREF(function);
33083         __Pyx_DECREF_SET(__pyx_t_4, function);
33084       }
33085     }
33086     __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);
33087     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
33088     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
33089     if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 1263, __pyx_L1_error)
33090     __Pyx_GOTREF(__pyx_t_2);
33091     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
33092     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
33093     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
33094     __PYX_ERR(2, 1263, __pyx_L1_error)
33095 
33096     /* "View.MemoryView":1262
33097  * @cname('__pyx_memoryview_err')
33098  * cdef int _err(object error, char *msg) except -1 with gil:
33099  *     if msg != NULL:             # <<<<<<<<<<<<<<
33100  *         raise error(msg.decode('ascii'))
33101  *     else:
33102  */
33103   }
33104 
33105   /* "View.MemoryView":1265
33106  *         raise error(msg.decode('ascii'))
33107  *     else:
33108  *         raise error             # <<<<<<<<<<<<<<
33109  *
33110  * @cname('__pyx_memoryview_copy_contents')
33111  */
33112   /*else*/ {
33113     __Pyx_Raise(__pyx_v_error, 0, 0, 0);
33114     __PYX_ERR(2, 1265, __pyx_L1_error)
33115   }
33116 
33117   /* "View.MemoryView":1261
33118  *
33119  * @cname('__pyx_memoryview_err')
33120  * cdef int _err(object error, char *msg) except -1 with gil:             # <<<<<<<<<<<<<<
33121  *     if msg != NULL:
33122  *         raise error(msg.decode('ascii'))
33123  */
33124 
33125   /* function exit code */
33126   __pyx_L1_error:;
33127   __Pyx_XDECREF(__pyx_t_2);
33128   __Pyx_XDECREF(__pyx_t_3);
33129   __Pyx_XDECREF(__pyx_t_4);
33130   __Pyx_XDECREF(__pyx_t_5);
33131   __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
33132   __pyx_r = -1;
33133   __Pyx_XDECREF(__pyx_v_error);
33134   __Pyx_RefNannyFinishContext();
33135   #ifdef WITH_THREAD
33136   __Pyx_PyGILState_Release(__pyx_gilstate_save);
33137   #endif
33138   return __pyx_r;
33139 }
33140 
33141 /* "View.MemoryView":1268
33142  *
33143  * @cname('__pyx_memoryview_copy_contents')
33144  * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
33145  *                                   __Pyx_memviewslice dst,
33146  *                                   int src_ndim, int dst_ndim,
33147  */
33148 
__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)33149 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) {
33150   void *__pyx_v_tmpdata;
33151   size_t __pyx_v_itemsize;
33152   int __pyx_v_i;
33153   char __pyx_v_order;
33154   int __pyx_v_broadcasting;
33155   int __pyx_v_direct_copy;
33156   __Pyx_memviewslice __pyx_v_tmp;
33157   int __pyx_v_ndim;
33158   int __pyx_r;
33159   Py_ssize_t __pyx_t_1;
33160   int __pyx_t_2;
33161   int __pyx_t_3;
33162   int __pyx_t_4;
33163   int __pyx_t_5;
33164   int __pyx_t_6;
33165   void *__pyx_t_7;
33166   int __pyx_t_8;
33167   int __pyx_lineno = 0;
33168   const char *__pyx_filename = NULL;
33169   int __pyx_clineno = 0;
33170 
33171   /* "View.MemoryView":1276
33172  *     Check for overlapping memory and verify the shapes.
33173  *     """
33174  *     cdef void *tmpdata = NULL             # <<<<<<<<<<<<<<
33175  *     cdef size_t itemsize = src.memview.view.itemsize
33176  *     cdef int i
33177  */
33178   __pyx_v_tmpdata = NULL;
33179 
33180   /* "View.MemoryView":1277
33181  *     """
33182  *     cdef void *tmpdata = NULL
33183  *     cdef size_t itemsize = src.memview.view.itemsize             # <<<<<<<<<<<<<<
33184  *     cdef int i
33185  *     cdef char order = get_best_order(&src, src_ndim)
33186  */
33187   __pyx_t_1 = __pyx_v_src.memview->view.itemsize;
33188   __pyx_v_itemsize = __pyx_t_1;
33189 
33190   /* "View.MemoryView":1279
33191  *     cdef size_t itemsize = src.memview.view.itemsize
33192  *     cdef int i
33193  *     cdef char order = get_best_order(&src, src_ndim)             # <<<<<<<<<<<<<<
33194  *     cdef bint broadcasting = False
33195  *     cdef bint direct_copy = False
33196  */
33197   __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim);
33198 
33199   /* "View.MemoryView":1280
33200  *     cdef int i
33201  *     cdef char order = get_best_order(&src, src_ndim)
33202  *     cdef bint broadcasting = False             # <<<<<<<<<<<<<<
33203  *     cdef bint direct_copy = False
33204  *     cdef __Pyx_memviewslice tmp
33205  */
33206   __pyx_v_broadcasting = 0;
33207 
33208   /* "View.MemoryView":1281
33209  *     cdef char order = get_best_order(&src, src_ndim)
33210  *     cdef bint broadcasting = False
33211  *     cdef bint direct_copy = False             # <<<<<<<<<<<<<<
33212  *     cdef __Pyx_memviewslice tmp
33213  *
33214  */
33215   __pyx_v_direct_copy = 0;
33216 
33217   /* "View.MemoryView":1284
33218  *     cdef __Pyx_memviewslice tmp
33219  *
33220  *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
33221  *         broadcast_leading(&src, src_ndim, dst_ndim)
33222  *     elif dst_ndim < src_ndim:
33223  */
33224   __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0);
33225   if (__pyx_t_2) {
33226 
33227     /* "View.MemoryView":1285
33228  *
33229  *     if src_ndim < dst_ndim:
33230  *         broadcast_leading(&src, src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
33231  *     elif dst_ndim < src_ndim:
33232  *         broadcast_leading(&dst, dst_ndim, src_ndim)
33233  */
33234     __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim);
33235 
33236     /* "View.MemoryView":1284
33237  *     cdef __Pyx_memviewslice tmp
33238  *
33239  *     if src_ndim < dst_ndim:             # <<<<<<<<<<<<<<
33240  *         broadcast_leading(&src, src_ndim, dst_ndim)
33241  *     elif dst_ndim < src_ndim:
33242  */
33243     goto __pyx_L3;
33244   }
33245 
33246   /* "View.MemoryView":1286
33247  *     if src_ndim < dst_ndim:
33248  *         broadcast_leading(&src, src_ndim, dst_ndim)
33249  *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
33250  *         broadcast_leading(&dst, dst_ndim, src_ndim)
33251  *
33252  */
33253   __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0);
33254   if (__pyx_t_2) {
33255 
33256     /* "View.MemoryView":1287
33257  *         broadcast_leading(&src, src_ndim, dst_ndim)
33258  *     elif dst_ndim < src_ndim:
33259  *         broadcast_leading(&dst, dst_ndim, src_ndim)             # <<<<<<<<<<<<<<
33260  *
33261  *     cdef int ndim = max(src_ndim, dst_ndim)
33262  */
33263     __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim);
33264 
33265     /* "View.MemoryView":1286
33266  *     if src_ndim < dst_ndim:
33267  *         broadcast_leading(&src, src_ndim, dst_ndim)
33268  *     elif dst_ndim < src_ndim:             # <<<<<<<<<<<<<<
33269  *         broadcast_leading(&dst, dst_ndim, src_ndim)
33270  *
33271  */
33272   }
33273   __pyx_L3:;
33274 
33275   /* "View.MemoryView":1289
33276  *         broadcast_leading(&dst, dst_ndim, src_ndim)
33277  *
33278  *     cdef int ndim = max(src_ndim, dst_ndim)             # <<<<<<<<<<<<<<
33279  *
33280  *     for i in range(ndim):
33281  */
33282   __pyx_t_3 = __pyx_v_dst_ndim;
33283   __pyx_t_4 = __pyx_v_src_ndim;
33284   if (((__pyx_t_3 > __pyx_t_4) != 0)) {
33285     __pyx_t_5 = __pyx_t_3;
33286   } else {
33287     __pyx_t_5 = __pyx_t_4;
33288   }
33289   __pyx_v_ndim = __pyx_t_5;
33290 
33291   /* "View.MemoryView":1291
33292  *     cdef int ndim = max(src_ndim, dst_ndim)
33293  *
33294  *     for i in range(ndim):             # <<<<<<<<<<<<<<
33295  *         if src.shape[i] != dst.shape[i]:
33296  *             if src.shape[i] == 1:
33297  */
33298   __pyx_t_5 = __pyx_v_ndim;
33299   __pyx_t_3 = __pyx_t_5;
33300   for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
33301     __pyx_v_i = __pyx_t_4;
33302 
33303     /* "View.MemoryView":1292
33304  *
33305  *     for i in range(ndim):
33306  *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
33307  *             if src.shape[i] == 1:
33308  *                 broadcasting = True
33309  */
33310     __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0);
33311     if (__pyx_t_2) {
33312 
33313       /* "View.MemoryView":1293
33314  *     for i in range(ndim):
33315  *         if src.shape[i] != dst.shape[i]:
33316  *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
33317  *                 broadcasting = True
33318  *                 src.strides[i] = 0
33319  */
33320       __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0);
33321       if (__pyx_t_2) {
33322 
33323         /* "View.MemoryView":1294
33324  *         if src.shape[i] != dst.shape[i]:
33325  *             if src.shape[i] == 1:
33326  *                 broadcasting = True             # <<<<<<<<<<<<<<
33327  *                 src.strides[i] = 0
33328  *             else:
33329  */
33330         __pyx_v_broadcasting = 1;
33331 
33332         /* "View.MemoryView":1295
33333  *             if src.shape[i] == 1:
33334  *                 broadcasting = True
33335  *                 src.strides[i] = 0             # <<<<<<<<<<<<<<
33336  *             else:
33337  *                 _err_extents(i, dst.shape[i], src.shape[i])
33338  */
33339         (__pyx_v_src.strides[__pyx_v_i]) = 0;
33340 
33341         /* "View.MemoryView":1293
33342  *     for i in range(ndim):
33343  *         if src.shape[i] != dst.shape[i]:
33344  *             if src.shape[i] == 1:             # <<<<<<<<<<<<<<
33345  *                 broadcasting = True
33346  *                 src.strides[i] = 0
33347  */
33348         goto __pyx_L7;
33349       }
33350 
33351       /* "View.MemoryView":1297
33352  *                 src.strides[i] = 0
33353  *             else:
33354  *                 _err_extents(i, dst.shape[i], src.shape[i])             # <<<<<<<<<<<<<<
33355  *
33356  *         if src.suboffsets[i] >= 0:
33357  */
33358       /*else*/ {
33359         __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)
33360       }
33361       __pyx_L7:;
33362 
33363       /* "View.MemoryView":1292
33364  *
33365  *     for i in range(ndim):
33366  *         if src.shape[i] != dst.shape[i]:             # <<<<<<<<<<<<<<
33367  *             if src.shape[i] == 1:
33368  *                 broadcasting = True
33369  */
33370     }
33371 
33372     /* "View.MemoryView":1299
33373  *                 _err_extents(i, dst.shape[i], src.shape[i])
33374  *
33375  *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
33376  *             _err_dim(ValueError, "Dimension %d is not direct", i)
33377  *
33378  */
33379     __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0);
33380     if (__pyx_t_2) {
33381 
33382       /* "View.MemoryView":1300
33383  *
33384  *         if src.suboffsets[i] >= 0:
33385  *             _err_dim(ValueError, "Dimension %d is not direct", i)             # <<<<<<<<<<<<<<
33386  *
33387  *     if slices_overlap(&src, &dst, ndim, itemsize):
33388  */
33389       __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)
33390 
33391       /* "View.MemoryView":1299
33392  *                 _err_extents(i, dst.shape[i], src.shape[i])
33393  *
33394  *         if src.suboffsets[i] >= 0:             # <<<<<<<<<<<<<<
33395  *             _err_dim(ValueError, "Dimension %d is not direct", i)
33396  *
33397  */
33398     }
33399   }
33400 
33401   /* "View.MemoryView":1302
33402  *             _err_dim(ValueError, "Dimension %d is not direct", i)
33403  *
33404  *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
33405  *
33406  *         if not slice_is_contig(src, order, ndim):
33407  */
33408   __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0);
33409   if (__pyx_t_2) {
33410 
33411     /* "View.MemoryView":1304
33412  *     if slices_overlap(&src, &dst, ndim, itemsize):
33413  *
33414  *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
33415  *             order = get_best_order(&dst, ndim)
33416  *
33417  */
33418     __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0);
33419     if (__pyx_t_2) {
33420 
33421       /* "View.MemoryView":1305
33422  *
33423  *         if not slice_is_contig(src, order, ndim):
33424  *             order = get_best_order(&dst, ndim)             # <<<<<<<<<<<<<<
33425  *
33426  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
33427  */
33428       __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim);
33429 
33430       /* "View.MemoryView":1304
33431  *     if slices_overlap(&src, &dst, ndim, itemsize):
33432  *
33433  *         if not slice_is_contig(src, order, ndim):             # <<<<<<<<<<<<<<
33434  *             order = get_best_order(&dst, ndim)
33435  *
33436  */
33437     }
33438 
33439     /* "View.MemoryView":1307
33440  *             order = get_best_order(&dst, ndim)
33441  *
33442  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)             # <<<<<<<<<<<<<<
33443  *         src = tmp
33444  *
33445  */
33446     __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)
33447     __pyx_v_tmpdata = __pyx_t_7;
33448 
33449     /* "View.MemoryView":1308
33450  *
33451  *         tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
33452  *         src = tmp             # <<<<<<<<<<<<<<
33453  *
33454  *     if not broadcasting:
33455  */
33456     __pyx_v_src = __pyx_v_tmp;
33457 
33458     /* "View.MemoryView":1302
33459  *             _err_dim(ValueError, "Dimension %d is not direct", i)
33460  *
33461  *     if slices_overlap(&src, &dst, ndim, itemsize):             # <<<<<<<<<<<<<<
33462  *
33463  *         if not slice_is_contig(src, order, ndim):
33464  */
33465   }
33466 
33467   /* "View.MemoryView":1310
33468  *         src = tmp
33469  *
33470  *     if not broadcasting:             # <<<<<<<<<<<<<<
33471  *
33472  *
33473  */
33474   __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
33475   if (__pyx_t_2) {
33476 
33477     /* "View.MemoryView":1313
33478  *
33479  *
33480  *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
33481  *             direct_copy = slice_is_contig(dst, 'C', ndim)
33482  *         elif slice_is_contig(src, 'F', ndim):
33483  */
33484     __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0);
33485     if (__pyx_t_2) {
33486 
33487       /* "View.MemoryView":1314
33488  *
33489  *         if slice_is_contig(src, 'C', ndim):
33490  *             direct_copy = slice_is_contig(dst, 'C', ndim)             # <<<<<<<<<<<<<<
33491  *         elif slice_is_contig(src, 'F', ndim):
33492  *             direct_copy = slice_is_contig(dst, 'F', ndim)
33493  */
33494       __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim);
33495 
33496       /* "View.MemoryView":1313
33497  *
33498  *
33499  *         if slice_is_contig(src, 'C', ndim):             # <<<<<<<<<<<<<<
33500  *             direct_copy = slice_is_contig(dst, 'C', ndim)
33501  *         elif slice_is_contig(src, 'F', ndim):
33502  */
33503       goto __pyx_L12;
33504     }
33505 
33506     /* "View.MemoryView":1315
33507  *         if slice_is_contig(src, 'C', ndim):
33508  *             direct_copy = slice_is_contig(dst, 'C', ndim)
33509  *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
33510  *             direct_copy = slice_is_contig(dst, 'F', ndim)
33511  *
33512  */
33513     __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0);
33514     if (__pyx_t_2) {
33515 
33516       /* "View.MemoryView":1316
33517  *             direct_copy = slice_is_contig(dst, 'C', ndim)
33518  *         elif slice_is_contig(src, 'F', ndim):
33519  *             direct_copy = slice_is_contig(dst, 'F', ndim)             # <<<<<<<<<<<<<<
33520  *
33521  *         if direct_copy:
33522  */
33523       __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim);
33524 
33525       /* "View.MemoryView":1315
33526  *         if slice_is_contig(src, 'C', ndim):
33527  *             direct_copy = slice_is_contig(dst, 'C', ndim)
33528  *         elif slice_is_contig(src, 'F', ndim):             # <<<<<<<<<<<<<<
33529  *             direct_copy = slice_is_contig(dst, 'F', ndim)
33530  *
33531  */
33532     }
33533     __pyx_L12:;
33534 
33535     /* "View.MemoryView":1318
33536  *             direct_copy = slice_is_contig(dst, 'F', ndim)
33537  *
33538  *         if direct_copy:             # <<<<<<<<<<<<<<
33539  *
33540  *             refcount_copying(&dst, dtype_is_object, ndim, False)
33541  */
33542     __pyx_t_2 = (__pyx_v_direct_copy != 0);
33543     if (__pyx_t_2) {
33544 
33545       /* "View.MemoryView":1320
33546  *         if direct_copy:
33547  *
33548  *             refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
33549  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
33550  *             refcount_copying(&dst, dtype_is_object, ndim, True)
33551  */
33552       __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
33553 
33554       /* "View.MemoryView":1321
33555  *
33556  *             refcount_copying(&dst, dtype_is_object, ndim, False)
33557  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))             # <<<<<<<<<<<<<<
33558  *             refcount_copying(&dst, dtype_is_object, ndim, True)
33559  *             free(tmpdata)
33560  */
33561       (void)(memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)));
33562 
33563       /* "View.MemoryView":1322
33564  *             refcount_copying(&dst, dtype_is_object, ndim, False)
33565  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
33566  *             refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
33567  *             free(tmpdata)
33568  *             return 0
33569  */
33570       __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
33571 
33572       /* "View.MemoryView":1323
33573  *             memcpy(dst.data, src.data, slice_get_size(&src, ndim))
33574  *             refcount_copying(&dst, dtype_is_object, ndim, True)
33575  *             free(tmpdata)             # <<<<<<<<<<<<<<
33576  *             return 0
33577  *
33578  */
33579       free(__pyx_v_tmpdata);
33580 
33581       /* "View.MemoryView":1324
33582  *             refcount_copying(&dst, dtype_is_object, ndim, True)
33583  *             free(tmpdata)
33584  *             return 0             # <<<<<<<<<<<<<<
33585  *
33586  *     if order == 'F' == get_best_order(&dst, ndim):
33587  */
33588       __pyx_r = 0;
33589       goto __pyx_L0;
33590 
33591       /* "View.MemoryView":1318
33592  *             direct_copy = slice_is_contig(dst, 'F', ndim)
33593  *
33594  *         if direct_copy:             # <<<<<<<<<<<<<<
33595  *
33596  *             refcount_copying(&dst, dtype_is_object, ndim, False)
33597  */
33598     }
33599 
33600     /* "View.MemoryView":1310
33601  *         src = tmp
33602  *
33603  *     if not broadcasting:             # <<<<<<<<<<<<<<
33604  *
33605  *
33606  */
33607   }
33608 
33609   /* "View.MemoryView":1326
33610  *             return 0
33611  *
33612  *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
33613  *
33614  *
33615  */
33616   __pyx_t_2 = (__pyx_v_order == 'F');
33617   if (__pyx_t_2) {
33618     __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim));
33619   }
33620   __pyx_t_8 = (__pyx_t_2 != 0);
33621   if (__pyx_t_8) {
33622 
33623     /* "View.MemoryView":1329
33624  *
33625  *
33626  *         transpose_memslice(&src)             # <<<<<<<<<<<<<<
33627  *         transpose_memslice(&dst)
33628  *
33629  */
33630     __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(2, 1329, __pyx_L1_error)
33631 
33632     /* "View.MemoryView":1330
33633  *
33634  *         transpose_memslice(&src)
33635  *         transpose_memslice(&dst)             # <<<<<<<<<<<<<<
33636  *
33637  *     refcount_copying(&dst, dtype_is_object, ndim, False)
33638  */
33639     __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(2, 1330, __pyx_L1_error)
33640 
33641     /* "View.MemoryView":1326
33642  *             return 0
33643  *
33644  *     if order == 'F' == get_best_order(&dst, ndim):             # <<<<<<<<<<<<<<
33645  *
33646  *
33647  */
33648   }
33649 
33650   /* "View.MemoryView":1332
33651  *         transpose_memslice(&dst)
33652  *
33653  *     refcount_copying(&dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
33654  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
33655  *     refcount_copying(&dst, dtype_is_object, ndim, True)
33656  */
33657   __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
33658 
33659   /* "View.MemoryView":1333
33660  *
33661  *     refcount_copying(&dst, dtype_is_object, ndim, False)
33662  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)             # <<<<<<<<<<<<<<
33663  *     refcount_copying(&dst, dtype_is_object, ndim, True)
33664  *
33665  */
33666   copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize);
33667 
33668   /* "View.MemoryView":1334
33669  *     refcount_copying(&dst, dtype_is_object, ndim, False)
33670  *     copy_strided_to_strided(&src, &dst, ndim, itemsize)
33671  *     refcount_copying(&dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
33672  *
33673  *     free(tmpdata)
33674  */
33675   __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
33676 
33677   /* "View.MemoryView":1336
33678  *     refcount_copying(&dst, dtype_is_object, ndim, True)
33679  *
33680  *     free(tmpdata)             # <<<<<<<<<<<<<<
33681  *     return 0
33682  *
33683  */
33684   free(__pyx_v_tmpdata);
33685 
33686   /* "View.MemoryView":1337
33687  *
33688  *     free(tmpdata)
33689  *     return 0             # <<<<<<<<<<<<<<
33690  *
33691  * @cname('__pyx_memoryview_broadcast_leading')
33692  */
33693   __pyx_r = 0;
33694   goto __pyx_L0;
33695 
33696   /* "View.MemoryView":1268
33697  *
33698  * @cname('__pyx_memoryview_copy_contents')
33699  * cdef int memoryview_copy_contents(__Pyx_memviewslice src,             # <<<<<<<<<<<<<<
33700  *                                   __Pyx_memviewslice dst,
33701  *                                   int src_ndim, int dst_ndim,
33702  */
33703 
33704   /* function exit code */
33705   __pyx_L1_error:;
33706   {
33707     #ifdef WITH_THREAD
33708     PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
33709     #endif
33710     __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
33711     #ifdef WITH_THREAD
33712     __Pyx_PyGILState_Release(__pyx_gilstate_save);
33713     #endif
33714   }
33715   __pyx_r = -1;
33716   __pyx_L0:;
33717   return __pyx_r;
33718 }
33719 
33720 /* "View.MemoryView":1340
33721  *
33722  * @cname('__pyx_memoryview_broadcast_leading')
33723  * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
33724  *                             int ndim,
33725  *                             int ndim_other) nogil:
33726  */
33727 
__pyx_memoryview_broadcast_leading(__Pyx_memviewslice * __pyx_v_mslice,int __pyx_v_ndim,int __pyx_v_ndim_other)33728 static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) {
33729   int __pyx_v_i;
33730   int __pyx_v_offset;
33731   int __pyx_t_1;
33732   int __pyx_t_2;
33733   int __pyx_t_3;
33734 
33735   /* "View.MemoryView":1344
33736  *                             int ndim_other) nogil:
33737  *     cdef int i
33738  *     cdef int offset = ndim_other - ndim             # <<<<<<<<<<<<<<
33739  *
33740  *     for i in range(ndim - 1, -1, -1):
33741  */
33742   __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim);
33743 
33744   /* "View.MemoryView":1346
33745  *     cdef int offset = ndim_other - ndim
33746  *
33747  *     for i in range(ndim - 1, -1, -1):             # <<<<<<<<<<<<<<
33748  *         mslice.shape[i + offset] = mslice.shape[i]
33749  *         mslice.strides[i + offset] = mslice.strides[i]
33750  */
33751   for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
33752     __pyx_v_i = __pyx_t_1;
33753 
33754     /* "View.MemoryView":1347
33755  *
33756  *     for i in range(ndim - 1, -1, -1):
33757  *         mslice.shape[i + offset] = mslice.shape[i]             # <<<<<<<<<<<<<<
33758  *         mslice.strides[i + offset] = mslice.strides[i]
33759  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
33760  */
33761     (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]);
33762 
33763     /* "View.MemoryView":1348
33764  *     for i in range(ndim - 1, -1, -1):
33765  *         mslice.shape[i + offset] = mslice.shape[i]
33766  *         mslice.strides[i + offset] = mslice.strides[i]             # <<<<<<<<<<<<<<
33767  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
33768  *
33769  */
33770     (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]);
33771 
33772     /* "View.MemoryView":1349
33773  *         mslice.shape[i + offset] = mslice.shape[i]
33774  *         mslice.strides[i + offset] = mslice.strides[i]
33775  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]             # <<<<<<<<<<<<<<
33776  *
33777  *     for i in range(offset):
33778  */
33779     (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]);
33780   }
33781 
33782   /* "View.MemoryView":1351
33783  *         mslice.suboffsets[i + offset] = mslice.suboffsets[i]
33784  *
33785  *     for i in range(offset):             # <<<<<<<<<<<<<<
33786  *         mslice.shape[i] = 1
33787  *         mslice.strides[i] = mslice.strides[0]
33788  */
33789   __pyx_t_1 = __pyx_v_offset;
33790   __pyx_t_2 = __pyx_t_1;
33791   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
33792     __pyx_v_i = __pyx_t_3;
33793 
33794     /* "View.MemoryView":1352
33795  *
33796  *     for i in range(offset):
33797  *         mslice.shape[i] = 1             # <<<<<<<<<<<<<<
33798  *         mslice.strides[i] = mslice.strides[0]
33799  *         mslice.suboffsets[i] = -1
33800  */
33801     (__pyx_v_mslice->shape[__pyx_v_i]) = 1;
33802 
33803     /* "View.MemoryView":1353
33804  *     for i in range(offset):
33805  *         mslice.shape[i] = 1
33806  *         mslice.strides[i] = mslice.strides[0]             # <<<<<<<<<<<<<<
33807  *         mslice.suboffsets[i] = -1
33808  *
33809  */
33810     (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]);
33811 
33812     /* "View.MemoryView":1354
33813  *         mslice.shape[i] = 1
33814  *         mslice.strides[i] = mslice.strides[0]
33815  *         mslice.suboffsets[i] = -1             # <<<<<<<<<<<<<<
33816  *
33817  *
33818  */
33819     (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
33820   }
33821 
33822   /* "View.MemoryView":1340
33823  *
33824  * @cname('__pyx_memoryview_broadcast_leading')
33825  * cdef void broadcast_leading(__Pyx_memviewslice *mslice,             # <<<<<<<<<<<<<<
33826  *                             int ndim,
33827  *                             int ndim_other) nogil:
33828  */
33829 
33830   /* function exit code */
33831 }
33832 
33833 /* "View.MemoryView":1362
33834  *
33835  * @cname('__pyx_memoryview_refcount_copying')
33836  * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
33837  *                            int ndim, bint inc) nogil:
33838  *
33839  */
33840 
__pyx_memoryview_refcount_copying(__Pyx_memviewslice * __pyx_v_dst,int __pyx_v_dtype_is_object,int __pyx_v_ndim,int __pyx_v_inc)33841 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) {
33842   int __pyx_t_1;
33843 
33844   /* "View.MemoryView":1366
33845  *
33846  *
33847  *     if dtype_is_object:             # <<<<<<<<<<<<<<
33848  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
33849  *                                            dst.strides, ndim, inc)
33850  */
33851   __pyx_t_1 = (__pyx_v_dtype_is_object != 0);
33852   if (__pyx_t_1) {
33853 
33854     /* "View.MemoryView":1367
33855  *
33856  *     if dtype_is_object:
33857  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,             # <<<<<<<<<<<<<<
33858  *                                            dst.strides, ndim, inc)
33859  *
33860  */
33861     __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);
33862 
33863     /* "View.MemoryView":1366
33864  *
33865  *
33866  *     if dtype_is_object:             # <<<<<<<<<<<<<<
33867  *         refcount_objects_in_slice_with_gil(dst.data, dst.shape,
33868  *                                            dst.strides, ndim, inc)
33869  */
33870   }
33871 
33872   /* "View.MemoryView":1362
33873  *
33874  * @cname('__pyx_memoryview_refcount_copying')
33875  * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object,             # <<<<<<<<<<<<<<
33876  *                            int ndim, bint inc) nogil:
33877  *
33878  */
33879 
33880   /* function exit code */
33881 }
33882 
33883 /* "View.MemoryView":1371
33884  *
33885  * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
33886  * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
33887  *                                              Py_ssize_t *strides, int ndim,
33888  *                                              bint inc) with gil:
33889  */
33890 
__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)33891 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) {
33892   __Pyx_RefNannyDeclarations
33893   #ifdef WITH_THREAD
33894   PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
33895   #endif
33896   __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);
33897 
33898   /* "View.MemoryView":1374
33899  *                                              Py_ssize_t *strides, int ndim,
33900  *                                              bint inc) with gil:
33901  *     refcount_objects_in_slice(data, shape, strides, ndim, inc)             # <<<<<<<<<<<<<<
33902  *
33903  * @cname('__pyx_memoryview_refcount_objects_in_slice')
33904  */
33905   __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc);
33906 
33907   /* "View.MemoryView":1371
33908  *
33909  * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
33910  * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
33911  *                                              Py_ssize_t *strides, int ndim,
33912  *                                              bint inc) with gil:
33913  */
33914 
33915   /* function exit code */
33916   __Pyx_RefNannyFinishContext();
33917   #ifdef WITH_THREAD
33918   __Pyx_PyGILState_Release(__pyx_gilstate_save);
33919   #endif
33920 }
33921 
33922 /* "View.MemoryView":1377
33923  *
33924  * @cname('__pyx_memoryview_refcount_objects_in_slice')
33925  * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
33926  *                                     Py_ssize_t *strides, int ndim, bint inc):
33927  *     cdef Py_ssize_t i
33928  */
33929 
__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)33930 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) {
33931   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
33932   __Pyx_RefNannyDeclarations
33933   Py_ssize_t __pyx_t_1;
33934   Py_ssize_t __pyx_t_2;
33935   Py_ssize_t __pyx_t_3;
33936   int __pyx_t_4;
33937   __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);
33938 
33939   /* "View.MemoryView":1381
33940  *     cdef Py_ssize_t i
33941  *
33942  *     for i in range(shape[0]):             # <<<<<<<<<<<<<<
33943  *         if ndim == 1:
33944  *             if inc:
33945  */
33946   __pyx_t_1 = (__pyx_v_shape[0]);
33947   __pyx_t_2 = __pyx_t_1;
33948   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
33949     __pyx_v_i = __pyx_t_3;
33950 
33951     /* "View.MemoryView":1382
33952  *
33953  *     for i in range(shape[0]):
33954  *         if ndim == 1:             # <<<<<<<<<<<<<<
33955  *             if inc:
33956  *                 Py_INCREF((<PyObject **> data)[0])
33957  */
33958     __pyx_t_4 = ((__pyx_v_ndim == 1) != 0);
33959     if (__pyx_t_4) {
33960 
33961       /* "View.MemoryView":1383
33962  *     for i in range(shape[0]):
33963  *         if ndim == 1:
33964  *             if inc:             # <<<<<<<<<<<<<<
33965  *                 Py_INCREF((<PyObject **> data)[0])
33966  *             else:
33967  */
33968       __pyx_t_4 = (__pyx_v_inc != 0);
33969       if (__pyx_t_4) {
33970 
33971         /* "View.MemoryView":1384
33972  *         if ndim == 1:
33973  *             if inc:
33974  *                 Py_INCREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
33975  *             else:
33976  *                 Py_DECREF((<PyObject **> data)[0])
33977  */
33978         Py_INCREF((((PyObject **)__pyx_v_data)[0]));
33979 
33980         /* "View.MemoryView":1383
33981  *     for i in range(shape[0]):
33982  *         if ndim == 1:
33983  *             if inc:             # <<<<<<<<<<<<<<
33984  *                 Py_INCREF((<PyObject **> data)[0])
33985  *             else:
33986  */
33987         goto __pyx_L6;
33988       }
33989 
33990       /* "View.MemoryView":1386
33991  *                 Py_INCREF((<PyObject **> data)[0])
33992  *             else:
33993  *                 Py_DECREF((<PyObject **> data)[0])             # <<<<<<<<<<<<<<
33994  *         else:
33995  *             refcount_objects_in_slice(data, shape + 1, strides + 1,
33996  */
33997       /*else*/ {
33998         Py_DECREF((((PyObject **)__pyx_v_data)[0]));
33999       }
34000       __pyx_L6:;
34001 
34002       /* "View.MemoryView":1382
34003  *
34004  *     for i in range(shape[0]):
34005  *         if ndim == 1:             # <<<<<<<<<<<<<<
34006  *             if inc:
34007  *                 Py_INCREF((<PyObject **> data)[0])
34008  */
34009       goto __pyx_L5;
34010     }
34011 
34012     /* "View.MemoryView":1388
34013  *                 Py_DECREF((<PyObject **> data)[0])
34014  *         else:
34015  *             refcount_objects_in_slice(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
34016  *                                       ndim - 1, inc)
34017  *
34018  */
34019     /*else*/ {
34020 
34021       /* "View.MemoryView":1389
34022  *         else:
34023  *             refcount_objects_in_slice(data, shape + 1, strides + 1,
34024  *                                       ndim - 1, inc)             # <<<<<<<<<<<<<<
34025  *
34026  *         data += strides[0]
34027  */
34028       __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc);
34029     }
34030     __pyx_L5:;
34031 
34032     /* "View.MemoryView":1391
34033  *                                       ndim - 1, inc)
34034  *
34035  *         data += strides[0]             # <<<<<<<<<<<<<<
34036  *
34037  *
34038  */
34039     __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
34040   }
34041 
34042   /* "View.MemoryView":1377
34043  *
34044  * @cname('__pyx_memoryview_refcount_objects_in_slice')
34045  * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
34046  *                                     Py_ssize_t *strides, int ndim, bint inc):
34047  *     cdef Py_ssize_t i
34048  */
34049 
34050   /* function exit code */
34051   __Pyx_RefNannyFinishContext();
34052 }
34053 
34054 /* "View.MemoryView":1397
34055  *
34056  * @cname('__pyx_memoryview_slice_assign_scalar')
34057  * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
34058  *                               size_t itemsize, void *item,
34059  *                               bint dtype_is_object) nogil:
34060  */
34061 
__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)34062 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) {
34063 
34064   /* "View.MemoryView":1400
34065  *                               size_t itemsize, void *item,
34066  *                               bint dtype_is_object) nogil:
34067  *     refcount_copying(dst, dtype_is_object, ndim, False)             # <<<<<<<<<<<<<<
34068  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
34069  *                          itemsize, item)
34070  */
34071   __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
34072 
34073   /* "View.MemoryView":1401
34074  *                               bint dtype_is_object) nogil:
34075  *     refcount_copying(dst, dtype_is_object, ndim, False)
34076  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,             # <<<<<<<<<<<<<<
34077  *                          itemsize, item)
34078  *     refcount_copying(dst, dtype_is_object, ndim, True)
34079  */
34080   __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);
34081 
34082   /* "View.MemoryView":1403
34083  *     _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
34084  *                          itemsize, item)
34085  *     refcount_copying(dst, dtype_is_object, ndim, True)             # <<<<<<<<<<<<<<
34086  *
34087  *
34088  */
34089   __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
34090 
34091   /* "View.MemoryView":1397
34092  *
34093  * @cname('__pyx_memoryview_slice_assign_scalar')
34094  * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim,             # <<<<<<<<<<<<<<
34095  *                               size_t itemsize, void *item,
34096  *                               bint dtype_is_object) nogil:
34097  */
34098 
34099   /* function exit code */
34100 }
34101 
34102 /* "View.MemoryView":1407
34103  *
34104  * @cname('__pyx_memoryview__slice_assign_scalar')
34105  * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
34106  *                               Py_ssize_t *strides, int ndim,
34107  *                               size_t itemsize, void *item) nogil:
34108  */
34109 
__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)34110 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) {
34111   CYTHON_UNUSED Py_ssize_t __pyx_v_i;
34112   Py_ssize_t __pyx_v_stride;
34113   Py_ssize_t __pyx_v_extent;
34114   int __pyx_t_1;
34115   Py_ssize_t __pyx_t_2;
34116   Py_ssize_t __pyx_t_3;
34117   Py_ssize_t __pyx_t_4;
34118 
34119   /* "View.MemoryView":1411
34120  *                               size_t itemsize, void *item) nogil:
34121  *     cdef Py_ssize_t i
34122  *     cdef Py_ssize_t stride = strides[0]             # <<<<<<<<<<<<<<
34123  *     cdef Py_ssize_t extent = shape[0]
34124  *
34125  */
34126   __pyx_v_stride = (__pyx_v_strides[0]);
34127 
34128   /* "View.MemoryView":1412
34129  *     cdef Py_ssize_t i
34130  *     cdef Py_ssize_t stride = strides[0]
34131  *     cdef Py_ssize_t extent = shape[0]             # <<<<<<<<<<<<<<
34132  *
34133  *     if ndim == 1:
34134  */
34135   __pyx_v_extent = (__pyx_v_shape[0]);
34136 
34137   /* "View.MemoryView":1414
34138  *     cdef Py_ssize_t extent = shape[0]
34139  *
34140  *     if ndim == 1:             # <<<<<<<<<<<<<<
34141  *         for i in range(extent):
34142  *             memcpy(data, item, itemsize)
34143  */
34144   __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
34145   if (__pyx_t_1) {
34146 
34147     /* "View.MemoryView":1415
34148  *
34149  *     if ndim == 1:
34150  *         for i in range(extent):             # <<<<<<<<<<<<<<
34151  *             memcpy(data, item, itemsize)
34152  *             data += stride
34153  */
34154     __pyx_t_2 = __pyx_v_extent;
34155     __pyx_t_3 = __pyx_t_2;
34156     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
34157       __pyx_v_i = __pyx_t_4;
34158 
34159       /* "View.MemoryView":1416
34160  *     if ndim == 1:
34161  *         for i in range(extent):
34162  *             memcpy(data, item, itemsize)             # <<<<<<<<<<<<<<
34163  *             data += stride
34164  *     else:
34165  */
34166       (void)(memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize));
34167 
34168       /* "View.MemoryView":1417
34169  *         for i in range(extent):
34170  *             memcpy(data, item, itemsize)
34171  *             data += stride             # <<<<<<<<<<<<<<
34172  *     else:
34173  *         for i in range(extent):
34174  */
34175       __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
34176     }
34177 
34178     /* "View.MemoryView":1414
34179  *     cdef Py_ssize_t extent = shape[0]
34180  *
34181  *     if ndim == 1:             # <<<<<<<<<<<<<<
34182  *         for i in range(extent):
34183  *             memcpy(data, item, itemsize)
34184  */
34185     goto __pyx_L3;
34186   }
34187 
34188   /* "View.MemoryView":1419
34189  *             data += stride
34190  *     else:
34191  *         for i in range(extent):             # <<<<<<<<<<<<<<
34192  *             _slice_assign_scalar(data, shape + 1, strides + 1,
34193  *                                 ndim - 1, itemsize, item)
34194  */
34195   /*else*/ {
34196     __pyx_t_2 = __pyx_v_extent;
34197     __pyx_t_3 = __pyx_t_2;
34198     for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
34199       __pyx_v_i = __pyx_t_4;
34200 
34201       /* "View.MemoryView":1420
34202  *     else:
34203  *         for i in range(extent):
34204  *             _slice_assign_scalar(data, shape + 1, strides + 1,             # <<<<<<<<<<<<<<
34205  *                                 ndim - 1, itemsize, item)
34206  *             data += stride
34207  */
34208       __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);
34209 
34210       /* "View.MemoryView":1422
34211  *             _slice_assign_scalar(data, shape + 1, strides + 1,
34212  *                                 ndim - 1, itemsize, item)
34213  *             data += stride             # <<<<<<<<<<<<<<
34214  *
34215  *
34216  */
34217       __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
34218     }
34219   }
34220   __pyx_L3:;
34221 
34222   /* "View.MemoryView":1407
34223  *
34224  * @cname('__pyx_memoryview__slice_assign_scalar')
34225  * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape,             # <<<<<<<<<<<<<<
34226  *                               Py_ssize_t *strides, int ndim,
34227  *                               size_t itemsize, void *item) nogil:
34228  */
34229 
34230   /* function exit code */
34231 }
34232 
34233 /* "(tree fragment)":1
34234  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
34235  *     cdef object __pyx_PickleError
34236  *     cdef object __pyx_result
34237  */
34238 
34239 /* Python wrapper */
34240 static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
34241 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)34242 static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
34243   PyObject *__pyx_v___pyx_type = 0;
34244   long __pyx_v___pyx_checksum;
34245   PyObject *__pyx_v___pyx_state = 0;
34246   int __pyx_lineno = 0;
34247   const char *__pyx_filename = NULL;
34248   int __pyx_clineno = 0;
34249   PyObject *__pyx_r = 0;
34250   __Pyx_RefNannyDeclarations
34251   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0);
34252   {
34253     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
34254     PyObject* values[3] = {0,0,0};
34255     if (unlikely(__pyx_kwds)) {
34256       Py_ssize_t kw_args;
34257       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
34258       switch (pos_args) {
34259         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
34260         CYTHON_FALLTHROUGH;
34261         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
34262         CYTHON_FALLTHROUGH;
34263         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
34264         CYTHON_FALLTHROUGH;
34265         case  0: break;
34266         default: goto __pyx_L5_argtuple_error;
34267       }
34268       kw_args = PyDict_Size(__pyx_kwds);
34269       switch (pos_args) {
34270         case  0:
34271         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
34272         else goto __pyx_L5_argtuple_error;
34273         CYTHON_FALLTHROUGH;
34274         case  1:
34275         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
34276         else {
34277           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
34278         }
34279         CYTHON_FALLTHROUGH;
34280         case  2:
34281         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
34282         else {
34283           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
34284         }
34285       }
34286       if (unlikely(kw_args > 0)) {
34287         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
34288       }
34289     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
34290       goto __pyx_L5_argtuple_error;
34291     } else {
34292       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
34293       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
34294       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
34295     }
34296     __pyx_v___pyx_type = values[0];
34297     __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)
34298     __pyx_v___pyx_state = values[2];
34299   }
34300   goto __pyx_L4_argument_unpacking_done;
34301   __pyx_L5_argtuple_error:;
34302   __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
34303   __pyx_L3_error:;
34304   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
34305   __Pyx_RefNannyFinishContext();
34306   return NULL;
34307   __pyx_L4_argument_unpacking_done:;
34308   __pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
34309 
34310   /* function exit code */
34311   __Pyx_RefNannyFinishContext();
34312   return __pyx_r;
34313 }
34314 
__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)34315 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) {
34316   PyObject *__pyx_v___pyx_PickleError = 0;
34317   PyObject *__pyx_v___pyx_result = 0;
34318   PyObject *__pyx_r = NULL;
34319   __Pyx_RefNannyDeclarations
34320   int __pyx_t_1;
34321   PyObject *__pyx_t_2 = NULL;
34322   PyObject *__pyx_t_3 = NULL;
34323   PyObject *__pyx_t_4 = NULL;
34324   PyObject *__pyx_t_5 = NULL;
34325   int __pyx_t_6;
34326   int __pyx_lineno = 0;
34327   const char *__pyx_filename = NULL;
34328   int __pyx_clineno = 0;
34329   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0);
34330 
34331   /* "(tree fragment)":4
34332  *     cdef object __pyx_PickleError
34333  *     cdef object __pyx_result
34334  *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
34335  *         from pickle import PickleError as __pyx_PickleError
34336  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
34337  */
34338   __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb068931) != 0);
34339   if (__pyx_t_1) {
34340 
34341     /* "(tree fragment)":5
34342  *     cdef object __pyx_result
34343  *     if __pyx_checksum != 0xb068931:
34344  *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
34345  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
34346  *     __pyx_result = Enum.__new__(__pyx_type)
34347  */
34348     __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
34349     __Pyx_GOTREF(__pyx_t_2);
34350     __Pyx_INCREF(__pyx_n_s_PickleError);
34351     __Pyx_GIVEREF(__pyx_n_s_PickleError);
34352     PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
34353     __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)
34354     __Pyx_GOTREF(__pyx_t_3);
34355     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
34356     __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
34357     __Pyx_GOTREF(__pyx_t_2);
34358     __Pyx_INCREF(__pyx_t_2);
34359     __pyx_v___pyx_PickleError = __pyx_t_2;
34360     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
34361     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
34362 
34363     /* "(tree fragment)":6
34364  *     if __pyx_checksum != 0xb068931:
34365  *         from pickle import PickleError as __pyx_PickleError
34366  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)             # <<<<<<<<<<<<<<
34367  *     __pyx_result = Enum.__new__(__pyx_type)
34368  *     if __pyx_state is not None:
34369  */
34370     __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 6, __pyx_L1_error)
34371     __Pyx_GOTREF(__pyx_t_2);
34372     __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)
34373     __Pyx_GOTREF(__pyx_t_4);
34374     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
34375     __Pyx_INCREF(__pyx_v___pyx_PickleError);
34376     __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
34377     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
34378       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
34379       if (likely(__pyx_t_5)) {
34380         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
34381         __Pyx_INCREF(__pyx_t_5);
34382         __Pyx_INCREF(function);
34383         __Pyx_DECREF_SET(__pyx_t_2, function);
34384       }
34385     }
34386     __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);
34387     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
34388     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
34389     if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 6, __pyx_L1_error)
34390     __Pyx_GOTREF(__pyx_t_3);
34391     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
34392     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
34393     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
34394     __PYX_ERR(2, 6, __pyx_L1_error)
34395 
34396     /* "(tree fragment)":4
34397  *     cdef object __pyx_PickleError
34398  *     cdef object __pyx_result
34399  *     if __pyx_checksum != 0xb068931:             # <<<<<<<<<<<<<<
34400  *         from pickle import PickleError as __pyx_PickleError
34401  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
34402  */
34403   }
34404 
34405   /* "(tree fragment)":7
34406  *         from pickle import PickleError as __pyx_PickleError
34407  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
34408  *     __pyx_result = Enum.__new__(__pyx_type)             # <<<<<<<<<<<<<<
34409  *     if __pyx_state is not None:
34410  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
34411  */
34412   __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)
34413   __Pyx_GOTREF(__pyx_t_2);
34414   __pyx_t_4 = NULL;
34415   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
34416     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
34417     if (likely(__pyx_t_4)) {
34418       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
34419       __Pyx_INCREF(__pyx_t_4);
34420       __Pyx_INCREF(function);
34421       __Pyx_DECREF_SET(__pyx_t_2, function);
34422     }
34423   }
34424   __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);
34425   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
34426   if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 7, __pyx_L1_error)
34427   __Pyx_GOTREF(__pyx_t_3);
34428   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
34429   __pyx_v___pyx_result = __pyx_t_3;
34430   __pyx_t_3 = 0;
34431 
34432   /* "(tree fragment)":8
34433  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
34434  *     __pyx_result = Enum.__new__(__pyx_type)
34435  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
34436  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
34437  *     return __pyx_result
34438  */
34439   __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
34440   __pyx_t_6 = (__pyx_t_1 != 0);
34441   if (__pyx_t_6) {
34442 
34443     /* "(tree fragment)":9
34444  *     __pyx_result = Enum.__new__(__pyx_type)
34445  *     if __pyx_state is not None:
34446  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
34447  *     return __pyx_result
34448  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
34449  */
34450     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)
34451     __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)
34452     __Pyx_GOTREF(__pyx_t_3);
34453     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
34454 
34455     /* "(tree fragment)":8
34456  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
34457  *     __pyx_result = Enum.__new__(__pyx_type)
34458  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
34459  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
34460  *     return __pyx_result
34461  */
34462   }
34463 
34464   /* "(tree fragment)":10
34465  *     if __pyx_state is not None:
34466  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
34467  *     return __pyx_result             # <<<<<<<<<<<<<<
34468  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
34469  *     __pyx_result.name = __pyx_state[0]
34470  */
34471   __Pyx_XDECREF(__pyx_r);
34472   __Pyx_INCREF(__pyx_v___pyx_result);
34473   __pyx_r = __pyx_v___pyx_result;
34474   goto __pyx_L0;
34475 
34476   /* "(tree fragment)":1
34477  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
34478  *     cdef object __pyx_PickleError
34479  *     cdef object __pyx_result
34480  */
34481 
34482   /* function exit code */
34483   __pyx_L1_error:;
34484   __Pyx_XDECREF(__pyx_t_2);
34485   __Pyx_XDECREF(__pyx_t_3);
34486   __Pyx_XDECREF(__pyx_t_4);
34487   __Pyx_XDECREF(__pyx_t_5);
34488   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
34489   __pyx_r = NULL;
34490   __pyx_L0:;
34491   __Pyx_XDECREF(__pyx_v___pyx_PickleError);
34492   __Pyx_XDECREF(__pyx_v___pyx_result);
34493   __Pyx_XGIVEREF(__pyx_r);
34494   __Pyx_RefNannyFinishContext();
34495   return __pyx_r;
34496 }
34497 
34498 /* "(tree fragment)":11
34499  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
34500  *     return __pyx_result
34501  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
34502  *     __pyx_result.name = __pyx_state[0]
34503  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
34504  */
34505 
__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj * __pyx_v___pyx_result,PyObject * __pyx_v___pyx_state)34506 static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
34507   PyObject *__pyx_r = NULL;
34508   __Pyx_RefNannyDeclarations
34509   PyObject *__pyx_t_1 = NULL;
34510   int __pyx_t_2;
34511   Py_ssize_t __pyx_t_3;
34512   int __pyx_t_4;
34513   int __pyx_t_5;
34514   PyObject *__pyx_t_6 = NULL;
34515   PyObject *__pyx_t_7 = NULL;
34516   PyObject *__pyx_t_8 = NULL;
34517   int __pyx_lineno = 0;
34518   const char *__pyx_filename = NULL;
34519   int __pyx_clineno = 0;
34520   __Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0);
34521 
34522   /* "(tree fragment)":12
34523  *     return __pyx_result
34524  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
34525  *     __pyx_result.name = __pyx_state[0]             # <<<<<<<<<<<<<<
34526  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
34527  *         __pyx_result.__dict__.update(__pyx_state[1])
34528  */
34529   if (unlikely(__pyx_v___pyx_state == Py_None)) {
34530     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
34531     __PYX_ERR(2, 12, __pyx_L1_error)
34532   }
34533   __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)
34534   __Pyx_GOTREF(__pyx_t_1);
34535   __Pyx_GIVEREF(__pyx_t_1);
34536   __Pyx_GOTREF(__pyx_v___pyx_result->name);
34537   __Pyx_DECREF(__pyx_v___pyx_result->name);
34538   __pyx_v___pyx_result->name = __pyx_t_1;
34539   __pyx_t_1 = 0;
34540 
34541   /* "(tree fragment)":13
34542  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
34543  *     __pyx_result.name = __pyx_state[0]
34544  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
34545  *         __pyx_result.__dict__.update(__pyx_state[1])
34546  */
34547   if (unlikely(__pyx_v___pyx_state == Py_None)) {
34548     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
34549     __PYX_ERR(2, 13, __pyx_L1_error)
34550   }
34551   __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)
34552   __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
34553   if (__pyx_t_4) {
34554   } else {
34555     __pyx_t_2 = __pyx_t_4;
34556     goto __pyx_L4_bool_binop_done;
34557   }
34558   __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)
34559   __pyx_t_5 = (__pyx_t_4 != 0);
34560   __pyx_t_2 = __pyx_t_5;
34561   __pyx_L4_bool_binop_done:;
34562   if (__pyx_t_2) {
34563 
34564     /* "(tree fragment)":14
34565  *     __pyx_result.name = __pyx_state[0]
34566  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
34567  *         __pyx_result.__dict__.update(__pyx_state[1])             # <<<<<<<<<<<<<<
34568  */
34569     __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)
34570     __Pyx_GOTREF(__pyx_t_6);
34571     __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)
34572     __Pyx_GOTREF(__pyx_t_7);
34573     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
34574     if (unlikely(__pyx_v___pyx_state == Py_None)) {
34575       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
34576       __PYX_ERR(2, 14, __pyx_L1_error)
34577     }
34578     __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)
34579     __Pyx_GOTREF(__pyx_t_6);
34580     __pyx_t_8 = NULL;
34581     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
34582       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
34583       if (likely(__pyx_t_8)) {
34584         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
34585         __Pyx_INCREF(__pyx_t_8);
34586         __Pyx_INCREF(function);
34587         __Pyx_DECREF_SET(__pyx_t_7, function);
34588       }
34589     }
34590     __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);
34591     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
34592     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
34593     if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
34594     __Pyx_GOTREF(__pyx_t_1);
34595     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
34596     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
34597 
34598     /* "(tree fragment)":13
34599  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
34600  *     __pyx_result.name = __pyx_state[0]
34601  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
34602  *         __pyx_result.__dict__.update(__pyx_state[1])
34603  */
34604   }
34605 
34606   /* "(tree fragment)":11
34607  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
34608  *     return __pyx_result
34609  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
34610  *     __pyx_result.name = __pyx_state[0]
34611  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
34612  */
34613 
34614   /* function exit code */
34615   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
34616   goto __pyx_L0;
34617   __pyx_L1_error:;
34618   __Pyx_XDECREF(__pyx_t_1);
34619   __Pyx_XDECREF(__pyx_t_6);
34620   __Pyx_XDECREF(__pyx_t_7);
34621   __Pyx_XDECREF(__pyx_t_8);
34622   __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
34623   __pyx_r = 0;
34624   __pyx_L0:;
34625   __Pyx_XGIVEREF(__pyx_r);
34626   __Pyx_RefNannyFinishContext();
34627   return __pyx_r;
34628 }
34629 static struct __pyx_vtabstruct_array __pyx_vtable_array;
34630 
__pyx_tp_new_array(PyTypeObject * t,PyObject * a,PyObject * k)34631 static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) {
34632   struct __pyx_array_obj *p;
34633   PyObject *o;
34634   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
34635     o = (*t->tp_alloc)(t, 0);
34636   } else {
34637     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
34638   }
34639   if (unlikely(!o)) return 0;
34640   p = ((struct __pyx_array_obj *)o);
34641   p->__pyx_vtab = __pyx_vtabptr_array;
34642   p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None);
34643   p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None);
34644   if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad;
34645   return o;
34646   bad:
34647   Py_DECREF(o); o = 0;
34648   return NULL;
34649 }
34650 
__pyx_tp_dealloc_array(PyObject * o)34651 static void __pyx_tp_dealloc_array(PyObject *o) {
34652   struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
34653   #if CYTHON_USE_TP_FINALIZE
34654   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))) {
34655     if (PyObject_CallFinalizerFromDealloc(o)) return;
34656   }
34657   #endif
34658   {
34659     PyObject *etype, *eval, *etb;
34660     PyErr_Fetch(&etype, &eval, &etb);
34661     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
34662     __pyx_array___dealloc__(o);
34663     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
34664     PyErr_Restore(etype, eval, etb);
34665   }
34666   Py_CLEAR(p->mode);
34667   Py_CLEAR(p->_format);
34668   (*Py_TYPE(o)->tp_free)(o);
34669 }
__pyx_sq_item_array(PyObject * o,Py_ssize_t i)34670 static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) {
34671   PyObject *r;
34672   PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
34673   r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
34674   Py_DECREF(x);
34675   return r;
34676 }
34677 
__pyx_mp_ass_subscript_array(PyObject * o,PyObject * i,PyObject * v)34678 static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) {
34679   if (v) {
34680     return __pyx_array___setitem__(o, i, v);
34681   }
34682   else {
34683     PyErr_Format(PyExc_NotImplementedError,
34684       "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
34685     return -1;
34686   }
34687 }
34688 
__pyx_tp_getattro_array(PyObject * o,PyObject * n)34689 static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
34690   PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n);
34691   if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
34692     PyErr_Clear();
34693     v = __pyx_array___getattr__(o, n);
34694   }
34695   return v;
34696 }
34697 
__pyx_getprop___pyx_array_memview(PyObject * o,CYTHON_UNUSED void * x)34698 static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) {
34699   return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o);
34700 }
34701 
34702 static PyMethodDef __pyx_methods_array[] = {
34703   {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
34704   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0},
34705   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0},
34706   {0, 0, 0, 0}
34707 };
34708 
34709 static struct PyGetSetDef __pyx_getsets_array[] = {
34710   {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0},
34711   {0, 0, 0, 0, 0}
34712 };
34713 
34714 static PySequenceMethods __pyx_tp_as_sequence_array = {
34715   __pyx_array___len__, /*sq_length*/
34716   0, /*sq_concat*/
34717   0, /*sq_repeat*/
34718   __pyx_sq_item_array, /*sq_item*/
34719   0, /*sq_slice*/
34720   0, /*sq_ass_item*/
34721   0, /*sq_ass_slice*/
34722   0, /*sq_contains*/
34723   0, /*sq_inplace_concat*/
34724   0, /*sq_inplace_repeat*/
34725 };
34726 
34727 static PyMappingMethods __pyx_tp_as_mapping_array = {
34728   __pyx_array___len__, /*mp_length*/
34729   __pyx_array___getitem__, /*mp_subscript*/
34730   __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/
34731 };
34732 
34733 static PyBufferProcs __pyx_tp_as_buffer_array = {
34734   #if PY_MAJOR_VERSION < 3
34735   0, /*bf_getreadbuffer*/
34736   #endif
34737   #if PY_MAJOR_VERSION < 3
34738   0, /*bf_getwritebuffer*/
34739   #endif
34740   #if PY_MAJOR_VERSION < 3
34741   0, /*bf_getsegcount*/
34742   #endif
34743   #if PY_MAJOR_VERSION < 3
34744   0, /*bf_getcharbuffer*/
34745   #endif
34746   __pyx_array_getbuffer, /*bf_getbuffer*/
34747   0, /*bf_releasebuffer*/
34748 };
34749 
34750 static PyTypeObject __pyx_type___pyx_array = {
34751   PyVarObject_HEAD_INIT(0, 0)
34752   "dipy.align.sumsqdiff.array", /*tp_name*/
34753   sizeof(struct __pyx_array_obj), /*tp_basicsize*/
34754   0, /*tp_itemsize*/
34755   __pyx_tp_dealloc_array, /*tp_dealloc*/
34756   #if PY_VERSION_HEX < 0x030800b4
34757   0, /*tp_print*/
34758   #endif
34759   #if PY_VERSION_HEX >= 0x030800b4
34760   0, /*tp_vectorcall_offset*/
34761   #endif
34762   0, /*tp_getattr*/
34763   0, /*tp_setattr*/
34764   #if PY_MAJOR_VERSION < 3
34765   0, /*tp_compare*/
34766   #endif
34767   #if PY_MAJOR_VERSION >= 3
34768   0, /*tp_as_async*/
34769   #endif
34770   0, /*tp_repr*/
34771   0, /*tp_as_number*/
34772   &__pyx_tp_as_sequence_array, /*tp_as_sequence*/
34773   &__pyx_tp_as_mapping_array, /*tp_as_mapping*/
34774   0, /*tp_hash*/
34775   0, /*tp_call*/
34776   0, /*tp_str*/
34777   __pyx_tp_getattro_array, /*tp_getattro*/
34778   0, /*tp_setattro*/
34779   &__pyx_tp_as_buffer_array, /*tp_as_buffer*/
34780   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
34781   0, /*tp_doc*/
34782   0, /*tp_traverse*/
34783   0, /*tp_clear*/
34784   0, /*tp_richcompare*/
34785   0, /*tp_weaklistoffset*/
34786   0, /*tp_iter*/
34787   0, /*tp_iternext*/
34788   __pyx_methods_array, /*tp_methods*/
34789   0, /*tp_members*/
34790   __pyx_getsets_array, /*tp_getset*/
34791   0, /*tp_base*/
34792   0, /*tp_dict*/
34793   0, /*tp_descr_get*/
34794   0, /*tp_descr_set*/
34795   0, /*tp_dictoffset*/
34796   0, /*tp_init*/
34797   0, /*tp_alloc*/
34798   __pyx_tp_new_array, /*tp_new*/
34799   0, /*tp_free*/
34800   0, /*tp_is_gc*/
34801   0, /*tp_bases*/
34802   0, /*tp_mro*/
34803   0, /*tp_cache*/
34804   0, /*tp_subclasses*/
34805   0, /*tp_weaklist*/
34806   0, /*tp_del*/
34807   0, /*tp_version_tag*/
34808   #if PY_VERSION_HEX >= 0x030400a1
34809   0, /*tp_finalize*/
34810   #endif
34811   #if PY_VERSION_HEX >= 0x030800b1
34812   0, /*tp_vectorcall*/
34813   #endif
34814   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
34815   0, /*tp_print*/
34816   #endif
34817 };
34818 
__pyx_tp_new_Enum(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)34819 static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
34820   struct __pyx_MemviewEnum_obj *p;
34821   PyObject *o;
34822   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
34823     o = (*t->tp_alloc)(t, 0);
34824   } else {
34825     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
34826   }
34827   if (unlikely(!o)) return 0;
34828   p = ((struct __pyx_MemviewEnum_obj *)o);
34829   p->name = Py_None; Py_INCREF(Py_None);
34830   return o;
34831 }
34832 
__pyx_tp_dealloc_Enum(PyObject * o)34833 static void __pyx_tp_dealloc_Enum(PyObject *o) {
34834   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
34835   #if CYTHON_USE_TP_FINALIZE
34836   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
34837     if (PyObject_CallFinalizerFromDealloc(o)) return;
34838   }
34839   #endif
34840   PyObject_GC_UnTrack(o);
34841   Py_CLEAR(p->name);
34842   (*Py_TYPE(o)->tp_free)(o);
34843 }
34844 
__pyx_tp_traverse_Enum(PyObject * o,visitproc v,void * a)34845 static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
34846   int e;
34847   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
34848   if (p->name) {
34849     e = (*v)(p->name, a); if (e) return e;
34850   }
34851   return 0;
34852 }
34853 
__pyx_tp_clear_Enum(PyObject * o)34854 static int __pyx_tp_clear_Enum(PyObject *o) {
34855   PyObject* tmp;
34856   struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
34857   tmp = ((PyObject*)p->name);
34858   p->name = Py_None; Py_INCREF(Py_None);
34859   Py_XDECREF(tmp);
34860   return 0;
34861 }
34862 
34863 static PyMethodDef __pyx_methods_Enum[] = {
34864   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0},
34865   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0},
34866   {0, 0, 0, 0}
34867 };
34868 
34869 static PyTypeObject __pyx_type___pyx_MemviewEnum = {
34870   PyVarObject_HEAD_INIT(0, 0)
34871   "dipy.align.sumsqdiff.Enum", /*tp_name*/
34872   sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
34873   0, /*tp_itemsize*/
34874   __pyx_tp_dealloc_Enum, /*tp_dealloc*/
34875   #if PY_VERSION_HEX < 0x030800b4
34876   0, /*tp_print*/
34877   #endif
34878   #if PY_VERSION_HEX >= 0x030800b4
34879   0, /*tp_vectorcall_offset*/
34880   #endif
34881   0, /*tp_getattr*/
34882   0, /*tp_setattr*/
34883   #if PY_MAJOR_VERSION < 3
34884   0, /*tp_compare*/
34885   #endif
34886   #if PY_MAJOR_VERSION >= 3
34887   0, /*tp_as_async*/
34888   #endif
34889   __pyx_MemviewEnum___repr__, /*tp_repr*/
34890   0, /*tp_as_number*/
34891   0, /*tp_as_sequence*/
34892   0, /*tp_as_mapping*/
34893   0, /*tp_hash*/
34894   0, /*tp_call*/
34895   0, /*tp_str*/
34896   0, /*tp_getattro*/
34897   0, /*tp_setattro*/
34898   0, /*tp_as_buffer*/
34899   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
34900   0, /*tp_doc*/
34901   __pyx_tp_traverse_Enum, /*tp_traverse*/
34902   __pyx_tp_clear_Enum, /*tp_clear*/
34903   0, /*tp_richcompare*/
34904   0, /*tp_weaklistoffset*/
34905   0, /*tp_iter*/
34906   0, /*tp_iternext*/
34907   __pyx_methods_Enum, /*tp_methods*/
34908   0, /*tp_members*/
34909   0, /*tp_getset*/
34910   0, /*tp_base*/
34911   0, /*tp_dict*/
34912   0, /*tp_descr_get*/
34913   0, /*tp_descr_set*/
34914   0, /*tp_dictoffset*/
34915   __pyx_MemviewEnum___init__, /*tp_init*/
34916   0, /*tp_alloc*/
34917   __pyx_tp_new_Enum, /*tp_new*/
34918   0, /*tp_free*/
34919   0, /*tp_is_gc*/
34920   0, /*tp_bases*/
34921   0, /*tp_mro*/
34922   0, /*tp_cache*/
34923   0, /*tp_subclasses*/
34924   0, /*tp_weaklist*/
34925   0, /*tp_del*/
34926   0, /*tp_version_tag*/
34927   #if PY_VERSION_HEX >= 0x030400a1
34928   0, /*tp_finalize*/
34929   #endif
34930   #if PY_VERSION_HEX >= 0x030800b1
34931   0, /*tp_vectorcall*/
34932   #endif
34933   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
34934   0, /*tp_print*/
34935   #endif
34936 };
34937 static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview;
34938 
__pyx_tp_new_memoryview(PyTypeObject * t,PyObject * a,PyObject * k)34939 static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) {
34940   struct __pyx_memoryview_obj *p;
34941   PyObject *o;
34942   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
34943     o = (*t->tp_alloc)(t, 0);
34944   } else {
34945     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
34946   }
34947   if (unlikely(!o)) return 0;
34948   p = ((struct __pyx_memoryview_obj *)o);
34949   p->__pyx_vtab = __pyx_vtabptr_memoryview;
34950   p->obj = Py_None; Py_INCREF(Py_None);
34951   p->_size = Py_None; Py_INCREF(Py_None);
34952   p->_array_interface = Py_None; Py_INCREF(Py_None);
34953   p->view.obj = NULL;
34954   if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad;
34955   return o;
34956   bad:
34957   Py_DECREF(o); o = 0;
34958   return NULL;
34959 }
34960 
__pyx_tp_dealloc_memoryview(PyObject * o)34961 static void __pyx_tp_dealloc_memoryview(PyObject *o) {
34962   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
34963   #if CYTHON_USE_TP_FINALIZE
34964   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
34965     if (PyObject_CallFinalizerFromDealloc(o)) return;
34966   }
34967   #endif
34968   PyObject_GC_UnTrack(o);
34969   {
34970     PyObject *etype, *eval, *etb;
34971     PyErr_Fetch(&etype, &eval, &etb);
34972     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
34973     __pyx_memoryview___dealloc__(o);
34974     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
34975     PyErr_Restore(etype, eval, etb);
34976   }
34977   Py_CLEAR(p->obj);
34978   Py_CLEAR(p->_size);
34979   Py_CLEAR(p->_array_interface);
34980   (*Py_TYPE(o)->tp_free)(o);
34981 }
34982 
__pyx_tp_traverse_memoryview(PyObject * o,visitproc v,void * a)34983 static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) {
34984   int e;
34985   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
34986   if (p->obj) {
34987     e = (*v)(p->obj, a); if (e) return e;
34988   }
34989   if (p->_size) {
34990     e = (*v)(p->_size, a); if (e) return e;
34991   }
34992   if (p->_array_interface) {
34993     e = (*v)(p->_array_interface, a); if (e) return e;
34994   }
34995   if (p->view.obj) {
34996     e = (*v)(p->view.obj, a); if (e) return e;
34997   }
34998   return 0;
34999 }
35000 
__pyx_tp_clear_memoryview(PyObject * o)35001 static int __pyx_tp_clear_memoryview(PyObject *o) {
35002   PyObject* tmp;
35003   struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
35004   tmp = ((PyObject*)p->obj);
35005   p->obj = Py_None; Py_INCREF(Py_None);
35006   Py_XDECREF(tmp);
35007   tmp = ((PyObject*)p->_size);
35008   p->_size = Py_None; Py_INCREF(Py_None);
35009   Py_XDECREF(tmp);
35010   tmp = ((PyObject*)p->_array_interface);
35011   p->_array_interface = Py_None; Py_INCREF(Py_None);
35012   Py_XDECREF(tmp);
35013   Py_CLEAR(p->view.obj);
35014   return 0;
35015 }
__pyx_sq_item_memoryview(PyObject * o,Py_ssize_t i)35016 static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) {
35017   PyObject *r;
35018   PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
35019   r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
35020   Py_DECREF(x);
35021   return r;
35022 }
35023 
__pyx_mp_ass_subscript_memoryview(PyObject * o,PyObject * i,PyObject * v)35024 static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) {
35025   if (v) {
35026     return __pyx_memoryview___setitem__(o, i, v);
35027   }
35028   else {
35029     PyErr_Format(PyExc_NotImplementedError,
35030       "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
35031     return -1;
35032   }
35033 }
35034 
__pyx_getprop___pyx_memoryview_T(PyObject * o,CYTHON_UNUSED void * x)35035 static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) {
35036   return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o);
35037 }
35038 
__pyx_getprop___pyx_memoryview_base(PyObject * o,CYTHON_UNUSED void * x)35039 static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
35040   return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o);
35041 }
35042 
__pyx_getprop___pyx_memoryview_shape(PyObject * o,CYTHON_UNUSED void * x)35043 static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
35044   return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o);
35045 }
35046 
__pyx_getprop___pyx_memoryview_strides(PyObject * o,CYTHON_UNUSED void * x)35047 static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
35048   return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o);
35049 }
35050 
__pyx_getprop___pyx_memoryview_suboffsets(PyObject * o,CYTHON_UNUSED void * x)35051 static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
35052   return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o);
35053 }
35054 
__pyx_getprop___pyx_memoryview_ndim(PyObject * o,CYTHON_UNUSED void * x)35055 static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
35056   return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o);
35057 }
35058 
__pyx_getprop___pyx_memoryview_itemsize(PyObject * o,CYTHON_UNUSED void * x)35059 static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
35060   return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o);
35061 }
35062 
__pyx_getprop___pyx_memoryview_nbytes(PyObject * o,CYTHON_UNUSED void * x)35063 static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
35064   return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o);
35065 }
35066 
__pyx_getprop___pyx_memoryview_size(PyObject * o,CYTHON_UNUSED void * x)35067 static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
35068   return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o);
35069 }
35070 
35071 static PyMethodDef __pyx_methods_memoryview[] = {
35072   {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0},
35073   {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0},
35074   {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0},
35075   {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0},
35076   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0},
35077   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0},
35078   {0, 0, 0, 0}
35079 };
35080 
35081 static struct PyGetSetDef __pyx_getsets_memoryview[] = {
35082   {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0},
35083   {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0},
35084   {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0},
35085   {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0},
35086   {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0},
35087   {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0},
35088   {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0},
35089   {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0},
35090   {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0},
35091   {0, 0, 0, 0, 0}
35092 };
35093 
35094 static PySequenceMethods __pyx_tp_as_sequence_memoryview = {
35095   __pyx_memoryview___len__, /*sq_length*/
35096   0, /*sq_concat*/
35097   0, /*sq_repeat*/
35098   __pyx_sq_item_memoryview, /*sq_item*/
35099   0, /*sq_slice*/
35100   0, /*sq_ass_item*/
35101   0, /*sq_ass_slice*/
35102   0, /*sq_contains*/
35103   0, /*sq_inplace_concat*/
35104   0, /*sq_inplace_repeat*/
35105 };
35106 
35107 static PyMappingMethods __pyx_tp_as_mapping_memoryview = {
35108   __pyx_memoryview___len__, /*mp_length*/
35109   __pyx_memoryview___getitem__, /*mp_subscript*/
35110   __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/
35111 };
35112 
35113 static PyBufferProcs __pyx_tp_as_buffer_memoryview = {
35114   #if PY_MAJOR_VERSION < 3
35115   0, /*bf_getreadbuffer*/
35116   #endif
35117   #if PY_MAJOR_VERSION < 3
35118   0, /*bf_getwritebuffer*/
35119   #endif
35120   #if PY_MAJOR_VERSION < 3
35121   0, /*bf_getsegcount*/
35122   #endif
35123   #if PY_MAJOR_VERSION < 3
35124   0, /*bf_getcharbuffer*/
35125   #endif
35126   __pyx_memoryview_getbuffer, /*bf_getbuffer*/
35127   0, /*bf_releasebuffer*/
35128 };
35129 
35130 static PyTypeObject __pyx_type___pyx_memoryview = {
35131   PyVarObject_HEAD_INIT(0, 0)
35132   "dipy.align.sumsqdiff.memoryview", /*tp_name*/
35133   sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
35134   0, /*tp_itemsize*/
35135   __pyx_tp_dealloc_memoryview, /*tp_dealloc*/
35136   #if PY_VERSION_HEX < 0x030800b4
35137   0, /*tp_print*/
35138   #endif
35139   #if PY_VERSION_HEX >= 0x030800b4
35140   0, /*tp_vectorcall_offset*/
35141   #endif
35142   0, /*tp_getattr*/
35143   0, /*tp_setattr*/
35144   #if PY_MAJOR_VERSION < 3
35145   0, /*tp_compare*/
35146   #endif
35147   #if PY_MAJOR_VERSION >= 3
35148   0, /*tp_as_async*/
35149   #endif
35150   __pyx_memoryview___repr__, /*tp_repr*/
35151   0, /*tp_as_number*/
35152   &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/
35153   &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/
35154   0, /*tp_hash*/
35155   0, /*tp_call*/
35156   __pyx_memoryview___str__, /*tp_str*/
35157   0, /*tp_getattro*/
35158   0, /*tp_setattro*/
35159   &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/
35160   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
35161   0, /*tp_doc*/
35162   __pyx_tp_traverse_memoryview, /*tp_traverse*/
35163   __pyx_tp_clear_memoryview, /*tp_clear*/
35164   0, /*tp_richcompare*/
35165   0, /*tp_weaklistoffset*/
35166   0, /*tp_iter*/
35167   0, /*tp_iternext*/
35168   __pyx_methods_memoryview, /*tp_methods*/
35169   0, /*tp_members*/
35170   __pyx_getsets_memoryview, /*tp_getset*/
35171   0, /*tp_base*/
35172   0, /*tp_dict*/
35173   0, /*tp_descr_get*/
35174   0, /*tp_descr_set*/
35175   0, /*tp_dictoffset*/
35176   0, /*tp_init*/
35177   0, /*tp_alloc*/
35178   __pyx_tp_new_memoryview, /*tp_new*/
35179   0, /*tp_free*/
35180   0, /*tp_is_gc*/
35181   0, /*tp_bases*/
35182   0, /*tp_mro*/
35183   0, /*tp_cache*/
35184   0, /*tp_subclasses*/
35185   0, /*tp_weaklist*/
35186   0, /*tp_del*/
35187   0, /*tp_version_tag*/
35188   #if PY_VERSION_HEX >= 0x030400a1
35189   0, /*tp_finalize*/
35190   #endif
35191   #if PY_VERSION_HEX >= 0x030800b1
35192   0, /*tp_vectorcall*/
35193   #endif
35194   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
35195   0, /*tp_print*/
35196   #endif
35197 };
35198 static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice;
35199 
__pyx_tp_new__memoryviewslice(PyTypeObject * t,PyObject * a,PyObject * k)35200 static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) {
35201   struct __pyx_memoryviewslice_obj *p;
35202   PyObject *o = __pyx_tp_new_memoryview(t, a, k);
35203   if (unlikely(!o)) return 0;
35204   p = ((struct __pyx_memoryviewslice_obj *)o);
35205   p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice;
35206   p->from_object = Py_None; Py_INCREF(Py_None);
35207   p->from_slice.memview = NULL;
35208   return o;
35209 }
35210 
__pyx_tp_dealloc__memoryviewslice(PyObject * o)35211 static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
35212   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
35213   #if CYTHON_USE_TP_FINALIZE
35214   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
35215     if (PyObject_CallFinalizerFromDealloc(o)) return;
35216   }
35217   #endif
35218   PyObject_GC_UnTrack(o);
35219   {
35220     PyObject *etype, *eval, *etb;
35221     PyErr_Fetch(&etype, &eval, &etb);
35222     __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
35223     __pyx_memoryviewslice___dealloc__(o);
35224     __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
35225     PyErr_Restore(etype, eval, etb);
35226   }
35227   Py_CLEAR(p->from_object);
35228   PyObject_GC_Track(o);
35229   __pyx_tp_dealloc_memoryview(o);
35230 }
35231 
__pyx_tp_traverse__memoryviewslice(PyObject * o,visitproc v,void * a)35232 static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) {
35233   int e;
35234   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
35235   e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e;
35236   if (p->from_object) {
35237     e = (*v)(p->from_object, a); if (e) return e;
35238   }
35239   return 0;
35240 }
35241 
__pyx_tp_clear__memoryviewslice(PyObject * o)35242 static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
35243   PyObject* tmp;
35244   struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
35245   __pyx_tp_clear_memoryview(o);
35246   tmp = ((PyObject*)p->from_object);
35247   p->from_object = Py_None; Py_INCREF(Py_None);
35248   Py_XDECREF(tmp);
35249   __PYX_XDEC_MEMVIEW(&p->from_slice, 1);
35250   return 0;
35251 }
35252 
__pyx_getprop___pyx_memoryviewslice_base(PyObject * o,CYTHON_UNUSED void * x)35253 static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) {
35254   return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o);
35255 }
35256 
35257 static PyMethodDef __pyx_methods__memoryviewslice[] = {
35258   {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0},
35259   {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0},
35260   {0, 0, 0, 0}
35261 };
35262 
35263 static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
35264   {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0},
35265   {0, 0, 0, 0, 0}
35266 };
35267 
35268 static PyTypeObject __pyx_type___pyx_memoryviewslice = {
35269   PyVarObject_HEAD_INIT(0, 0)
35270   "dipy.align.sumsqdiff._memoryviewslice", /*tp_name*/
35271   sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
35272   0, /*tp_itemsize*/
35273   __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
35274   #if PY_VERSION_HEX < 0x030800b4
35275   0, /*tp_print*/
35276   #endif
35277   #if PY_VERSION_HEX >= 0x030800b4
35278   0, /*tp_vectorcall_offset*/
35279   #endif
35280   0, /*tp_getattr*/
35281   0, /*tp_setattr*/
35282   #if PY_MAJOR_VERSION < 3
35283   0, /*tp_compare*/
35284   #endif
35285   #if PY_MAJOR_VERSION >= 3
35286   0, /*tp_as_async*/
35287   #endif
35288   #if CYTHON_COMPILING_IN_PYPY
35289   __pyx_memoryview___repr__, /*tp_repr*/
35290   #else
35291   0, /*tp_repr*/
35292   #endif
35293   0, /*tp_as_number*/
35294   0, /*tp_as_sequence*/
35295   0, /*tp_as_mapping*/
35296   0, /*tp_hash*/
35297   0, /*tp_call*/
35298   #if CYTHON_COMPILING_IN_PYPY
35299   __pyx_memoryview___str__, /*tp_str*/
35300   #else
35301   0, /*tp_str*/
35302   #endif
35303   0, /*tp_getattro*/
35304   0, /*tp_setattro*/
35305   0, /*tp_as_buffer*/
35306   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
35307   "Internal class for passing memoryview slices to Python", /*tp_doc*/
35308   __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/
35309   __pyx_tp_clear__memoryviewslice, /*tp_clear*/
35310   0, /*tp_richcompare*/
35311   0, /*tp_weaklistoffset*/
35312   0, /*tp_iter*/
35313   0, /*tp_iternext*/
35314   __pyx_methods__memoryviewslice, /*tp_methods*/
35315   0, /*tp_members*/
35316   __pyx_getsets__memoryviewslice, /*tp_getset*/
35317   0, /*tp_base*/
35318   0, /*tp_dict*/
35319   0, /*tp_descr_get*/
35320   0, /*tp_descr_set*/
35321   0, /*tp_dictoffset*/
35322   0, /*tp_init*/
35323   0, /*tp_alloc*/
35324   __pyx_tp_new__memoryviewslice, /*tp_new*/
35325   0, /*tp_free*/
35326   0, /*tp_is_gc*/
35327   0, /*tp_bases*/
35328   0, /*tp_mro*/
35329   0, /*tp_cache*/
35330   0, /*tp_subclasses*/
35331   0, /*tp_weaklist*/
35332   0, /*tp_del*/
35333   0, /*tp_version_tag*/
35334   #if PY_VERSION_HEX >= 0x030400a1
35335   0, /*tp_finalize*/
35336   #endif
35337   #if PY_VERSION_HEX >= 0x030800b1
35338   0, /*tp_vectorcall*/
35339   #endif
35340   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
35341   0, /*tp_print*/
35342   #endif
35343 };
35344 
35345 static PyMethodDef __pyx_methods[] = {
35346   {0, 0, 0, 0}
35347 };
35348 
35349 #if PY_MAJOR_VERSION >= 3
35350 #if CYTHON_PEP489_MULTI_PHASE_INIT
35351 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
35352 static int __pyx_pymod_exec_sumsqdiff(PyObject* module); /*proto*/
35353 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
35354   {Py_mod_create, (void*)__pyx_pymod_create},
35355   {Py_mod_exec, (void*)__pyx_pymod_exec_sumsqdiff},
35356   {0, NULL}
35357 };
35358 #endif
35359 
35360 static struct PyModuleDef __pyx_moduledef = {
35361     PyModuleDef_HEAD_INIT,
35362     "sumsqdiff",
35363     __pyx_k_Utility_functions_used_by_the_S, /* m_doc */
35364   #if CYTHON_PEP489_MULTI_PHASE_INIT
35365     0, /* m_size */
35366   #else
35367     -1, /* m_size */
35368   #endif
35369     __pyx_methods /* m_methods */,
35370   #if CYTHON_PEP489_MULTI_PHASE_INIT
35371     __pyx_moduledef_slots, /* m_slots */
35372   #else
35373     NULL, /* m_reload */
35374   #endif
35375     NULL, /* m_traverse */
35376     NULL, /* m_clear */
35377     NULL /* m_free */
35378 };
35379 #endif
35380 #ifndef CYTHON_SMALL_CODE
35381 #if defined(__clang__)
35382     #define CYTHON_SMALL_CODE
35383 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
35384     #define CYTHON_SMALL_CODE __attribute__((cold))
35385 #else
35386     #define CYTHON_SMALL_CODE
35387 #endif
35388 #endif
35389 
35390 static __Pyx_StringTabEntry __pyx_string_tab[] = {
35391   {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
35392   {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1},
35393   {&__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},
35394   {&__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},
35395   {&__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},
35396   {&__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},
35397   {&__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},
35398   {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1},
35399   {&__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},
35400   {&__pyx_kp_s_Expected_at_least_d_argument_s_g, __pyx_k_Expected_at_least_d_argument_s_g, sizeof(__pyx_k_Expected_at_least_d_argument_s_g), 0, 0, 1, 0},
35401   {&__pyx_kp_s_Function_call_with_ambiguous_arg, __pyx_k_Function_call_with_ambiguous_arg, sizeof(__pyx_k_Function_call_with_ambiguous_arg), 0, 0, 1, 0},
35402   {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
35403   {&__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},
35404   {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
35405   {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0},
35406   {&__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},
35407   {&__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},
35408   {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
35409   {&__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},
35410   {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0},
35411   {&__pyx_n_s_NUM_NEIGHBORS, __pyx_k_NUM_NEIGHBORS, sizeof(__pyx_k_NUM_NEIGHBORS), 0, 0, 1, 1},
35412   {&__pyx_kp_s_No_matching_signature_found, __pyx_k_No_matching_signature_found, sizeof(__pyx_k_No_matching_signature_found), 0, 0, 1, 0},
35413   {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
35414   {&__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},
35415   {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
35416   {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
35417   {&__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},
35418   {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
35419   {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1},
35420   {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
35421   {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0},
35422   {&__pyx_kp_s__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 0, 1, 0},
35423   {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
35424   {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
35425   {&__pyx_n_s_asarray, __pyx_k_asarray, sizeof(__pyx_k_asarray), 0, 0, 1, 1},
35426   {&__pyx_n_s_ascontiguousarray, __pyx_k_ascontiguousarray, sizeof(__pyx_k_ascontiguousarray), 0, 0, 1, 1},
35427   {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
35428   {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
35429   {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
35430   {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
35431   {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
35432   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
35433   {&__pyx_n_s_compute_energy_ssd_2d, __pyx_k_compute_energy_ssd_2d, sizeof(__pyx_k_compute_energy_ssd_2d), 0, 0, 1, 1},
35434   {&__pyx_n_s_compute_energy_ssd_3d, __pyx_k_compute_energy_ssd_3d, sizeof(__pyx_k_compute_energy_ssd_3d), 0, 0, 1, 1},
35435   {&__pyx_n_s_compute_residual_displacement_fi, __pyx_k_compute_residual_displacement_fi, sizeof(__pyx_k_compute_residual_displacement_fi), 0, 0, 1, 1},
35436   {&__pyx_n_s_compute_residual_displacement_fi_2, __pyx_k_compute_residual_displacement_fi_2, sizeof(__pyx_k_compute_residual_displacement_fi_2), 0, 0, 1, 1},
35437   {&__pyx_n_s_compute_ssd_demons_step_2d, __pyx_k_compute_ssd_demons_step_2d, sizeof(__pyx_k_compute_ssd_demons_step_2d), 0, 0, 1, 1},
35438   {&__pyx_n_s_compute_ssd_demons_step_3d, __pyx_k_compute_ssd_demons_step_3d, sizeof(__pyx_k_compute_ssd_demons_step_3d), 0, 0, 1, 1},
35439   {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0},
35440   {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0},
35441   {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1},
35442   {&__pyx_n_s_dCol, __pyx_k_dCol, sizeof(__pyx_k_dCol), 0, 0, 1, 1},
35443   {&__pyx_n_s_dRow, __pyx_k_dRow, sizeof(__pyx_k_dRow), 0, 0, 1, 1},
35444   {&__pyx_n_s_dSlice, __pyx_k_dSlice, sizeof(__pyx_k_dSlice), 0, 0, 1, 1},
35445   {&__pyx_n_s_dc, __pyx_k_dc, sizeof(__pyx_k_dc), 0, 0, 1, 1},
35446   {&__pyx_n_s_defaults, __pyx_k_defaults, sizeof(__pyx_k_defaults), 0, 0, 1, 1},
35447   {&__pyx_n_s_delta, __pyx_k_delta, sizeof(__pyx_k_delta), 0, 0, 1, 1},
35448   {&__pyx_n_s_delta_2, __pyx_k_delta_2, sizeof(__pyx_k_delta_2), 0, 0, 1, 1},
35449   {&__pyx_n_s_delta_field, __pyx_k_delta_field, sizeof(__pyx_k_delta_field), 0, 0, 1, 1},
35450   {&__pyx_n_s_den, __pyx_k_den, sizeof(__pyx_k_den), 0, 0, 1, 1},
35451   {&__pyx_n_s_det, __pyx_k_det, sizeof(__pyx_k_det), 0, 0, 1, 1},
35452   {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
35453   {&__pyx_n_s_dipy_align_sumsqdiff, __pyx_k_dipy_align_sumsqdiff, sizeof(__pyx_k_dipy_align_sumsqdiff), 0, 0, 1, 1},
35454   {&__pyx_kp_s_dipy_align_sumsqdiff_pyx, __pyx_k_dipy_align_sumsqdiff_pyx, sizeof(__pyx_k_dipy_align_sumsqdiff_pyx), 0, 0, 1, 0},
35455   {&__pyx_n_s_disp, __pyx_k_disp, sizeof(__pyx_k_disp), 0, 0, 1, 1},
35456   {&__pyx_n_s_displacement_field, __pyx_k_displacement_field, sizeof(__pyx_k_displacement_field), 0, 0, 1, 1},
35457   {&__pyx_n_s_dotP, __pyx_k_dotP, sizeof(__pyx_k_dotP), 0, 0, 1, 1},
35458   {&__pyx_n_s_double, __pyx_k_double, sizeof(__pyx_k_double), 0, 0, 1, 1},
35459   {&__pyx_n_s_dr, __pyx_k_dr, sizeof(__pyx_k_dr), 0, 0, 1, 1},
35460   {&__pyx_n_s_ds, __pyx_k_ds, sizeof(__pyx_k_ds), 0, 0, 1, 1},
35461   {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
35462   {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
35463   {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
35464   {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
35465   {&__pyx_n_s_energy, __pyx_k_energy, sizeof(__pyx_k_energy), 0, 0, 1, 1},
35466   {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
35467   {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
35468   {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
35469   {&__pyx_n_s_float, __pyx_k_float, sizeof(__pyx_k_float), 0, 0, 1, 1},
35470   {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
35471   {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1},
35472   {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1},
35473   {&__pyx_n_s_ftype, __pyx_k_ftype, sizeof(__pyx_k_ftype), 0, 0, 1, 1},
35474   {&__pyx_n_s_g, __pyx_k_g, sizeof(__pyx_k_g), 0, 0, 1, 1},
35475   {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
35476   {&__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},
35477   {&__pyx_n_s_grad, __pyx_k_grad, sizeof(__pyx_k_grad), 0, 0, 1, 1},
35478   {&__pyx_n_s_gradient_field, __pyx_k_gradient_field, sizeof(__pyx_k_gradient_field), 0, 0, 1, 1},
35479   {&__pyx_n_s_gradient_moving, __pyx_k_gradient_moving, sizeof(__pyx_k_gradient_moving), 0, 0, 1, 1},
35480   {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
35481   {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
35482   {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
35483   {&__pyx_n_s_is_singular, __pyx_k_is_singular, sizeof(__pyx_k_is_singular), 0, 0, 1, 1},
35484   {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
35485   {&__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},
35486   {&__pyx_n_s_iterate_residual_displacement_fi, __pyx_k_iterate_residual_displacement_fi, sizeof(__pyx_k_iterate_residual_displacement_fi), 0, 0, 1, 1},
35487   {&__pyx_n_s_iterate_residual_displacement_fi_2, __pyx_k_iterate_residual_displacement_fi_2, sizeof(__pyx_k_iterate_residual_displacement_fi_2), 0, 0, 1, 1},
35488   {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1},
35489   {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1},
35490   {&__pyx_n_s_kind, __pyx_k_kind, sizeof(__pyx_k_kind), 0, 0, 1, 1},
35491   {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
35492   {&__pyx_n_s_lambda_param, __pyx_k_lambda_param, sizeof(__pyx_k_lambda_param), 0, 0, 1, 1},
35493   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
35494   {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
35495   {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
35496   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
35497   {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
35498   {&__pyx_n_s_nc, __pyx_k_nc, sizeof(__pyx_k_nc), 0, 0, 1, 1},
35499   {&__pyx_n_s_ncols, __pyx_k_ncols, sizeof(__pyx_k_ncols), 0, 0, 1, 1},
35500   {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
35501   {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
35502   {&__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},
35503   {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
35504   {&__pyx_n_s_nr, __pyx_k_nr, sizeof(__pyx_k_nr), 0, 0, 1, 1},
35505   {&__pyx_n_s_nrm2, __pyx_k_nrm2, sizeof(__pyx_k_nrm2), 0, 0, 1, 1},
35506   {&__pyx_n_s_nrows, __pyx_k_nrows, sizeof(__pyx_k_nrows), 0, 0, 1, 1},
35507   {&__pyx_n_s_ns, __pyx_k_ns, sizeof(__pyx_k_ns), 0, 0, 1, 1},
35508   {&__pyx_n_s_nslices, __pyx_k_nslices, sizeof(__pyx_k_nslices), 0, 0, 1, 1},
35509   {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
35510   {&__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},
35511   {&__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},
35512   {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
35513   {&__pyx_n_s_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 0, 1, 1},
35514   {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
35515   {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
35516   {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
35517   {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
35518   {&__pyx_n_s_pyx_fuse_0compute_energy_ssd_2, __pyx_k_pyx_fuse_0compute_energy_ssd_2, sizeof(__pyx_k_pyx_fuse_0compute_energy_ssd_2), 0, 0, 1, 1},
35519   {&__pyx_n_s_pyx_fuse_0compute_energy_ssd_3, __pyx_k_pyx_fuse_0compute_energy_ssd_3, sizeof(__pyx_k_pyx_fuse_0compute_energy_ssd_3), 0, 0, 1, 1},
35520   {&__pyx_n_s_pyx_fuse_0compute_residual_dis, __pyx_k_pyx_fuse_0compute_residual_dis, sizeof(__pyx_k_pyx_fuse_0compute_residual_dis), 0, 0, 1, 1},
35521   {&__pyx_n_s_pyx_fuse_0iterate_residual_dis, __pyx_k_pyx_fuse_0iterate_residual_dis, sizeof(__pyx_k_pyx_fuse_0iterate_residual_dis), 0, 0, 1, 1},
35522   {&__pyx_n_s_pyx_fuse_0iterate_residual_dis_2, __pyx_k_pyx_fuse_0iterate_residual_dis_2, sizeof(__pyx_k_pyx_fuse_0iterate_residual_dis_2), 0, 0, 1, 1},
35523   {&__pyx_n_s_pyx_fuse_1compute_energy_ssd_2, __pyx_k_pyx_fuse_1compute_energy_ssd_2, sizeof(__pyx_k_pyx_fuse_1compute_energy_ssd_2), 0, 0, 1, 1},
35524   {&__pyx_n_s_pyx_fuse_1compute_energy_ssd_3, __pyx_k_pyx_fuse_1compute_energy_ssd_3, sizeof(__pyx_k_pyx_fuse_1compute_energy_ssd_3), 0, 0, 1, 1},
35525   {&__pyx_n_s_pyx_fuse_1compute_residual_dis, __pyx_k_pyx_fuse_1compute_residual_dis, sizeof(__pyx_k_pyx_fuse_1compute_residual_dis), 0, 0, 1, 1},
35526   {&__pyx_n_s_pyx_fuse_1iterate_residual_dis, __pyx_k_pyx_fuse_1iterate_residual_dis, sizeof(__pyx_k_pyx_fuse_1iterate_residual_dis), 0, 0, 1, 1},
35527   {&__pyx_n_s_pyx_fuse_1iterate_residual_dis_2, __pyx_k_pyx_fuse_1iterate_residual_dis_2, sizeof(__pyx_k_pyx_fuse_1iterate_residual_dis_2), 0, 0, 1, 1},
35528   {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
35529   {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
35530   {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
35531   {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
35532   {&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 0, 0, 1, 1},
35533   {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
35534   {&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1},
35535   {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
35536   {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
35537   {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
35538   {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
35539   {&__pyx_n_s_residual, __pyx_k_residual, sizeof(__pyx_k_residual), 0, 0, 1, 1},
35540   {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
35541   {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
35542   {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
35543   {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
35544   {&__pyx_n_s_sigma_sq_x, __pyx_k_sigma_sq_x, sizeof(__pyx_k_sigma_sq_x), 0, 0, 1, 1},
35545   {&__pyx_n_s_sigmasq, __pyx_k_sigmasq, sizeof(__pyx_k_sigmasq), 0, 0, 1, 1},
35546   {&__pyx_n_s_sigmasq_field, __pyx_k_sigmasq_field, sizeof(__pyx_k_sigmasq_field), 0, 0, 1, 1},
35547   {&__pyx_n_s_signatures, __pyx_k_signatures, sizeof(__pyx_k_signatures), 0, 0, 1, 1},
35548   {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
35549   {&__pyx_n_s_solve_2d_symmetric_positive_defi, __pyx_k_solve_2d_symmetric_positive_defi, sizeof(__pyx_k_solve_2d_symmetric_positive_defi), 0, 0, 1, 1},
35550   {&__pyx_n_s_solve_3d_symmetric_positive_defi, __pyx_k_solve_3d_symmetric_positive_defi, sizeof(__pyx_k_solve_3d_symmetric_positive_defi), 0, 0, 1, 1},
35551   {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
35552   {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
35553   {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
35554   {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
35555   {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0},
35556   {&__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},
35557   {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0},
35558   {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
35559   {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
35560   {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
35561   {&__pyx_n_s_target, __pyx_k_target, sizeof(__pyx_k_target), 0, 0, 1, 1},
35562   {&__pyx_n_s_tau, __pyx_k_tau, sizeof(__pyx_k_tau), 0, 0, 1, 1},
35563   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
35564   {&__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},
35565   {&__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},
35566   {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
35567   {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
35568   {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1},
35569   {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
35570   {0, 0, 0, 0, 0, 0, 0}
35571 };
__Pyx_InitCachedBuiltins(void)35572 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
35573   __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 163, __pyx_L1_error)
35574   __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 163, __pyx_L1_error)
35575   __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 947, __pyx_L1_error)
35576   __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(2, 133, __pyx_L1_error)
35577   __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(2, 148, __pyx_L1_error)
35578   __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(2, 151, __pyx_L1_error)
35579   __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(2, 404, __pyx_L1_error)
35580   __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(2, 613, __pyx_L1_error)
35581   __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(2, 832, __pyx_L1_error)
35582   return 0;
35583   __pyx_L1_error:;
35584   return -1;
35585 }
35586 
__Pyx_InitCachedConstants(void)35587 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
35588   __Pyx_RefNannyDeclarations
35589   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
35590 
35591   /* "dipy/align/sumsqdiff.pyx":62
35592  *     """
35593  *     cdef:
35594  *         cnp.ndarray out = np.zeros(2, dtype=float)             # <<<<<<<<<<<<<<
35595  *
35596  *     _solve_2d_symmetric_positive_definite(
35597  */
35598   __pyx_tuple_ = PyTuple_Pack(1, __pyx_int_2); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 62, __pyx_L1_error)
35599   __Pyx_GOTREF(__pyx_tuple_);
35600   __Pyx_GIVEREF(__pyx_tuple_);
35601 
35602   /* "dipy/align/sumsqdiff.pyx":150
35603  *     """
35604  *     cdef:
35605  *         cnp.ndarray out = np.zeros(3, dtype=float)             # <<<<<<<<<<<<<<
35606  *         int is_singular
35607  *     is_singular = _solve_3d_symmetric_positive_definite(
35608  */
35609   __pyx_tuple__2 = PyTuple_Pack(1, __pyx_int_3); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 150, __pyx_L1_error)
35610   __Pyx_GOTREF(__pyx_tuple__2);
35611   __Pyx_GIVEREF(__pyx_tuple__2);
35612 
35613   /* "dipy/align/sumsqdiff.pyx":163
35614  * @cython.wraparound(False)
35615  * @cython.cdivision(True)
35616  * cpdef double iterate_residual_displacement_field_ssd_2d(             # <<<<<<<<<<<<<<
35617  *                 floating[:, :] delta_field, floating[:, :] sigmasq_field,
35618  *                 floating[:, :, :] grad, floating[:, :, :] target,
35619  */
35620   __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_No_matching_signature_found); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 163, __pyx_L1_error)
35621   __Pyx_GOTREF(__pyx_tuple__5);
35622   __Pyx_GIVEREF(__pyx_tuple__5);
35623   __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Function_call_with_ambiguous_arg); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 163, __pyx_L1_error)
35624   __Pyx_GOTREF(__pyx_tuple__6);
35625   __Pyx_GIVEREF(__pyx_tuple__6);
35626 
35627   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":947
35628  *         __pyx_import_array()
35629  *     except Exception:
35630  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
35631  *
35632  * cdef inline int import_umath() except -1:
35633  */
35634   __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 947, __pyx_L1_error)
35635   __Pyx_GOTREF(__pyx_tuple__8);
35636   __Pyx_GIVEREF(__pyx_tuple__8);
35637 
35638   /* "../../miniconda3/envs/dipy-env-37/lib/python3.7/site-packages/numpy/__init__.pxd":953
35639  *         _import_umath()
35640  *     except Exception:
35641  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
35642  *
35643  * cdef inline int import_ufunc() except -1:
35644  */
35645   __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 953, __pyx_L1_error)
35646   __Pyx_GOTREF(__pyx_tuple__9);
35647   __Pyx_GIVEREF(__pyx_tuple__9);
35648 
35649   /* "View.MemoryView":133
35650  *
35651  *         if not self.ndim:
35652  *             raise ValueError("Empty shape tuple for cython.array")             # <<<<<<<<<<<<<<
35653  *
35654  *         if itemsize <= 0:
35655  */
35656   __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 133, __pyx_L1_error)
35657   __Pyx_GOTREF(__pyx_tuple__10);
35658   __Pyx_GIVEREF(__pyx_tuple__10);
35659 
35660   /* "View.MemoryView":136
35661  *
35662  *         if itemsize <= 0:
35663  *             raise ValueError("itemsize <= 0 for cython.array")             # <<<<<<<<<<<<<<
35664  *
35665  *         if not isinstance(format, bytes):
35666  */
35667   __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 136, __pyx_L1_error)
35668   __Pyx_GOTREF(__pyx_tuple__11);
35669   __Pyx_GIVEREF(__pyx_tuple__11);
35670 
35671   /* "View.MemoryView":148
35672  *
35673  *         if not self._shape:
35674  *             raise MemoryError("unable to allocate shape and strides.")             # <<<<<<<<<<<<<<
35675  *
35676  *
35677  */
35678   __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 148, __pyx_L1_error)
35679   __Pyx_GOTREF(__pyx_tuple__12);
35680   __Pyx_GIVEREF(__pyx_tuple__12);
35681 
35682   /* "View.MemoryView":176
35683  *             self.data = <char *>malloc(self.len)
35684  *             if not self.data:
35685  *                 raise MemoryError("unable to allocate array data.")             # <<<<<<<<<<<<<<
35686  *
35687  *             if self.dtype_is_object:
35688  */
35689   __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 176, __pyx_L1_error)
35690   __Pyx_GOTREF(__pyx_tuple__13);
35691   __Pyx_GIVEREF(__pyx_tuple__13);
35692 
35693   /* "View.MemoryView":192
35694  *             bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
35695  *         if not (flags & bufmode):
35696  *             raise ValueError("Can only create a buffer that is contiguous in memory.")             # <<<<<<<<<<<<<<
35697  *         info.buf = self.data
35698  *         info.len = self.len
35699  */
35700   __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 192, __pyx_L1_error)
35701   __Pyx_GOTREF(__pyx_tuple__14);
35702   __Pyx_GIVEREF(__pyx_tuple__14);
35703 
35704   /* "(tree fragment)":2
35705  * def __reduce_cython__(self):
35706  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
35707  * def __setstate_cython__(self, __pyx_state):
35708  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
35709  */
35710   __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)
35711   __Pyx_GOTREF(__pyx_tuple__15);
35712   __Pyx_GIVEREF(__pyx_tuple__15);
35713 
35714   /* "(tree fragment)":4
35715  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
35716  * def __setstate_cython__(self, __pyx_state):
35717  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
35718  */
35719   __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)
35720   __Pyx_GOTREF(__pyx_tuple__16);
35721   __Pyx_GIVEREF(__pyx_tuple__16);
35722 
35723   /* "View.MemoryView":418
35724  *     def __setitem__(memoryview self, object index, object value):
35725  *         if self.view.readonly:
35726  *             raise TypeError("Cannot assign to read-only memoryview")             # <<<<<<<<<<<<<<
35727  *
35728  *         have_slices, index = _unellipsify(index, self.view.ndim)
35729  */
35730   __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(2, 418, __pyx_L1_error)
35731   __Pyx_GOTREF(__pyx_tuple__17);
35732   __Pyx_GIVEREF(__pyx_tuple__17);
35733 
35734   /* "View.MemoryView":495
35735  *             result = struct.unpack(self.view.format, bytesitem)
35736  *         except struct.error:
35737  *             raise ValueError("Unable to convert item to object")             # <<<<<<<<<<<<<<
35738  *         else:
35739  *             if len(self.view.format) == 1:
35740  */
35741   __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(2, 495, __pyx_L1_error)
35742   __Pyx_GOTREF(__pyx_tuple__18);
35743   __Pyx_GIVEREF(__pyx_tuple__18);
35744 
35745   /* "View.MemoryView":520
35746  *     def __getbuffer__(self, Py_buffer *info, int flags):
35747  *         if flags & PyBUF_WRITABLE and self.view.readonly:
35748  *             raise ValueError("Cannot create writable memory view from read-only memoryview")             # <<<<<<<<<<<<<<
35749  *
35750  *         if flags & PyBUF_ND:
35751  */
35752   __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(2, 520, __pyx_L1_error)
35753   __Pyx_GOTREF(__pyx_tuple__19);
35754   __Pyx_GIVEREF(__pyx_tuple__19);
35755 
35756   /* "View.MemoryView":570
35757  *         if self.view.strides == NULL:
35758  *
35759  *             raise ValueError("Buffer view does not expose strides")             # <<<<<<<<<<<<<<
35760  *
35761  *         return tuple([stride for stride in self.view.strides[:self.view.ndim]])
35762  */
35763   __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(2, 570, __pyx_L1_error)
35764   __Pyx_GOTREF(__pyx_tuple__20);
35765   __Pyx_GIVEREF(__pyx_tuple__20);
35766 
35767   /* "View.MemoryView":577
35768  *     def suboffsets(self):
35769  *         if self.view.suboffsets == NULL:
35770  *             return (-1,) * self.view.ndim             # <<<<<<<<<<<<<<
35771  *
35772  *         return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
35773  */
35774   __pyx_tuple__21 = PyTuple_New(1); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(2, 577, __pyx_L1_error)
35775   __Pyx_GOTREF(__pyx_tuple__21);
35776   __Pyx_INCREF(__pyx_int_neg_1);
35777   __Pyx_GIVEREF(__pyx_int_neg_1);
35778   PyTuple_SET_ITEM(__pyx_tuple__21, 0, __pyx_int_neg_1);
35779   __Pyx_GIVEREF(__pyx_tuple__21);
35780 
35781   /* "(tree fragment)":2
35782  * def __reduce_cython__(self):
35783  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
35784  * def __setstate_cython__(self, __pyx_state):
35785  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
35786  */
35787   __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(2, 2, __pyx_L1_error)
35788   __Pyx_GOTREF(__pyx_tuple__22);
35789   __Pyx_GIVEREF(__pyx_tuple__22);
35790 
35791   /* "(tree fragment)":4
35792  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
35793  * def __setstate_cython__(self, __pyx_state):
35794  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
35795  */
35796   __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(2, 4, __pyx_L1_error)
35797   __Pyx_GOTREF(__pyx_tuple__23);
35798   __Pyx_GIVEREF(__pyx_tuple__23);
35799 
35800   /* "View.MemoryView":682
35801  *         if item is Ellipsis:
35802  *             if not seen_ellipsis:
35803  *                 result.extend([slice(None)] * (ndim - len(tup) + 1))             # <<<<<<<<<<<<<<
35804  *                 seen_ellipsis = True
35805  *             else:
35806  */
35807   __pyx_slice__24 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__24)) __PYX_ERR(2, 682, __pyx_L1_error)
35808   __Pyx_GOTREF(__pyx_slice__24);
35809   __Pyx_GIVEREF(__pyx_slice__24);
35810 
35811   /* "View.MemoryView":703
35812  *     for suboffset in suboffsets[:ndim]:
35813  *         if suboffset >= 0:
35814  *             raise ValueError("Indirect dimensions not supported")             # <<<<<<<<<<<<<<
35815  *
35816  *
35817  */
35818   __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(2, 703, __pyx_L1_error)
35819   __Pyx_GOTREF(__pyx_tuple__25);
35820   __Pyx_GIVEREF(__pyx_tuple__25);
35821 
35822   /* "(tree fragment)":2
35823  * def __reduce_cython__(self):
35824  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
35825  * def __setstate_cython__(self, __pyx_state):
35826  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
35827  */
35828   __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(2, 2, __pyx_L1_error)
35829   __Pyx_GOTREF(__pyx_tuple__26);
35830   __Pyx_GIVEREF(__pyx_tuple__26);
35831 
35832   /* "(tree fragment)":4
35833  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")
35834  * def __setstate_cython__(self, __pyx_state):
35835  *     raise TypeError("no default __reduce__ due to non-trivial __cinit__")             # <<<<<<<<<<<<<<
35836  */
35837   __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(2, 4, __pyx_L1_error)
35838   __Pyx_GOTREF(__pyx_tuple__27);
35839   __Pyx_GIVEREF(__pyx_tuple__27);
35840 
35841   /* "dipy/align/sumsqdiff.pyx":41
35842  *
35843  *
35844  * def solve_2d_symmetric_positive_definite(A, y, double det):             # <<<<<<<<<<<<<<
35845  *     r"""Solves a 2-variable symmetric positive-definite linear system
35846  *
35847  */
35848   __pyx_tuple__28 = PyTuple_Pack(4, __pyx_n_s_A, __pyx_n_s_y, __pyx_n_s_det, __pyx_n_s_out); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 41, __pyx_L1_error)
35849   __Pyx_GOTREF(__pyx_tuple__28);
35850   __Pyx_GIVEREF(__pyx_tuple__28);
35851   __pyx_codeobj__29 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_dipy_align_sumsqdiff_pyx, __pyx_n_s_solve_2d_symmetric_positive_defi, 41, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__29)) __PYX_ERR(0, 41, __pyx_L1_error)
35852 
35853   /* "dipy/align/sumsqdiff.pyx":127
35854  *
35855  *
35856  * def solve_3d_symmetric_positive_definite(g, y, double tau):             # <<<<<<<<<<<<<<
35857  *     r"""Solves a 3-variable symmetric positive-definite linear system
35858  *
35859  */
35860   __pyx_tuple__30 = PyTuple_Pack(5, __pyx_n_s_g, __pyx_n_s_y, __pyx_n_s_tau, __pyx_n_s_out, __pyx_n_s_is_singular); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 127, __pyx_L1_error)
35861   __Pyx_GOTREF(__pyx_tuple__30);
35862   __Pyx_GIVEREF(__pyx_tuple__30);
35863   __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_dipy_align_sumsqdiff_pyx, __pyx_n_s_solve_3d_symmetric_positive_defi, 127, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 127, __pyx_L1_error)
35864 
35865   /* "dipy/align/sumsqdiff.pyx":163
35866  * @cython.wraparound(False)
35867  * @cython.cdivision(True)
35868  * cpdef double iterate_residual_displacement_field_ssd_2d(             # <<<<<<<<<<<<<<
35869  *                 floating[:, :] delta_field, floating[:, :] sigmasq_field,
35870  *                 floating[:, :, :] grad, floating[:, :, :] target,
35871  */
35872   __pyx_tuple__32 = PyTuple_Pack(6, __pyx_n_s_delta_field, __pyx_n_s_sigmasq_field, __pyx_n_s_grad, __pyx_n_s_target, __pyx_n_s_lambda_param, __pyx_n_s_displacement_field); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 163, __pyx_L1_error)
35873   __Pyx_GOTREF(__pyx_tuple__32);
35874   __Pyx_GIVEREF(__pyx_tuple__32);
35875   __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(6, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_dipy_align_sumsqdiff_pyx, __pyx_n_s_pyx_fuse_0iterate_residual_dis, 163, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 163, __pyx_L1_error)
35876 
35877   /* "dipy/align/sumsqdiff.pyx":287
35878  * @cython.boundscheck(False)
35879  * @cython.wraparound(False)
35880  * cpdef double compute_energy_ssd_2d(floating[:, :] delta_field):             # <<<<<<<<<<<<<<
35881  *     r"""Sum of squared differences between two 2D images
35882  *
35883  */
35884   __pyx_tuple__34 = PyTuple_Pack(2, __pyx_n_s_delta_field, __pyx_n_s_delta_field); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 287, __pyx_L1_error)
35885   __Pyx_GOTREF(__pyx_tuple__34);
35886   __Pyx_GIVEREF(__pyx_tuple__34);
35887   __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_dipy_align_sumsqdiff_pyx, __pyx_n_s_pyx_fuse_0compute_energy_ssd_2, 287, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 287, __pyx_L1_error)
35888 
35889   /* "dipy/align/sumsqdiff.pyx":336
35890  * @cython.wraparound(False)
35891  * @cython.cdivision(True)
35892  * cpdef double iterate_residual_displacement_field_ssd_3d(             # <<<<<<<<<<<<<<
35893  *                 floating[:, :, :] delta_field, floating[:, :, :] sigmasq_field,
35894  *                 floating[:, :, :, :] grad, floating[:, :, :, :] target,
35895  */
35896   __pyx_tuple__36 = PyTuple_Pack(6, __pyx_n_s_delta_field, __pyx_n_s_sigmasq_field, __pyx_n_s_grad, __pyx_n_s_target, __pyx_n_s_lambda_param, __pyx_n_s_disp); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 336, __pyx_L1_error)
35897   __Pyx_GOTREF(__pyx_tuple__36);
35898   __Pyx_GIVEREF(__pyx_tuple__36);
35899   __pyx_codeobj__37 = (PyObject*)__Pyx_PyCode_New(6, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_dipy_align_sumsqdiff_pyx, __pyx_n_s_pyx_fuse_0iterate_residual_dis_2, 336, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__37)) __PYX_ERR(0, 336, __pyx_L1_error)
35900 
35901   /* "dipy/align/sumsqdiff.pyx":486
35902  * @cython.boundscheck(False)
35903  * @cython.wraparound(False)
35904  * cpdef double compute_energy_ssd_3d(floating[:, :, :] delta_field):             # <<<<<<<<<<<<<<
35905  *     r"""Sum of squared differences between two 3D volumes
35906  *
35907  */
35908   __pyx_tuple__38 = PyTuple_Pack(2, __pyx_n_s_delta_field, __pyx_n_s_delta_field); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 486, __pyx_L1_error)
35909   __Pyx_GOTREF(__pyx_tuple__38);
35910   __Pyx_GIVEREF(__pyx_tuple__38);
35911   __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_dipy_align_sumsqdiff_pyx, __pyx_n_s_pyx_fuse_0compute_energy_ssd_3, 486, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 486, __pyx_L1_error)
35912 
35913   /* "dipy/align/sumsqdiff.pyx":534
35914  * @cython.boundscheck(False)
35915  * @cython.wraparound(False)
35916  * def compute_residual_displacement_field_ssd_3d(             # <<<<<<<<<<<<<<
35917  *         floating[:, :, :] delta_field, floating[:, :, :] sigmasq_field,
35918  *         floating[:, :, :, :] gradient_field, floating[:, :, :, :] target,
35919  */
35920   __pyx_tuple__40 = PyTuple_Pack(27, __pyx_n_s_delta_field, __pyx_n_s_sigmasq_field, __pyx_n_s_gradient_field, __pyx_n_s_target, __pyx_n_s_lambda_param, __pyx_n_s_disp, __pyx_n_s_residual, __pyx_n_s_ftype, __pyx_n_s_NUM_NEIGHBORS, __pyx_n_s_dSlice, __pyx_n_s_dRow, __pyx_n_s_dCol, __pyx_n_s_b, __pyx_n_s_y, __pyx_n_s_nslices, __pyx_n_s_nrows, __pyx_n_s_ncols, __pyx_n_s_delta, __pyx_n_s_sigmasq, __pyx_n_s_dotP, __pyx_n_s_s, __pyx_n_s_r, __pyx_n_s_c, __pyx_n_s_ds, __pyx_n_s_dr, __pyx_n_s_dc, __pyx_n_s_k); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 534, __pyx_L1_error)
35921   __Pyx_GOTREF(__pyx_tuple__40);
35922   __Pyx_GIVEREF(__pyx_tuple__40);
35923   __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(7, 0, 27, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_dipy_align_sumsqdiff_pyx, __pyx_n_s_compute_residual_displacement_fi, 534, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 534, __pyx_L1_error)
35924 
35925   /* "dipy/align/sumsqdiff.pyx":649
35926  * @cython.boundscheck(False)
35927  * @cython.wraparound(False)
35928  * cpdef compute_residual_displacement_field_ssd_2d(             # <<<<<<<<<<<<<<
35929  *         floating[:, :] delta_field, floating[:, :] sigmasq_field,
35930  *         floating[:, :, :] gradient_field, floating[:, :, :] target,
35931  */
35932   __pyx_tuple__42 = PyTuple_Pack(7, __pyx_n_s_delta_field, __pyx_n_s_sigmasq_field, __pyx_n_s_gradient_field, __pyx_n_s_target, __pyx_n_s_lambda_param, __pyx_n_s_d, __pyx_n_s_residual); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 649, __pyx_L1_error)
35933   __Pyx_GOTREF(__pyx_tuple__42);
35934   __Pyx_GIVEREF(__pyx_tuple__42);
35935   __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(7, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_dipy_align_sumsqdiff_pyx, __pyx_n_s_pyx_fuse_0compute_residual_dis, 649, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 649, __pyx_L1_error)
35936 
35937   /* "dipy/align/sumsqdiff.pyx":752
35938  * @cython.wraparound(False)
35939  * @cython.cdivision(True)
35940  * def compute_ssd_demons_step_2d(floating[:,:] delta_field,             # <<<<<<<<<<<<<<
35941  *                                floating[:,:,:] gradient_moving,
35942  *                                double sigma_sq_x,
35943  */
35944   __pyx_tuple__44 = PyTuple_Pack(13, __pyx_n_s_delta_field, __pyx_n_s_gradient_moving, __pyx_n_s_sigma_sq_x, __pyx_n_s_out, __pyx_n_s_nr, __pyx_n_s_nc, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_delta, __pyx_n_s_delta_2, __pyx_n_s_nrm2, __pyx_n_s_energy, __pyx_n_s_den); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 752, __pyx_L1_error)
35945   __Pyx_GOTREF(__pyx_tuple__44);
35946   __Pyx_GIVEREF(__pyx_tuple__44);
35947   __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(4, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_dipy_align_sumsqdiff_pyx, __pyx_n_s_compute_ssd_demons_step_2d, 752, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 752, __pyx_L1_error)
35948 
35949   /* "dipy/align/sumsqdiff.pyx":826
35950  * @cython.wraparound(False)
35951  * @cython.cdivision(True)
35952  * def compute_ssd_demons_step_3d(floating[:,:,:] delta_field,             # <<<<<<<<<<<<<<
35953  *                                floating[:,:,:,:] gradient_moving,
35954  *                                double sigma_sq_x,
35955  */
35956   __pyx_tuple__46 = PyTuple_Pack(15, __pyx_n_s_delta_field, __pyx_n_s_gradient_moving, __pyx_n_s_sigma_sq_x, __pyx_n_s_out, __pyx_n_s_ns, __pyx_n_s_nr, __pyx_n_s_nc, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_k, __pyx_n_s_delta, __pyx_n_s_delta_2, __pyx_n_s_nrm2, __pyx_n_s_energy, __pyx_n_s_den); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 826, __pyx_L1_error)
35957   __Pyx_GOTREF(__pyx_tuple__46);
35958   __Pyx_GIVEREF(__pyx_tuple__46);
35959   __pyx_codeobj__47 = (PyObject*)__Pyx_PyCode_New(4, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_dipy_align_sumsqdiff_pyx, __pyx_n_s_compute_ssd_demons_step_3d, 826, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) __PYX_ERR(0, 826, __pyx_L1_error)
35960 
35961   /* "View.MemoryView":286
35962  *         return self.name
35963  *
35964  * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
35965  * cdef strided = Enum("<strided and direct>") # default
35966  * cdef indirect = Enum("<strided and indirect>")
35967  */
35968   __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(2, 286, __pyx_L1_error)
35969   __Pyx_GOTREF(__pyx_tuple__48);
35970   __Pyx_GIVEREF(__pyx_tuple__48);
35971 
35972   /* "View.MemoryView":287
35973  *
35974  * cdef generic = Enum("<strided and direct or indirect>")
35975  * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
35976  * cdef indirect = Enum("<strided and indirect>")
35977  *
35978  */
35979   __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(2, 287, __pyx_L1_error)
35980   __Pyx_GOTREF(__pyx_tuple__49);
35981   __Pyx_GIVEREF(__pyx_tuple__49);
35982 
35983   /* "View.MemoryView":288
35984  * cdef generic = Enum("<strided and direct or indirect>")
35985  * cdef strided = Enum("<strided and direct>") # default
35986  * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
35987  *
35988  *
35989  */
35990   __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(2, 288, __pyx_L1_error)
35991   __Pyx_GOTREF(__pyx_tuple__50);
35992   __Pyx_GIVEREF(__pyx_tuple__50);
35993 
35994   /* "View.MemoryView":291
35995  *
35996  *
35997  * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
35998  * cdef indirect_contiguous = Enum("<contiguous and indirect>")
35999  *
36000  */
36001   __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(2, 291, __pyx_L1_error)
36002   __Pyx_GOTREF(__pyx_tuple__51);
36003   __Pyx_GIVEREF(__pyx_tuple__51);
36004 
36005   /* "View.MemoryView":292
36006  *
36007  * cdef contiguous = Enum("<contiguous and direct>")
36008  * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
36009  *
36010  *
36011  */
36012   __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(2, 292, __pyx_L1_error)
36013   __Pyx_GOTREF(__pyx_tuple__52);
36014   __Pyx_GIVEREF(__pyx_tuple__52);
36015 
36016   /* "(tree fragment)":1
36017  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
36018  *     cdef object __pyx_PickleError
36019  *     cdef object __pyx_result
36020  */
36021   __pyx_tuple__53 = 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__53)) __PYX_ERR(2, 1, __pyx_L1_error)
36022   __Pyx_GOTREF(__pyx_tuple__53);
36023   __Pyx_GIVEREF(__pyx_tuple__53);
36024   __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(2, 1, __pyx_L1_error)
36025   __Pyx_RefNannyFinishContext();
36026   return 0;
36027   __pyx_L1_error:;
36028   __Pyx_RefNannyFinishContext();
36029   return -1;
36030 }
36031 
__Pyx_InitGlobals(void)36032 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
36033   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
36034   __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
36035   __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
36036   __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
36037   __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
36038   __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
36039   __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) __PYX_ERR(0, 1, __pyx_L1_error)
36040   __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) __PYX_ERR(0, 1, __pyx_L1_error)
36041   __pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(0, 1, __pyx_L1_error)
36042   __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
36043   return 0;
36044   __pyx_L1_error:;
36045   return -1;
36046 }
36047 
36048 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
36049 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
36050 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
36051 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
36052 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
36053 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
36054 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
36055 
__Pyx_modinit_global_init_code(void)36056 static int __Pyx_modinit_global_init_code(void) {
36057   __Pyx_RefNannyDeclarations
36058   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
36059   /*--- Global init code ---*/
36060   generic = Py_None; Py_INCREF(Py_None);
36061   strided = Py_None; Py_INCREF(Py_None);
36062   indirect = Py_None; Py_INCREF(Py_None);
36063   contiguous = Py_None; Py_INCREF(Py_None);
36064   indirect_contiguous = Py_None; Py_INCREF(Py_None);
36065   __Pyx_RefNannyFinishContext();
36066   return 0;
36067 }
36068 
__Pyx_modinit_variable_export_code(void)36069 static int __Pyx_modinit_variable_export_code(void) {
36070   __Pyx_RefNannyDeclarations
36071   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
36072   /*--- Variable export code ---*/
36073   __Pyx_RefNannyFinishContext();
36074   return 0;
36075 }
36076 
__Pyx_modinit_function_export_code(void)36077 static int __Pyx_modinit_function_export_code(void) {
36078   __Pyx_RefNannyDeclarations
36079   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
36080   /*--- Function export code ---*/
36081   __Pyx_RefNannyFinishContext();
36082   return 0;
36083 }
36084 
__Pyx_modinit_type_init_code(void)36085 static int __Pyx_modinit_type_init_code(void) {
36086   __Pyx_RefNannyDeclarations
36087   int __pyx_lineno = 0;
36088   const char *__pyx_filename = NULL;
36089   int __pyx_clineno = 0;
36090   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
36091   /*--- Type init code ---*/
36092   __pyx_vtabptr_array = &__pyx_vtable_array;
36093   __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview;
36094   if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(2, 105, __pyx_L1_error)
36095   #if PY_VERSION_HEX < 0x030800B1
36096   __pyx_type___pyx_array.tp_print = 0;
36097   #endif
36098   if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(2, 105, __pyx_L1_error)
36099   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(2, 105, __pyx_L1_error)
36100   __pyx_array_type = &__pyx_type___pyx_array;
36101   if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(2, 279, __pyx_L1_error)
36102   #if PY_VERSION_HEX < 0x030800B1
36103   __pyx_type___pyx_MemviewEnum.tp_print = 0;
36104   #endif
36105   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_MemviewEnum.tp_dictoffset && __pyx_type___pyx_MemviewEnum.tp_getattro == PyObject_GenericGetAttr)) {
36106     __pyx_type___pyx_MemviewEnum.tp_getattro = __Pyx_PyObject_GenericGetAttr;
36107   }
36108   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(2, 279, __pyx_L1_error)
36109   __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum;
36110   __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview;
36111   __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer;
36112   __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice;
36113   __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment;
36114   __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar;
36115   __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed;
36116   __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object;
36117   __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object;
36118   if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(2, 330, __pyx_L1_error)
36119   #if PY_VERSION_HEX < 0x030800B1
36120   __pyx_type___pyx_memoryview.tp_print = 0;
36121   #endif
36122   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryview.tp_dictoffset && __pyx_type___pyx_memoryview.tp_getattro == PyObject_GenericGetAttr)) {
36123     __pyx_type___pyx_memoryview.tp_getattro = __Pyx_PyObject_GenericGetAttr;
36124   }
36125   if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(2, 330, __pyx_L1_error)
36126   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(2, 330, __pyx_L1_error)
36127   __pyx_memoryview_type = &__pyx_type___pyx_memoryview;
36128   __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice;
36129   __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview;
36130   __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object;
36131   __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object;
36132   __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type;
36133   if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(2, 965, __pyx_L1_error)
36134   #if PY_VERSION_HEX < 0x030800B1
36135   __pyx_type___pyx_memoryviewslice.tp_print = 0;
36136   #endif
36137   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryviewslice.tp_dictoffset && __pyx_type___pyx_memoryviewslice.tp_getattro == PyObject_GenericGetAttr)) {
36138     __pyx_type___pyx_memoryviewslice.tp_getattro = __Pyx_PyObject_GenericGetAttr;
36139   }
36140   if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(2, 965, __pyx_L1_error)
36141   if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(2, 965, __pyx_L1_error)
36142   __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
36143   __Pyx_RefNannyFinishContext();
36144   return 0;
36145   __pyx_L1_error:;
36146   __Pyx_RefNannyFinishContext();
36147   return -1;
36148 }
36149 
__Pyx_modinit_type_import_code(void)36150 static int __Pyx_modinit_type_import_code(void) {
36151   __Pyx_RefNannyDeclarations
36152   PyObject *__pyx_t_1 = NULL;
36153   int __pyx_lineno = 0;
36154   const char *__pyx_filename = NULL;
36155   int __pyx_clineno = 0;
36156   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
36157   /*--- Type import code ---*/
36158   __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error)
36159   __Pyx_GOTREF(__pyx_t_1);
36160   __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
36161   #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
36162   sizeof(PyTypeObject),
36163   #else
36164   sizeof(PyHeapTypeObject),
36165   #endif
36166   __Pyx_ImportType_CheckSize_Warn);
36167    if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error)
36168   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36169   __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 200, __pyx_L1_error)
36170   __Pyx_GOTREF(__pyx_t_1);
36171   __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
36172    if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(1, 200, __pyx_L1_error)
36173   __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore);
36174    if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(1, 223, __pyx_L1_error)
36175   __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore);
36176    if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(1, 227, __pyx_L1_error)
36177   __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
36178    if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(1, 239, __pyx_L1_error)
36179   __pyx_ptype_5numpy_generic = __Pyx_ImportType(__pyx_t_1, "numpy", "generic", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
36180    if (!__pyx_ptype_5numpy_generic) __PYX_ERR(1, 771, __pyx_L1_error)
36181   __pyx_ptype_5numpy_number = __Pyx_ImportType(__pyx_t_1, "numpy", "number", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
36182    if (!__pyx_ptype_5numpy_number) __PYX_ERR(1, 773, __pyx_L1_error)
36183   __pyx_ptype_5numpy_integer = __Pyx_ImportType(__pyx_t_1, "numpy", "integer", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
36184    if (!__pyx_ptype_5numpy_integer) __PYX_ERR(1, 775, __pyx_L1_error)
36185   __pyx_ptype_5numpy_signedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "signedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
36186    if (!__pyx_ptype_5numpy_signedinteger) __PYX_ERR(1, 777, __pyx_L1_error)
36187   __pyx_ptype_5numpy_unsignedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "unsignedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
36188    if (!__pyx_ptype_5numpy_unsignedinteger) __PYX_ERR(1, 779, __pyx_L1_error)
36189   __pyx_ptype_5numpy_inexact = __Pyx_ImportType(__pyx_t_1, "numpy", "inexact", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
36190    if (!__pyx_ptype_5numpy_inexact) __PYX_ERR(1, 781, __pyx_L1_error)
36191   __pyx_ptype_5numpy_floating = __Pyx_ImportType(__pyx_t_1, "numpy", "floating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
36192    if (!__pyx_ptype_5numpy_floating) __PYX_ERR(1, 783, __pyx_L1_error)
36193   __pyx_ptype_5numpy_complexfloating = __Pyx_ImportType(__pyx_t_1, "numpy", "complexfloating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
36194    if (!__pyx_ptype_5numpy_complexfloating) __PYX_ERR(1, 785, __pyx_L1_error)
36195   __pyx_ptype_5numpy_flexible = __Pyx_ImportType(__pyx_t_1, "numpy", "flexible", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
36196    if (!__pyx_ptype_5numpy_flexible) __PYX_ERR(1, 787, __pyx_L1_error)
36197   __pyx_ptype_5numpy_character = __Pyx_ImportType(__pyx_t_1, "numpy", "character", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
36198    if (!__pyx_ptype_5numpy_character) __PYX_ERR(1, 789, __pyx_L1_error)
36199   __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore);
36200    if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(1, 827, __pyx_L1_error)
36201   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36202   __Pyx_RefNannyFinishContext();
36203   return 0;
36204   __pyx_L1_error:;
36205   __Pyx_XDECREF(__pyx_t_1);
36206   __Pyx_RefNannyFinishContext();
36207   return -1;
36208 }
36209 
__Pyx_modinit_variable_import_code(void)36210 static int __Pyx_modinit_variable_import_code(void) {
36211   __Pyx_RefNannyDeclarations
36212   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
36213   /*--- Variable import code ---*/
36214   __Pyx_RefNannyFinishContext();
36215   return 0;
36216 }
36217 
__Pyx_modinit_function_import_code(void)36218 static int __Pyx_modinit_function_import_code(void) {
36219   __Pyx_RefNannyDeclarations
36220   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
36221   /*--- Function import code ---*/
36222   __Pyx_RefNannyFinishContext();
36223   return 0;
36224 }
36225 
36226 
36227 #ifndef CYTHON_NO_PYINIT_EXPORT
36228 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
36229 #elif PY_MAJOR_VERSION < 3
36230 #ifdef __cplusplus
36231 #define __Pyx_PyMODINIT_FUNC extern "C" void
36232 #else
36233 #define __Pyx_PyMODINIT_FUNC void
36234 #endif
36235 #else
36236 #ifdef __cplusplus
36237 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
36238 #else
36239 #define __Pyx_PyMODINIT_FUNC PyObject *
36240 #endif
36241 #endif
36242 
36243 
36244 #if PY_MAJOR_VERSION < 3
36245 __Pyx_PyMODINIT_FUNC initsumsqdiff(void) CYTHON_SMALL_CODE; /*proto*/
initsumsqdiff(void)36246 __Pyx_PyMODINIT_FUNC initsumsqdiff(void)
36247 #else
36248 __Pyx_PyMODINIT_FUNC PyInit_sumsqdiff(void) CYTHON_SMALL_CODE; /*proto*/
36249 __Pyx_PyMODINIT_FUNC PyInit_sumsqdiff(void)
36250 #if CYTHON_PEP489_MULTI_PHASE_INIT
36251 {
36252   return PyModuleDef_Init(&__pyx_moduledef);
36253 }
36254 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
36255     #if PY_VERSION_HEX >= 0x030700A1
36256     static PY_INT64_T main_interpreter_id = -1;
36257     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
36258     if (main_interpreter_id == -1) {
36259         main_interpreter_id = current_id;
36260         return (unlikely(current_id == -1)) ? -1 : 0;
36261     } else if (unlikely(main_interpreter_id != current_id))
36262     #else
36263     static PyInterpreterState *main_interpreter = NULL;
36264     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
36265     if (!main_interpreter) {
36266         main_interpreter = current_interpreter;
36267     } else if (unlikely(main_interpreter != current_interpreter))
36268     #endif
36269     {
36270         PyErr_SetString(
36271             PyExc_ImportError,
36272             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
36273         return -1;
36274     }
36275     return 0;
36276 }
36277 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) {
36278     PyObject *value = PyObject_GetAttrString(spec, from_name);
36279     int result = 0;
36280     if (likely(value)) {
36281         if (allow_none || value != Py_None) {
36282             result = PyDict_SetItemString(moddict, to_name, value);
36283         }
36284         Py_DECREF(value);
36285     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
36286         PyErr_Clear();
36287     } else {
36288         result = -1;
36289     }
36290     return result;
36291 }
36292 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
36293     PyObject *module = NULL, *moddict, *modname;
36294     if (__Pyx_check_single_interpreter())
36295         return NULL;
36296     if (__pyx_m)
36297         return __Pyx_NewRef(__pyx_m);
36298     modname = PyObject_GetAttrString(spec, "name");
36299     if (unlikely(!modname)) goto bad;
36300     module = PyModule_NewObject(modname);
36301     Py_DECREF(modname);
36302     if (unlikely(!module)) goto bad;
36303     moddict = PyModule_GetDict(module);
36304     if (unlikely(!moddict)) goto bad;
36305     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
36306     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
36307     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
36308     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
36309     return module;
36310 bad:
36311     Py_XDECREF(module);
36312     return NULL;
36313 }
36314 
36315 
36316 static CYTHON_SMALL_CODE int __pyx_pymod_exec_sumsqdiff(PyObject *__pyx_pyinit_module)
36317 #endif
36318 #endif
36319 {
36320   PyObject *__pyx_t_1 = NULL;
36321   PyObject *__pyx_t_2 = NULL;
36322   static PyThread_type_lock __pyx_t_3[8];
36323   int __pyx_lineno = 0;
36324   const char *__pyx_filename = NULL;
36325   int __pyx_clineno = 0;
36326   __Pyx_RefNannyDeclarations
36327   #if CYTHON_PEP489_MULTI_PHASE_INIT
36328   if (__pyx_m) {
36329     if (__pyx_m == __pyx_pyinit_module) return 0;
36330     PyErr_SetString(PyExc_RuntimeError, "Module 'sumsqdiff' has already been imported. Re-initialisation is not supported.");
36331     return -1;
36332   }
36333   #elif PY_MAJOR_VERSION >= 3
36334   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
36335   #endif
36336   #if CYTHON_REFNANNY
36337 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
36338 if (!__Pyx_RefNanny) {
36339   PyErr_Clear();
36340   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
36341   if (!__Pyx_RefNanny)
36342       Py_FatalError("failed to import 'refnanny' module");
36343 }
36344 #endif
36345   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_sumsqdiff(void)", 0);
36346   if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36347   #ifdef __Pxy_PyFrame_Initialize_Offsets
36348   __Pxy_PyFrame_Initialize_Offsets();
36349   #endif
36350   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
36351   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
36352   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
36353   #ifdef __Pyx_CyFunction_USED
36354   if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36355   #endif
36356   #ifdef __Pyx_FusedFunction_USED
36357   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36358   #endif
36359   #ifdef __Pyx_Coroutine_USED
36360   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36361   #endif
36362   #ifdef __Pyx_Generator_USED
36363   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36364   #endif
36365   #ifdef __Pyx_AsyncGen_USED
36366   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36367   #endif
36368   #ifdef __Pyx_StopAsyncIteration_USED
36369   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36370   #endif
36371   /*--- Library function declarations ---*/
36372   /*--- Threads initialization code ---*/
36373   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
36374   #ifdef WITH_THREAD /* Python build with threading support? */
36375   PyEval_InitThreads();
36376   #endif
36377   #endif
36378   /*--- Module creation code ---*/
36379   #if CYTHON_PEP489_MULTI_PHASE_INIT
36380   __pyx_m = __pyx_pyinit_module;
36381   Py_INCREF(__pyx_m);
36382   #else
36383   #if PY_MAJOR_VERSION < 3
36384   __pyx_m = Py_InitModule4("sumsqdiff", __pyx_methods, __pyx_k_Utility_functions_used_by_the_S, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
36385   #else
36386   __pyx_m = PyModule_Create(&__pyx_moduledef);
36387   #endif
36388   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
36389   #endif
36390   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
36391   Py_INCREF(__pyx_d);
36392   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
36393   Py_INCREF(__pyx_b);
36394   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
36395   Py_INCREF(__pyx_cython_runtime);
36396   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
36397   /*--- Initialize various global constants etc. ---*/
36398   if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36399   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
36400   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36401   #endif
36402   if (__pyx_module_is_main_dipy__align__sumsqdiff) {
36403     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36404   }
36405   #if PY_MAJOR_VERSION >= 3
36406   {
36407     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
36408     if (!PyDict_GetItemString(modules, "dipy.align.sumsqdiff")) {
36409       if (unlikely(PyDict_SetItemString(modules, "dipy.align.sumsqdiff", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
36410     }
36411   }
36412   #endif
36413   /*--- Builtin init code ---*/
36414   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36415   /*--- Constants init code ---*/
36416   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36417   /*--- Global type/function init code ---*/
36418   (void)__Pyx_modinit_global_init_code();
36419   (void)__Pyx_modinit_variable_export_code();
36420   (void)__Pyx_modinit_function_export_code();
36421   if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
36422   if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
36423   (void)__Pyx_modinit_variable_import_code();
36424   (void)__Pyx_modinit_function_import_code();
36425   /*--- Execution code ---*/
36426   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
36427   if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36428   #endif
36429 
36430   /* "dipy/align/sumsqdiff.pyx":3
36431  * """ Utility functions used by the Sum of Squared Differences (SSD) metric """
36432  *
36433  * import numpy as np             # <<<<<<<<<<<<<<
36434  * cimport cython
36435  * cimport numpy as cnp
36436  */
36437   __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
36438   __Pyx_GOTREF(__pyx_t_1);
36439   if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
36440   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36441 
36442   /* "dipy/align/sumsqdiff.pyx":41
36443  *
36444  *
36445  * def solve_2d_symmetric_positive_definite(A, y, double det):             # <<<<<<<<<<<<<<
36446  *     r"""Solves a 2-variable symmetric positive-definite linear system
36447  *
36448  */
36449   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4dipy_5align_9sumsqdiff_1solve_2d_symmetric_positive_definite, NULL, __pyx_n_s_dipy_align_sumsqdiff); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 41, __pyx_L1_error)
36450   __Pyx_GOTREF(__pyx_t_1);
36451   if (PyDict_SetItem(__pyx_d, __pyx_n_s_solve_2d_symmetric_positive_defi, __pyx_t_1) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
36452   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36453 
36454   /* "dipy/align/sumsqdiff.pyx":127
36455  *
36456  *
36457  * def solve_3d_symmetric_positive_definite(g, y, double tau):             # <<<<<<<<<<<<<<
36458  *     r"""Solves a 3-variable symmetric positive-definite linear system
36459  *
36460  */
36461   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4dipy_5align_9sumsqdiff_3solve_3d_symmetric_positive_definite, NULL, __pyx_n_s_dipy_align_sumsqdiff); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error)
36462   __Pyx_GOTREF(__pyx_t_1);
36463   if (PyDict_SetItem(__pyx_d, __pyx_n_s_solve_3d_symmetric_positive_defi, __pyx_t_1) < 0) __PYX_ERR(0, 127, __pyx_L1_error)
36464   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36465 
36466   /* "dipy/align/sumsqdiff.pyx":163
36467  * @cython.wraparound(False)
36468  * @cython.cdivision(True)
36469  * cpdef double iterate_residual_displacement_field_ssd_2d(             # <<<<<<<<<<<<<<
36470  *                 floating[:, :] delta_field, floating[:, :] sigmasq_field,
36471  *                 floating[:, :, :] grad, floating[:, :, :] target,
36472  */
36473   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
36474   __Pyx_GOTREF(__pyx_t_1);
36475   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_21__pyx_fuse_0iterate_residual_displacement_field_ssd_2d, 0, __pyx_n_s_pyx_fuse_0iterate_residual_dis, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error)
36476   __Pyx_GOTREF(__pyx_t_2);
36477   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36478   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_float, __pyx_t_2) < 0) __PYX_ERR(0, 163, __pyx_L1_error)
36479   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36480   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_23__pyx_fuse_1iterate_residual_displacement_field_ssd_2d, 0, __pyx_n_s_pyx_fuse_1iterate_residual_dis, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error)
36481   __Pyx_GOTREF(__pyx_t_2);
36482   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36483   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_double, __pyx_t_2) < 0) __PYX_ERR(0, 163, __pyx_L1_error)
36484   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36485   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_mdef_4dipy_5align_9sumsqdiff_5iterate_residual_displacement_field_ssd_2d, 0, __pyx_n_s_iterate_residual_displacement_fi, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error)
36486   __Pyx_GOTREF(__pyx_t_2);
36487   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36488   ((__pyx_FusedFunctionObject *) __pyx_t_2)->__signatures__ = __pyx_t_1;
36489   __Pyx_GIVEREF(__pyx_t_1);
36490   __pyx_t_1 = 0;
36491   if (PyDict_SetItem(__pyx_d, __pyx_n_s_iterate_residual_displacement_fi, __pyx_t_2) < 0) __PYX_ERR(0, 163, __pyx_L1_error)
36492   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36493 
36494   /* "dipy/align/sumsqdiff.pyx":287
36495  * @cython.boundscheck(False)
36496  * @cython.wraparound(False)
36497  * cpdef double compute_energy_ssd_2d(floating[:, :] delta_field):             # <<<<<<<<<<<<<<
36498  *     r"""Sum of squared differences between two 2D images
36499  *
36500  */
36501   __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error)
36502   __Pyx_GOTREF(__pyx_t_2);
36503   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_27__pyx_fuse_0compute_energy_ssd_2d, 0, __pyx_n_s_pyx_fuse_0compute_energy_ssd_2, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__35)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
36504   __Pyx_GOTREF(__pyx_t_1);
36505   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36506   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_float, __pyx_t_1) < 0) __PYX_ERR(0, 287, __pyx_L1_error)
36507   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36508   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_29__pyx_fuse_1compute_energy_ssd_2d, 0, __pyx_n_s_pyx_fuse_1compute_energy_ssd_2, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__35)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
36509   __Pyx_GOTREF(__pyx_t_1);
36510   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36511   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_double, __pyx_t_1) < 0) __PYX_ERR(0, 287, __pyx_L1_error)
36512   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36513   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_mdef_4dipy_5align_9sumsqdiff_7compute_energy_ssd_2d, 0, __pyx_n_s_compute_energy_ssd_2d, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__35)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
36514   __Pyx_GOTREF(__pyx_t_1);
36515   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36516   ((__pyx_FusedFunctionObject *) __pyx_t_1)->__signatures__ = __pyx_t_2;
36517   __Pyx_GIVEREF(__pyx_t_2);
36518   __pyx_t_2 = 0;
36519   if (PyDict_SetItem(__pyx_d, __pyx_n_s_compute_energy_ssd_2d, __pyx_t_1) < 0) __PYX_ERR(0, 287, __pyx_L1_error)
36520   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36521 
36522   /* "dipy/align/sumsqdiff.pyx":336
36523  * @cython.wraparound(False)
36524  * @cython.cdivision(True)
36525  * cpdef double iterate_residual_displacement_field_ssd_3d(             # <<<<<<<<<<<<<<
36526  *                 floating[:, :, :] delta_field, floating[:, :, :] sigmasq_field,
36527  *                 floating[:, :, :, :] grad, floating[:, :, :, :] target,
36528  */
36529   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 336, __pyx_L1_error)
36530   __Pyx_GOTREF(__pyx_t_1);
36531   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_33__pyx_fuse_0iterate_residual_displacement_field_ssd_3d, 0, __pyx_n_s_pyx_fuse_0iterate_residual_dis_2, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__37)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 336, __pyx_L1_error)
36532   __Pyx_GOTREF(__pyx_t_2);
36533   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36534   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_float, __pyx_t_2) < 0) __PYX_ERR(0, 336, __pyx_L1_error)
36535   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36536   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_35__pyx_fuse_1iterate_residual_displacement_field_ssd_3d, 0, __pyx_n_s_pyx_fuse_1iterate_residual_dis_2, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__37)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 336, __pyx_L1_error)
36537   __Pyx_GOTREF(__pyx_t_2);
36538   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36539   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_double, __pyx_t_2) < 0) __PYX_ERR(0, 336, __pyx_L1_error)
36540   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36541   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_mdef_4dipy_5align_9sumsqdiff_9iterate_residual_displacement_field_ssd_3d, 0, __pyx_n_s_iterate_residual_displacement_fi_2, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__37)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 336, __pyx_L1_error)
36542   __Pyx_GOTREF(__pyx_t_2);
36543   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36544   ((__pyx_FusedFunctionObject *) __pyx_t_2)->__signatures__ = __pyx_t_1;
36545   __Pyx_GIVEREF(__pyx_t_1);
36546   __pyx_t_1 = 0;
36547   if (PyDict_SetItem(__pyx_d, __pyx_n_s_iterate_residual_displacement_fi_2, __pyx_t_2) < 0) __PYX_ERR(0, 336, __pyx_L1_error)
36548   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36549 
36550   /* "dipy/align/sumsqdiff.pyx":486
36551  * @cython.boundscheck(False)
36552  * @cython.wraparound(False)
36553  * cpdef double compute_energy_ssd_3d(floating[:, :, :] delta_field):             # <<<<<<<<<<<<<<
36554  *     r"""Sum of squared differences between two 3D volumes
36555  *
36556  */
36557   __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 486, __pyx_L1_error)
36558   __Pyx_GOTREF(__pyx_t_2);
36559   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_39__pyx_fuse_0compute_energy_ssd_3d, 0, __pyx_n_s_pyx_fuse_0compute_energy_ssd_3, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
36560   __Pyx_GOTREF(__pyx_t_1);
36561   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36562   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_float, __pyx_t_1) < 0) __PYX_ERR(0, 486, __pyx_L1_error)
36563   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36564   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_41__pyx_fuse_1compute_energy_ssd_3d, 0, __pyx_n_s_pyx_fuse_1compute_energy_ssd_3, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
36565   __Pyx_GOTREF(__pyx_t_1);
36566   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36567   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_double, __pyx_t_1) < 0) __PYX_ERR(0, 486, __pyx_L1_error)
36568   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36569   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_mdef_4dipy_5align_9sumsqdiff_11compute_energy_ssd_3d, 0, __pyx_n_s_compute_energy_ssd_3d, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 486, __pyx_L1_error)
36570   __Pyx_GOTREF(__pyx_t_1);
36571   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36572   ((__pyx_FusedFunctionObject *) __pyx_t_1)->__signatures__ = __pyx_t_2;
36573   __Pyx_GIVEREF(__pyx_t_2);
36574   __pyx_t_2 = 0;
36575   if (PyDict_SetItem(__pyx_d, __pyx_n_s_compute_energy_ssd_3d, __pyx_t_1) < 0) __PYX_ERR(0, 486, __pyx_L1_error)
36576   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36577 
36578   /* "dipy/align/sumsqdiff.pyx":534
36579  * @cython.boundscheck(False)
36580  * @cython.wraparound(False)
36581  * def compute_residual_displacement_field_ssd_3d(             # <<<<<<<<<<<<<<
36582  *         floating[:, :, :] delta_field, floating[:, :, :] sigmasq_field,
36583  *         floating[:, :, :, :] gradient_field, floating[:, :, :, :] target,
36584  */
36585   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
36586   __Pyx_GOTREF(__pyx_t_1);
36587   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_45compute_residual_displacement_field_ssd_3d, 0, __pyx_n_s_compute_residual_displacement_fi, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__41)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 534, __pyx_L1_error)
36588   __Pyx_GOTREF(__pyx_t_2);
36589   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36590   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_float, __pyx_t_2) < 0) __PYX_ERR(0, 534, __pyx_L1_error)
36591   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36592   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_47compute_residual_displacement_field_ssd_3d, 0, __pyx_n_s_compute_residual_displacement_fi, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__41)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 534, __pyx_L1_error)
36593   __Pyx_GOTREF(__pyx_t_2);
36594   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36595   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_double, __pyx_t_2) < 0) __PYX_ERR(0, 534, __pyx_L1_error)
36596   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36597   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_mdef_4dipy_5align_9sumsqdiff_13compute_residual_displacement_field_ssd_3d, 0, __pyx_n_s_compute_residual_displacement_fi, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__41)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 534, __pyx_L1_error)
36598   __Pyx_GOTREF(__pyx_t_2);
36599   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36600   ((__pyx_FusedFunctionObject *) __pyx_t_2)->__signatures__ = __pyx_t_1;
36601   __Pyx_GIVEREF(__pyx_t_1);
36602   __pyx_t_1 = 0;
36603   if (PyDict_SetItem(__pyx_d, __pyx_n_s_compute_residual_displacement_fi, __pyx_t_2) < 0) __PYX_ERR(0, 534, __pyx_L1_error)
36604   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36605 
36606   /* "dipy/align/sumsqdiff.pyx":649
36607  * @cython.boundscheck(False)
36608  * @cython.wraparound(False)
36609  * cpdef compute_residual_displacement_field_ssd_2d(             # <<<<<<<<<<<<<<
36610  *         floating[:, :] delta_field, floating[:, :] sigmasq_field,
36611  *         floating[:, :, :] gradient_field, floating[:, :, :] target,
36612  */
36613   __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error)
36614   __Pyx_GOTREF(__pyx_t_2);
36615   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_51__pyx_fuse_0compute_residual_displacement_field_ssd_2d, 0, __pyx_n_s_pyx_fuse_0compute_residual_dis, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__43)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
36616   __Pyx_GOTREF(__pyx_t_1);
36617   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36618   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_float, __pyx_t_1) < 0) __PYX_ERR(0, 649, __pyx_L1_error)
36619   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36620   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_53__pyx_fuse_1compute_residual_displacement_field_ssd_2d, 0, __pyx_n_s_pyx_fuse_1compute_residual_dis, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__43)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
36621   __Pyx_GOTREF(__pyx_t_1);
36622   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36623   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_double, __pyx_t_1) < 0) __PYX_ERR(0, 649, __pyx_L1_error)
36624   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36625   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_mdef_4dipy_5align_9sumsqdiff_15compute_residual_displacement_field_ssd_2d, 0, __pyx_n_s_compute_residual_displacement_fi_2, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__43)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error)
36626   __Pyx_GOTREF(__pyx_t_1);
36627   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36628   ((__pyx_FusedFunctionObject *) __pyx_t_1)->__signatures__ = __pyx_t_2;
36629   __Pyx_GIVEREF(__pyx_t_2);
36630   __pyx_t_2 = 0;
36631   if (PyDict_SetItem(__pyx_d, __pyx_n_s_compute_residual_displacement_fi_2, __pyx_t_1) < 0) __PYX_ERR(0, 649, __pyx_L1_error)
36632   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36633 
36634   /* "dipy/align/sumsqdiff.pyx":752
36635  * @cython.wraparound(False)
36636  * @cython.cdivision(True)
36637  * def compute_ssd_demons_step_2d(floating[:,:] delta_field,             # <<<<<<<<<<<<<<
36638  *                                floating[:,:,:] gradient_moving,
36639  *                                double sigma_sq_x,
36640  */
36641   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 752, __pyx_L1_error)
36642   __Pyx_GOTREF(__pyx_t_1);
36643   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_57compute_ssd_demons_step_2d, 0, __pyx_n_s_compute_ssd_demons_step_2d, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__45)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 752, __pyx_L1_error)
36644   __Pyx_GOTREF(__pyx_t_2);
36645   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36646   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_float, __pyx_t_2) < 0) __PYX_ERR(0, 752, __pyx_L1_error)
36647   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36648   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_59compute_ssd_demons_step_2d, 0, __pyx_n_s_compute_ssd_demons_step_2d, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__45)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 752, __pyx_L1_error)
36649   __Pyx_GOTREF(__pyx_t_2);
36650   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36651   if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_double, __pyx_t_2) < 0) __PYX_ERR(0, 752, __pyx_L1_error)
36652   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36653   __pyx_t_2 = __pyx_FusedFunction_New(&__pyx_mdef_4dipy_5align_9sumsqdiff_17compute_ssd_demons_step_2d, 0, __pyx_n_s_compute_ssd_demons_step_2d, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__45)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 752, __pyx_L1_error)
36654   __Pyx_GOTREF(__pyx_t_2);
36655   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_empty_tuple);
36656   ((__pyx_FusedFunctionObject *) __pyx_t_2)->__signatures__ = __pyx_t_1;
36657   __Pyx_GIVEREF(__pyx_t_1);
36658   __pyx_t_1 = 0;
36659   if (PyDict_SetItem(__pyx_d, __pyx_n_s_compute_ssd_demons_step_2d, __pyx_t_2) < 0) __PYX_ERR(0, 752, __pyx_L1_error)
36660   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36661 
36662   /* "dipy/align/sumsqdiff.pyx":826
36663  * @cython.wraparound(False)
36664  * @cython.cdivision(True)
36665  * def compute_ssd_demons_step_3d(floating[:,:,:] delta_field,             # <<<<<<<<<<<<<<
36666  *                                floating[:,:,:,:] gradient_moving,
36667  *                                double sigma_sq_x,
36668  */
36669   __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 826, __pyx_L1_error)
36670   __Pyx_GOTREF(__pyx_t_2);
36671   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_fuse_0__pyx_mdef_4dipy_5align_9sumsqdiff_63compute_ssd_demons_step_3d, 0, __pyx_n_s_compute_ssd_demons_step_3d, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__47)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
36672   __Pyx_GOTREF(__pyx_t_1);
36673   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36674   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_float, __pyx_t_1) < 0) __PYX_ERR(0, 826, __pyx_L1_error)
36675   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36676   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_fuse_1__pyx_mdef_4dipy_5align_9sumsqdiff_65compute_ssd_demons_step_3d, 0, __pyx_n_s_compute_ssd_demons_step_3d, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__47)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
36677   __Pyx_GOTREF(__pyx_t_1);
36678   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36679   if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_double, __pyx_t_1) < 0) __PYX_ERR(0, 826, __pyx_L1_error)
36680   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36681   __pyx_t_1 = __pyx_FusedFunction_New(&__pyx_mdef_4dipy_5align_9sumsqdiff_19compute_ssd_demons_step_3d, 0, __pyx_n_s_compute_ssd_demons_step_3d, NULL, __pyx_n_s_dipy_align_sumsqdiff, __pyx_d, ((PyObject *)__pyx_codeobj__47)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 826, __pyx_L1_error)
36682   __Pyx_GOTREF(__pyx_t_1);
36683   __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_empty_tuple);
36684   ((__pyx_FusedFunctionObject *) __pyx_t_1)->__signatures__ = __pyx_t_2;
36685   __Pyx_GIVEREF(__pyx_t_2);
36686   __pyx_t_2 = 0;
36687   if (PyDict_SetItem(__pyx_d, __pyx_n_s_compute_ssd_demons_step_3d, __pyx_t_1) < 0) __PYX_ERR(0, 826, __pyx_L1_error)
36688   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36689 
36690   /* "dipy/align/sumsqdiff.pyx":1
36691  * """ Utility functions used by the Sum of Squared Differences (SSD) metric """             # <<<<<<<<<<<<<<
36692  *
36693  * import numpy as np
36694  */
36695   __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
36696   __Pyx_GOTREF(__pyx_t_1);
36697   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
36698   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36699 
36700   /* "View.MemoryView":209
36701  *         info.obj = self
36702  *
36703  *     __pyx_getbuffer = capsule(<void *> &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
36704  *
36705  *     def __dealloc__(array self):
36706  */
36707   __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)
36708   __Pyx_GOTREF(__pyx_t_1);
36709   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)
36710   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36711   PyType_Modified(__pyx_array_type);
36712 
36713   /* "View.MemoryView":286
36714  *         return self.name
36715  *
36716  * cdef generic = Enum("<strided and direct or indirect>")             # <<<<<<<<<<<<<<
36717  * cdef strided = Enum("<strided and direct>") # default
36718  * cdef indirect = Enum("<strided and indirect>")
36719  */
36720   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 286, __pyx_L1_error)
36721   __Pyx_GOTREF(__pyx_t_1);
36722   __Pyx_XGOTREF(generic);
36723   __Pyx_DECREF_SET(generic, __pyx_t_1);
36724   __Pyx_GIVEREF(__pyx_t_1);
36725   __pyx_t_1 = 0;
36726 
36727   /* "View.MemoryView":287
36728  *
36729  * cdef generic = Enum("<strided and direct or indirect>")
36730  * cdef strided = Enum("<strided and direct>") # default             # <<<<<<<<<<<<<<
36731  * cdef indirect = Enum("<strided and indirect>")
36732  *
36733  */
36734   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 287, __pyx_L1_error)
36735   __Pyx_GOTREF(__pyx_t_1);
36736   __Pyx_XGOTREF(strided);
36737   __Pyx_DECREF_SET(strided, __pyx_t_1);
36738   __Pyx_GIVEREF(__pyx_t_1);
36739   __pyx_t_1 = 0;
36740 
36741   /* "View.MemoryView":288
36742  * cdef generic = Enum("<strided and direct or indirect>")
36743  * cdef strided = Enum("<strided and direct>") # default
36744  * cdef indirect = Enum("<strided and indirect>")             # <<<<<<<<<<<<<<
36745  *
36746  *
36747  */
36748   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 288, __pyx_L1_error)
36749   __Pyx_GOTREF(__pyx_t_1);
36750   __Pyx_XGOTREF(indirect);
36751   __Pyx_DECREF_SET(indirect, __pyx_t_1);
36752   __Pyx_GIVEREF(__pyx_t_1);
36753   __pyx_t_1 = 0;
36754 
36755   /* "View.MemoryView":291
36756  *
36757  *
36758  * cdef contiguous = Enum("<contiguous and direct>")             # <<<<<<<<<<<<<<
36759  * cdef indirect_contiguous = Enum("<contiguous and indirect>")
36760  *
36761  */
36762   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 291, __pyx_L1_error)
36763   __Pyx_GOTREF(__pyx_t_1);
36764   __Pyx_XGOTREF(contiguous);
36765   __Pyx_DECREF_SET(contiguous, __pyx_t_1);
36766   __Pyx_GIVEREF(__pyx_t_1);
36767   __pyx_t_1 = 0;
36768 
36769   /* "View.MemoryView":292
36770  *
36771  * cdef contiguous = Enum("<contiguous and direct>")
36772  * cdef indirect_contiguous = Enum("<contiguous and indirect>")             # <<<<<<<<<<<<<<
36773  *
36774  *
36775  */
36776   __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 292, __pyx_L1_error)
36777   __Pyx_GOTREF(__pyx_t_1);
36778   __Pyx_XGOTREF(indirect_contiguous);
36779   __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1);
36780   __Pyx_GIVEREF(__pyx_t_1);
36781   __pyx_t_1 = 0;
36782 
36783   /* "View.MemoryView":316
36784  *
36785  * DEF THREAD_LOCKS_PREALLOCATED = 8
36786  * cdef int __pyx_memoryview_thread_locks_used = 0             # <<<<<<<<<<<<<<
36787  * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [
36788  *     PyThread_allocate_lock(),
36789  */
36790   __pyx_memoryview_thread_locks_used = 0;
36791 
36792   /* "View.MemoryView":317
36793  * DEF THREAD_LOCKS_PREALLOCATED = 8
36794  * cdef int __pyx_memoryview_thread_locks_used = 0
36795  * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [             # <<<<<<<<<<<<<<
36796  *     PyThread_allocate_lock(),
36797  *     PyThread_allocate_lock(),
36798  */
36799   __pyx_t_3[0] = PyThread_allocate_lock();
36800   __pyx_t_3[1] = PyThread_allocate_lock();
36801   __pyx_t_3[2] = PyThread_allocate_lock();
36802   __pyx_t_3[3] = PyThread_allocate_lock();
36803   __pyx_t_3[4] = PyThread_allocate_lock();
36804   __pyx_t_3[5] = PyThread_allocate_lock();
36805   __pyx_t_3[6] = PyThread_allocate_lock();
36806   __pyx_t_3[7] = PyThread_allocate_lock();
36807   memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_3, sizeof(__pyx_memoryview_thread_locks[0]) * (8));
36808 
36809   /* "View.MemoryView":549
36810  *         info.obj = self
36811  *
36812  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
36813  *
36814  *
36815  */
36816   __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)
36817   __Pyx_GOTREF(__pyx_t_1);
36818   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)
36819   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36820   PyType_Modified(__pyx_memoryview_type);
36821 
36822   /* "View.MemoryView":995
36823  *         return self.from_object
36824  *
36825  *     __pyx_getbuffer = capsule(<void *> &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")             # <<<<<<<<<<<<<<
36826  *
36827  *
36828  */
36829   __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)
36830   __Pyx_GOTREF(__pyx_t_1);
36831   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)
36832   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36833   PyType_Modified(__pyx_memoryviewslice_type);
36834 
36835   /* "(tree fragment)":1
36836  * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
36837  *     cdef object __pyx_PickleError
36838  *     cdef object __pyx_result
36839  */
36840   __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)
36841   __Pyx_GOTREF(__pyx_t_1);
36842   if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
36843   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36844 
36845   /* "(tree fragment)":11
36846  *         __pyx_unpickle_Enum__set_state(<Enum> __pyx_result, __pyx_state)
36847  *     return __pyx_result
36848  * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
36849  *     __pyx_result.name = __pyx_state[0]
36850  *     if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
36851  */
36852 
36853   /*--- Wrapped vars code ---*/
36854 
36855   goto __pyx_L0;
36856   __pyx_L1_error:;
36857   __Pyx_XDECREF(__pyx_t_1);
36858   __Pyx_XDECREF(__pyx_t_2);
36859   if (__pyx_m) {
36860     if (__pyx_d) {
36861       __Pyx_AddTraceback("init dipy.align.sumsqdiff", __pyx_clineno, __pyx_lineno, __pyx_filename);
36862     }
36863     Py_CLEAR(__pyx_m);
36864   } else if (!PyErr_Occurred()) {
36865     PyErr_SetString(PyExc_ImportError, "init dipy.align.sumsqdiff");
36866   }
36867   __pyx_L0:;
36868   __Pyx_RefNannyFinishContext();
36869   #if CYTHON_PEP489_MULTI_PHASE_INIT
36870   return (__pyx_m != NULL) ? 0 : -1;
36871   #elif PY_MAJOR_VERSION >= 3
36872   return __pyx_m;
36873   #else
36874   return;
36875   #endif
36876 }
36877 
36878 /* --- Runtime support code --- */
36879 /* Refnanny */
36880 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)36881 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
36882     PyObject *m = NULL, *p = NULL;
36883     void *r = NULL;
36884     m = PyImport_ImportModule(modname);
36885     if (!m) goto end;
36886     p = PyObject_GetAttrString(m, "RefNannyAPI");
36887     if (!p) goto end;
36888     r = PyLong_AsVoidPtr(p);
36889 end:
36890     Py_XDECREF(p);
36891     Py_XDECREF(m);
36892     return (__Pyx_RefNannyAPIStruct *)r;
36893 }
36894 #endif
36895 
36896 /* PyObjectGetAttrStr */
36897 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)36898 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
36899     PyTypeObject* tp = Py_TYPE(obj);
36900     if (likely(tp->tp_getattro))
36901         return tp->tp_getattro(obj, attr_name);
36902 #if PY_MAJOR_VERSION < 3
36903     if (likely(tp->tp_getattr))
36904         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
36905 #endif
36906     return PyObject_GetAttr(obj, attr_name);
36907 }
36908 #endif
36909 
36910 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)36911 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
36912     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
36913     if (unlikely(!result)) {
36914         PyErr_Format(PyExc_NameError,
36915 #if PY_MAJOR_VERSION >= 3
36916             "name '%U' is not defined", name);
36917 #else
36918             "name '%.200s' is not defined", PyString_AS_STRING(name));
36919 #endif
36920     }
36921     return result;
36922 }
36923 
36924 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)36925 static void __Pyx_RaiseArgtupleInvalid(
36926     const char* func_name,
36927     int exact,
36928     Py_ssize_t num_min,
36929     Py_ssize_t num_max,
36930     Py_ssize_t num_found)
36931 {
36932     Py_ssize_t num_expected;
36933     const char *more_or_less;
36934     if (num_found < num_min) {
36935         num_expected = num_min;
36936         more_or_less = "at least";
36937     } else {
36938         num_expected = num_max;
36939         more_or_less = "at most";
36940     }
36941     if (exact) {
36942         more_or_less = "exactly";
36943     }
36944     PyErr_Format(PyExc_TypeError,
36945                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
36946                  func_name, more_or_less, num_expected,
36947                  (num_expected == 1) ? "" : "s", num_found);
36948 }
36949 
36950 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)36951 static void __Pyx_RaiseDoubleKeywordsError(
36952     const char* func_name,
36953     PyObject* kw_name)
36954 {
36955     PyErr_Format(PyExc_TypeError,
36956         #if PY_MAJOR_VERSION >= 3
36957         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
36958         #else
36959         "%s() got multiple values for keyword argument '%s'", func_name,
36960         PyString_AsString(kw_name));
36961         #endif
36962 }
36963 
36964 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)36965 static int __Pyx_ParseOptionalKeywords(
36966     PyObject *kwds,
36967     PyObject **argnames[],
36968     PyObject *kwds2,
36969     PyObject *values[],
36970     Py_ssize_t num_pos_args,
36971     const char* function_name)
36972 {
36973     PyObject *key = 0, *value = 0;
36974     Py_ssize_t pos = 0;
36975     PyObject*** name;
36976     PyObject*** first_kw_arg = argnames + num_pos_args;
36977     while (PyDict_Next(kwds, &pos, &key, &value)) {
36978         name = first_kw_arg;
36979         while (*name && (**name != key)) name++;
36980         if (*name) {
36981             values[name-argnames] = value;
36982             continue;
36983         }
36984         name = first_kw_arg;
36985         #if PY_MAJOR_VERSION < 3
36986         if (likely(PyString_Check(key))) {
36987             while (*name) {
36988                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
36989                         && _PyString_Eq(**name, key)) {
36990                     values[name-argnames] = value;
36991                     break;
36992                 }
36993                 name++;
36994             }
36995             if (*name) continue;
36996             else {
36997                 PyObject*** argname = argnames;
36998                 while (argname != first_kw_arg) {
36999                     if ((**argname == key) || (
37000                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
37001                              && _PyString_Eq(**argname, key))) {
37002                         goto arg_passed_twice;
37003                     }
37004                     argname++;
37005                 }
37006             }
37007         } else
37008         #endif
37009         if (likely(PyUnicode_Check(key))) {
37010             while (*name) {
37011                 int cmp = (**name == key) ? 0 :
37012                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
37013                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
37014                 #endif
37015                     PyUnicode_Compare(**name, key);
37016                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
37017                 if (cmp == 0) {
37018                     values[name-argnames] = value;
37019                     break;
37020                 }
37021                 name++;
37022             }
37023             if (*name) continue;
37024             else {
37025                 PyObject*** argname = argnames;
37026                 while (argname != first_kw_arg) {
37027                     int cmp = (**argname == key) ? 0 :
37028                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
37029                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
37030                     #endif
37031                         PyUnicode_Compare(**argname, key);
37032                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
37033                     if (cmp == 0) goto arg_passed_twice;
37034                     argname++;
37035                 }
37036             }
37037         } else
37038             goto invalid_keyword_type;
37039         if (kwds2) {
37040             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
37041         } else {
37042             goto invalid_keyword;
37043         }
37044     }
37045     return 0;
37046 arg_passed_twice:
37047     __Pyx_RaiseDoubleKeywordsError(function_name, key);
37048     goto bad;
37049 invalid_keyword_type:
37050     PyErr_Format(PyExc_TypeError,
37051         "%.200s() keywords must be strings", function_name);
37052     goto bad;
37053 invalid_keyword:
37054     PyErr_Format(PyExc_TypeError,
37055     #if PY_MAJOR_VERSION < 3
37056         "%.200s() got an unexpected keyword argument '%.200s'",
37057         function_name, PyString_AsString(key));
37058     #else
37059         "%s() got an unexpected keyword argument '%U'",
37060         function_name, key);
37061     #endif
37062 bad:
37063     return -1;
37064 }
37065 
37066 /* PyDictVersioning */
37067 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)37068 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
37069     PyObject *dict = Py_TYPE(obj)->tp_dict;
37070     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
37071 }
__Pyx_get_object_dict_version(PyObject * obj)37072 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
37073     PyObject **dictptr = NULL;
37074     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
37075     if (offset) {
37076 #if CYTHON_COMPILING_IN_CPYTHON
37077         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
37078 #else
37079         dictptr = _PyObject_GetDictPtr(obj);
37080 #endif
37081     }
37082     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
37083 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)37084 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
37085     PyObject *dict = Py_TYPE(obj)->tp_dict;
37086     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
37087         return 0;
37088     return obj_dict_version == __Pyx_get_object_dict_version(obj);
37089 }
37090 #endif
37091 
37092 /* GetModuleGlobalName */
37093 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)37094 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
37095 #else
37096 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
37097 #endif
37098 {
37099     PyObject *result;
37100 #if !CYTHON_AVOID_BORROWED_REFS
37101 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
37102     result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
37103     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
37104     if (likely(result)) {
37105         return __Pyx_NewRef(result);
37106     } else if (unlikely(PyErr_Occurred())) {
37107         return NULL;
37108     }
37109 #else
37110     result = PyDict_GetItem(__pyx_d, name);
37111     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
37112     if (likely(result)) {
37113         return __Pyx_NewRef(result);
37114     }
37115 #endif
37116 #else
37117     result = PyObject_GetItem(__pyx_d, name);
37118     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
37119     if (likely(result)) {
37120         return __Pyx_NewRef(result);
37121     }
37122     PyErr_Clear();
37123 #endif
37124     return __Pyx_GetBuiltinName(name);
37125 }
37126 
37127 /* PyObjectCall */
37128 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)37129 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
37130     PyObject *result;
37131     ternaryfunc call = func->ob_type->tp_call;
37132     if (unlikely(!call))
37133         return PyObject_Call(func, arg, kw);
37134     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
37135         return NULL;
37136     result = (*call)(func, arg, kw);
37137     Py_LeaveRecursiveCall();
37138     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
37139         PyErr_SetString(
37140             PyExc_SystemError,
37141             "NULL result without error in PyObject_Call");
37142     }
37143     return result;
37144 }
37145 #endif
37146 
37147 /* ExtTypeTest */
__Pyx_TypeTest(PyObject * obj,PyTypeObject * type)37148 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
37149     if (unlikely(!type)) {
37150         PyErr_SetString(PyExc_SystemError, "Missing type object");
37151         return 0;
37152     }
37153     if (likely(__Pyx_TypeCheck(obj, type)))
37154         return 1;
37155     PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
37156                  Py_TYPE(obj)->tp_name, type->tp_name);
37157     return 0;
37158 }
37159 
37160 /* PyFunctionFastCall */
37161 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)37162 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
37163                                                PyObject *globals) {
37164     PyFrameObject *f;
37165     PyThreadState *tstate = __Pyx_PyThreadState_Current;
37166     PyObject **fastlocals;
37167     Py_ssize_t i;
37168     PyObject *result;
37169     assert(globals != NULL);
37170     /* XXX Perhaps we should create a specialized
37171        PyFrame_New() that doesn't take locals, but does
37172        take builtins without sanity checking them.
37173        */
37174     assert(tstate != NULL);
37175     f = PyFrame_New(tstate, co, globals, NULL);
37176     if (f == NULL) {
37177         return NULL;
37178     }
37179     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
37180     for (i = 0; i < na; i++) {
37181         Py_INCREF(*args);
37182         fastlocals[i] = *args++;
37183     }
37184     result = PyEval_EvalFrameEx(f,0);
37185     ++tstate->recursion_depth;
37186     Py_DECREF(f);
37187     --tstate->recursion_depth;
37188     return result;
37189 }
37190 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)37191 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
37192     PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
37193     PyObject *globals = PyFunction_GET_GLOBALS(func);
37194     PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
37195     PyObject *closure;
37196 #if PY_MAJOR_VERSION >= 3
37197     PyObject *kwdefs;
37198 #endif
37199     PyObject *kwtuple, **k;
37200     PyObject **d;
37201     Py_ssize_t nd;
37202     Py_ssize_t nk;
37203     PyObject *result;
37204     assert(kwargs == NULL || PyDict_Check(kwargs));
37205     nk = kwargs ? PyDict_Size(kwargs) : 0;
37206     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
37207         return NULL;
37208     }
37209     if (
37210 #if PY_MAJOR_VERSION >= 3
37211             co->co_kwonlyargcount == 0 &&
37212 #endif
37213             likely(kwargs == NULL || nk == 0) &&
37214             co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
37215         if (argdefs == NULL && co->co_argcount == nargs) {
37216             result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
37217             goto done;
37218         }
37219         else if (nargs == 0 && argdefs != NULL
37220                  && co->co_argcount == Py_SIZE(argdefs)) {
37221             /* function called with no arguments, but all parameters have
37222                a default value: use default values as arguments .*/
37223             args = &PyTuple_GET_ITEM(argdefs, 0);
37224             result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
37225             goto done;
37226         }
37227     }
37228     if (kwargs != NULL) {
37229         Py_ssize_t pos, i;
37230         kwtuple = PyTuple_New(2 * nk);
37231         if (kwtuple == NULL) {
37232             result = NULL;
37233             goto done;
37234         }
37235         k = &PyTuple_GET_ITEM(kwtuple, 0);
37236         pos = i = 0;
37237         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
37238             Py_INCREF(k[i]);
37239             Py_INCREF(k[i+1]);
37240             i += 2;
37241         }
37242         nk = i / 2;
37243     }
37244     else {
37245         kwtuple = NULL;
37246         k = NULL;
37247     }
37248     closure = PyFunction_GET_CLOSURE(func);
37249 #if PY_MAJOR_VERSION >= 3
37250     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
37251 #endif
37252     if (argdefs != NULL) {
37253         d = &PyTuple_GET_ITEM(argdefs, 0);
37254         nd = Py_SIZE(argdefs);
37255     }
37256     else {
37257         d = NULL;
37258         nd = 0;
37259     }
37260 #if PY_MAJOR_VERSION >= 3
37261     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
37262                                args, (int)nargs,
37263                                k, (int)nk,
37264                                d, (int)nd, kwdefs, closure);
37265 #else
37266     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
37267                                args, (int)nargs,
37268                                k, (int)nk,
37269                                d, (int)nd, closure);
37270 #endif
37271     Py_XDECREF(kwtuple);
37272 done:
37273     Py_LeaveRecursiveCall();
37274     return result;
37275 }
37276 #endif
37277 #endif
37278 
37279 /* PyCFunctionFastCall */
37280 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)37281 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
37282     PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
37283     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
37284     PyObject *self = PyCFunction_GET_SELF(func);
37285     int flags = PyCFunction_GET_FLAGS(func);
37286     assert(PyCFunction_Check(func));
37287     assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
37288     assert(nargs >= 0);
37289     assert(nargs == 0 || args != NULL);
37290     /* _PyCFunction_FastCallDict() must not be called with an exception set,
37291        because it may clear it (directly or indirectly) and so the
37292        caller loses its exception */
37293     assert(!PyErr_Occurred());
37294     if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
37295         return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
37296     } else {
37297         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
37298     }
37299 }
37300 #endif
37301 
37302 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)37303 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
37304     PyObject *args, *result = NULL;
37305     #if CYTHON_FAST_PYCALL
37306     if (PyFunction_Check(function)) {
37307         PyObject *args[2] = {arg1, arg2};
37308         return __Pyx_PyFunction_FastCall(function, args, 2);
37309     }
37310     #endif
37311     #if CYTHON_FAST_PYCCALL
37312     if (__Pyx_PyFastCFunction_Check(function)) {
37313         PyObject *args[2] = {arg1, arg2};
37314         return __Pyx_PyCFunction_FastCall(function, args, 2);
37315     }
37316     #endif
37317     args = PyTuple_New(2);
37318     if (unlikely(!args)) goto done;
37319     Py_INCREF(arg1);
37320     PyTuple_SET_ITEM(args, 0, arg1);
37321     Py_INCREF(arg2);
37322     PyTuple_SET_ITEM(args, 1, arg2);
37323     Py_INCREF(function);
37324     result = __Pyx_PyObject_Call(function, args, NULL);
37325     Py_DECREF(args);
37326     Py_DECREF(function);
37327 done:
37328     return result;
37329 }
37330 
37331 /* PyObjectCallMethO */
37332 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)37333 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
37334     PyObject *self, *result;
37335     PyCFunction cfunc;
37336     cfunc = PyCFunction_GET_FUNCTION(func);
37337     self = PyCFunction_GET_SELF(func);
37338     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
37339         return NULL;
37340     result = cfunc(self, arg);
37341     Py_LeaveRecursiveCall();
37342     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
37343         PyErr_SetString(
37344             PyExc_SystemError,
37345             "NULL result without error in PyObject_Call");
37346     }
37347     return result;
37348 }
37349 #endif
37350 
37351 /* PyObjectCallOneArg */
37352 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)37353 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
37354     PyObject *result;
37355     PyObject *args = PyTuple_New(1);
37356     if (unlikely(!args)) return NULL;
37357     Py_INCREF(arg);
37358     PyTuple_SET_ITEM(args, 0, arg);
37359     result = __Pyx_PyObject_Call(func, args, NULL);
37360     Py_DECREF(args);
37361     return result;
37362 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)37363 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
37364 #if CYTHON_FAST_PYCALL
37365     if (PyFunction_Check(func)) {
37366         return __Pyx_PyFunction_FastCall(func, &arg, 1);
37367     }
37368 #endif
37369     if (likely(PyCFunction_Check(func))) {
37370         if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
37371             return __Pyx_PyObject_CallMethO(func, arg);
37372 #if CYTHON_FAST_PYCCALL
37373         } else if (__Pyx_PyFastCFunction_Check(func)) {
37374             return __Pyx_PyCFunction_FastCall(func, &arg, 1);
37375 #endif
37376         }
37377     }
37378     return __Pyx__PyObject_CallOneArg(func, arg);
37379 }
37380 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)37381 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
37382     PyObject *result;
37383     PyObject *args = PyTuple_Pack(1, arg);
37384     if (unlikely(!args)) return NULL;
37385     result = __Pyx_PyObject_Call(func, args, NULL);
37386     Py_DECREF(args);
37387     return result;
37388 }
37389 #endif
37390 
37391 /* DictGetItem */
37392 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
__Pyx_PyDict_GetItem(PyObject * d,PyObject * key)37393 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
37394     PyObject *value;
37395     value = PyDict_GetItemWithError(d, key);
37396     if (unlikely(!value)) {
37397         if (!PyErr_Occurred()) {
37398             if (unlikely(PyTuple_Check(key))) {
37399                 PyObject* args = PyTuple_Pack(1, key);
37400                 if (likely(args)) {
37401                     PyErr_SetObject(PyExc_KeyError, args);
37402                     Py_DECREF(args);
37403                 }
37404             } else {
37405                 PyErr_SetObject(PyExc_KeyError, key);
37406             }
37407         }
37408         return NULL;
37409     }
37410     Py_INCREF(value);
37411     return value;
37412 }
37413 #endif
37414 
37415 /* PyErrFetchRestore */
37416 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)37417 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
37418     PyObject *tmp_type, *tmp_value, *tmp_tb;
37419     tmp_type = tstate->curexc_type;
37420     tmp_value = tstate->curexc_value;
37421     tmp_tb = tstate->curexc_traceback;
37422     tstate->curexc_type = type;
37423     tstate->curexc_value = value;
37424     tstate->curexc_traceback = tb;
37425     Py_XDECREF(tmp_type);
37426     Py_XDECREF(tmp_value);
37427     Py_XDECREF(tmp_tb);
37428 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)37429 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
37430     *type = tstate->curexc_type;
37431     *value = tstate->curexc_value;
37432     *tb = tstate->curexc_traceback;
37433     tstate->curexc_type = 0;
37434     tstate->curexc_value = 0;
37435     tstate->curexc_traceback = 0;
37436 }
37437 #endif
37438 
37439 /* RaiseException */
37440 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)37441 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
37442                         CYTHON_UNUSED PyObject *cause) {
37443     __Pyx_PyThreadState_declare
37444     Py_XINCREF(type);
37445     if (!value || value == Py_None)
37446         value = NULL;
37447     else
37448         Py_INCREF(value);
37449     if (!tb || tb == Py_None)
37450         tb = NULL;
37451     else {
37452         Py_INCREF(tb);
37453         if (!PyTraceBack_Check(tb)) {
37454             PyErr_SetString(PyExc_TypeError,
37455                 "raise: arg 3 must be a traceback or None");
37456             goto raise_error;
37457         }
37458     }
37459     if (PyType_Check(type)) {
37460 #if CYTHON_COMPILING_IN_PYPY
37461         if (!value) {
37462             Py_INCREF(Py_None);
37463             value = Py_None;
37464         }
37465 #endif
37466         PyErr_NormalizeException(&type, &value, &tb);
37467     } else {
37468         if (value) {
37469             PyErr_SetString(PyExc_TypeError,
37470                 "instance exception may not have a separate value");
37471             goto raise_error;
37472         }
37473         value = type;
37474         type = (PyObject*) Py_TYPE(type);
37475         Py_INCREF(type);
37476         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
37477             PyErr_SetString(PyExc_TypeError,
37478                 "raise: exception class must be a subclass of BaseException");
37479             goto raise_error;
37480         }
37481     }
37482     __Pyx_PyThreadState_assign
37483     __Pyx_ErrRestore(type, value, tb);
37484     return;
37485 raise_error:
37486     Py_XDECREF(value);
37487     Py_XDECREF(type);
37488     Py_XDECREF(tb);
37489     return;
37490 }
37491 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)37492 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
37493     PyObject* owned_instance = NULL;
37494     if (tb == Py_None) {
37495         tb = 0;
37496     } else if (tb && !PyTraceBack_Check(tb)) {
37497         PyErr_SetString(PyExc_TypeError,
37498             "raise: arg 3 must be a traceback or None");
37499         goto bad;
37500     }
37501     if (value == Py_None)
37502         value = 0;
37503     if (PyExceptionInstance_Check(type)) {
37504         if (value) {
37505             PyErr_SetString(PyExc_TypeError,
37506                 "instance exception may not have a separate value");
37507             goto bad;
37508         }
37509         value = type;
37510         type = (PyObject*) Py_TYPE(value);
37511     } else if (PyExceptionClass_Check(type)) {
37512         PyObject *instance_class = NULL;
37513         if (value && PyExceptionInstance_Check(value)) {
37514             instance_class = (PyObject*) Py_TYPE(value);
37515             if (instance_class != type) {
37516                 int is_subclass = PyObject_IsSubclass(instance_class, type);
37517                 if (!is_subclass) {
37518                     instance_class = NULL;
37519                 } else if (unlikely(is_subclass == -1)) {
37520                     goto bad;
37521                 } else {
37522                     type = instance_class;
37523                 }
37524             }
37525         }
37526         if (!instance_class) {
37527             PyObject *args;
37528             if (!value)
37529                 args = PyTuple_New(0);
37530             else if (PyTuple_Check(value)) {
37531                 Py_INCREF(value);
37532                 args = value;
37533             } else
37534                 args = PyTuple_Pack(1, value);
37535             if (!args)
37536                 goto bad;
37537             owned_instance = PyObject_Call(type, args, NULL);
37538             Py_DECREF(args);
37539             if (!owned_instance)
37540                 goto bad;
37541             value = owned_instance;
37542             if (!PyExceptionInstance_Check(value)) {
37543                 PyErr_Format(PyExc_TypeError,
37544                              "calling %R should have returned an instance of "
37545                              "BaseException, not %R",
37546                              type, Py_TYPE(value));
37547                 goto bad;
37548             }
37549         }
37550     } else {
37551         PyErr_SetString(PyExc_TypeError,
37552             "raise: exception class must be a subclass of BaseException");
37553         goto bad;
37554     }
37555     if (cause) {
37556         PyObject *fixed_cause;
37557         if (cause == Py_None) {
37558             fixed_cause = NULL;
37559         } else if (PyExceptionClass_Check(cause)) {
37560             fixed_cause = PyObject_CallObject(cause, NULL);
37561             if (fixed_cause == NULL)
37562                 goto bad;
37563         } else if (PyExceptionInstance_Check(cause)) {
37564             fixed_cause = cause;
37565             Py_INCREF(fixed_cause);
37566         } else {
37567             PyErr_SetString(PyExc_TypeError,
37568                             "exception causes must derive from "
37569                             "BaseException");
37570             goto bad;
37571         }
37572         PyException_SetCause(value, fixed_cause);
37573     }
37574     PyErr_SetObject(type, value);
37575     if (tb) {
37576 #if CYTHON_COMPILING_IN_PYPY
37577         PyObject *tmp_type, *tmp_value, *tmp_tb;
37578         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
37579         Py_INCREF(tb);
37580         PyErr_Restore(tmp_type, tmp_value, tb);
37581         Py_XDECREF(tmp_tb);
37582 #else
37583         PyThreadState *tstate = __Pyx_PyThreadState_Current;
37584         PyObject* tmp_tb = tstate->curexc_traceback;
37585         if (tb != tmp_tb) {
37586             Py_INCREF(tb);
37587             tstate->curexc_traceback = tb;
37588             Py_XDECREF(tmp_tb);
37589         }
37590 #endif
37591     }
37592 bad:
37593     Py_XDECREF(owned_instance);
37594     return;
37595 }
37596 #endif
37597 
37598 /* UnicodeAsUCS4 */
__Pyx_PyUnicode_AsPy_UCS4(PyObject * x)37599 static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject* x) {
37600    Py_ssize_t length;
37601    #if CYTHON_PEP393_ENABLED
37602    length = PyUnicode_GET_LENGTH(x);
37603    if (likely(length == 1)) {
37604        return PyUnicode_READ_CHAR(x, 0);
37605    }
37606    #else
37607    length = PyUnicode_GET_SIZE(x);
37608    if (likely(length == 1)) {
37609        return PyUnicode_AS_UNICODE(x)[0];
37610    }
37611    #if Py_UNICODE_SIZE == 2
37612    else if (PyUnicode_GET_SIZE(x) == 2) {
37613        Py_UCS4 high_val = PyUnicode_AS_UNICODE(x)[0];
37614        if (high_val >= 0xD800 && high_val <= 0xDBFF) {
37615            Py_UCS4 low_val = PyUnicode_AS_UNICODE(x)[1];
37616            if (low_val >= 0xDC00 && low_val <= 0xDFFF) {
37617                return 0x10000 + (((high_val & ((1<<10)-1)) << 10) | (low_val & ((1<<10)-1)));
37618            }
37619        }
37620    }
37621    #endif
37622    #endif
37623    PyErr_Format(PyExc_ValueError,
37624                 "only single character unicode strings can be converted to Py_UCS4, "
37625                 "got length %" CYTHON_FORMAT_SSIZE_T "d", length);
37626    return (Py_UCS4)-1;
37627 }
37628 
37629 /* object_ord */
__Pyx__PyObject_Ord(PyObject * c)37630 static long __Pyx__PyObject_Ord(PyObject* c) {
37631     Py_ssize_t size;
37632     if (PyBytes_Check(c)) {
37633         size = PyBytes_GET_SIZE(c);
37634         if (likely(size == 1)) {
37635             return (unsigned char) PyBytes_AS_STRING(c)[0];
37636         }
37637 #if PY_MAJOR_VERSION < 3
37638     } else if (PyUnicode_Check(c)) {
37639         return (long)__Pyx_PyUnicode_AsPy_UCS4(c);
37640 #endif
37641 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
37642     } else if (PyByteArray_Check(c)) {
37643         size = PyByteArray_GET_SIZE(c);
37644         if (likely(size == 1)) {
37645             return (unsigned char) PyByteArray_AS_STRING(c)[0];
37646         }
37647 #endif
37648     } else {
37649         PyErr_Format(PyExc_TypeError,
37650             "ord() expected string of length 1, but %.200s found", c->ob_type->tp_name);
37651         return (long)(Py_UCS4)-1;
37652     }
37653     PyErr_Format(PyExc_TypeError,
37654         "ord() expected a character, but string of length %zd found", size);
37655     return (long)(Py_UCS4)-1;
37656 }
37657 
37658 /* SetItemInt */
__Pyx_SetItemInt_Generic(PyObject * o,PyObject * j,PyObject * v)37659 static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
37660     int r;
37661     if (!j) return -1;
37662     r = PyObject_SetItem(o, j, v);
37663     Py_DECREF(j);
37664     return r;
37665 }
__Pyx_SetItemInt_Fast(PyObject * o,Py_ssize_t i,PyObject * v,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)37666 static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
37667                                                CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
37668 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
37669     if (is_list || PyList_CheckExact(o)) {
37670         Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
37671         if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
37672             PyObject* old = PyList_GET_ITEM(o, n);
37673             Py_INCREF(v);
37674             PyList_SET_ITEM(o, n, v);
37675             Py_DECREF(old);
37676             return 1;
37677         }
37678     } else {
37679         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
37680         if (likely(m && m->sq_ass_item)) {
37681             if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
37682                 Py_ssize_t l = m->sq_length(o);
37683                 if (likely(l >= 0)) {
37684                     i += l;
37685                 } else {
37686                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
37687                         return -1;
37688                     PyErr_Clear();
37689                 }
37690             }
37691             return m->sq_ass_item(o, i, v);
37692         }
37693     }
37694 #else
37695 #if CYTHON_COMPILING_IN_PYPY
37696     if (is_list || (PySequence_Check(o) && !PyDict_Check(o)))
37697 #else
37698     if (is_list || PySequence_Check(o))
37699 #endif
37700     {
37701         return PySequence_SetItem(o, i, v);
37702     }
37703 #endif
37704     return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
37705 }
37706 
37707 /* IterFinish */
__Pyx_IterFinish(void)37708 static CYTHON_INLINE int __Pyx_IterFinish(void) {
37709 #if CYTHON_FAST_THREAD_STATE
37710     PyThreadState *tstate = __Pyx_PyThreadState_Current;
37711     PyObject* exc_type = tstate->curexc_type;
37712     if (unlikely(exc_type)) {
37713         if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
37714             PyObject *exc_value, *exc_tb;
37715             exc_value = tstate->curexc_value;
37716             exc_tb = tstate->curexc_traceback;
37717             tstate->curexc_type = 0;
37718             tstate->curexc_value = 0;
37719             tstate->curexc_traceback = 0;
37720             Py_DECREF(exc_type);
37721             Py_XDECREF(exc_value);
37722             Py_XDECREF(exc_tb);
37723             return 0;
37724         } else {
37725             return -1;
37726         }
37727     }
37728     return 0;
37729 #else
37730     if (unlikely(PyErr_Occurred())) {
37731         if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
37732             PyErr_Clear();
37733             return 0;
37734         } else {
37735             return -1;
37736         }
37737     }
37738     return 0;
37739 #endif
37740 }
37741 
37742 /* PyObjectCallNoArg */
37743 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)37744 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
37745 #if CYTHON_FAST_PYCALL
37746     if (PyFunction_Check(func)) {
37747         return __Pyx_PyFunction_FastCall(func, NULL, 0);
37748     }
37749 #endif
37750 #ifdef __Pyx_CyFunction_USED
37751     if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
37752 #else
37753     if (likely(PyCFunction_Check(func)))
37754 #endif
37755     {
37756         if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
37757             return __Pyx_PyObject_CallMethO(func, NULL);
37758         }
37759     }
37760     return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
37761 }
37762 #endif
37763 
37764 /* PyObjectGetMethod */
__Pyx_PyObject_GetMethod(PyObject * obj,PyObject * name,PyObject ** method)37765 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
37766     PyObject *attr;
37767 #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
37768     PyTypeObject *tp = Py_TYPE(obj);
37769     PyObject *descr;
37770     descrgetfunc f = NULL;
37771     PyObject **dictptr, *dict;
37772     int meth_found = 0;
37773     assert (*method == NULL);
37774     if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
37775         attr = __Pyx_PyObject_GetAttrStr(obj, name);
37776         goto try_unpack;
37777     }
37778     if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
37779         return 0;
37780     }
37781     descr = _PyType_Lookup(tp, name);
37782     if (likely(descr != NULL)) {
37783         Py_INCREF(descr);
37784 #if PY_MAJOR_VERSION >= 3
37785         #ifdef __Pyx_CyFunction_USED
37786         if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
37787         #else
37788         if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
37789         #endif
37790 #else
37791         #ifdef __Pyx_CyFunction_USED
37792         if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
37793         #else
37794         if (likely(PyFunction_Check(descr)))
37795         #endif
37796 #endif
37797         {
37798             meth_found = 1;
37799         } else {
37800             f = Py_TYPE(descr)->tp_descr_get;
37801             if (f != NULL && PyDescr_IsData(descr)) {
37802                 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
37803                 Py_DECREF(descr);
37804                 goto try_unpack;
37805             }
37806         }
37807     }
37808     dictptr = _PyObject_GetDictPtr(obj);
37809     if (dictptr != NULL && (dict = *dictptr) != NULL) {
37810         Py_INCREF(dict);
37811         attr = __Pyx_PyDict_GetItemStr(dict, name);
37812         if (attr != NULL) {
37813             Py_INCREF(attr);
37814             Py_DECREF(dict);
37815             Py_XDECREF(descr);
37816             goto try_unpack;
37817         }
37818         Py_DECREF(dict);
37819     }
37820     if (meth_found) {
37821         *method = descr;
37822         return 1;
37823     }
37824     if (f != NULL) {
37825         attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
37826         Py_DECREF(descr);
37827         goto try_unpack;
37828     }
37829     if (descr != NULL) {
37830         *method = descr;
37831         return 0;
37832     }
37833     PyErr_Format(PyExc_AttributeError,
37834 #if PY_MAJOR_VERSION >= 3
37835                  "'%.50s' object has no attribute '%U'",
37836                  tp->tp_name, name);
37837 #else
37838                  "'%.50s' object has no attribute '%.400s'",
37839                  tp->tp_name, PyString_AS_STRING(name));
37840 #endif
37841     return 0;
37842 #else
37843     attr = __Pyx_PyObject_GetAttrStr(obj, name);
37844     goto try_unpack;
37845 #endif
37846 try_unpack:
37847 #if CYTHON_UNPACK_METHODS
37848     if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
37849         PyObject *function = PyMethod_GET_FUNCTION(attr);
37850         Py_INCREF(function);
37851         Py_DECREF(attr);
37852         *method = function;
37853         return 1;
37854     }
37855 #endif
37856     *method = attr;
37857     return 0;
37858 }
37859 
37860 /* PyObjectCallMethod0 */
__Pyx_PyObject_CallMethod0(PyObject * obj,PyObject * method_name)37861 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
37862     PyObject *method = NULL, *result = NULL;
37863     int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
37864     if (likely(is_method)) {
37865         result = __Pyx_PyObject_CallOneArg(method, obj);
37866         Py_DECREF(method);
37867         return result;
37868     }
37869     if (unlikely(!method)) goto bad;
37870     result = __Pyx_PyObject_CallNoArg(method);
37871     Py_DECREF(method);
37872 bad:
37873     return result;
37874 }
37875 
37876 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)37877 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
37878     PyErr_Format(PyExc_ValueError,
37879                  "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
37880                  index, (index == 1) ? "" : "s");
37881 }
37882 
37883 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)37884 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
37885     PyErr_Format(PyExc_ValueError,
37886                  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
37887 }
37888 
37889 /* UnpackItemEndCheck */
__Pyx_IternextUnpackEndCheck(PyObject * retval,Py_ssize_t expected)37890 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
37891     if (unlikely(retval)) {
37892         Py_DECREF(retval);
37893         __Pyx_RaiseTooManyValuesError(expected);
37894         return -1;
37895     } else {
37896         return __Pyx_IterFinish();
37897     }
37898     return 0;
37899 }
37900 
37901 /* RaiseNoneIterError */
__Pyx_RaiseNoneNotIterableError(void)37902 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
37903     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
37904 }
37905 
37906 /* UnpackTupleError */
__Pyx_UnpackTupleError(PyObject * t,Py_ssize_t index)37907 static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
37908     if (t == Py_None) {
37909       __Pyx_RaiseNoneNotIterableError();
37910     } else if (PyTuple_GET_SIZE(t) < index) {
37911       __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
37912     } else {
37913       __Pyx_RaiseTooManyValuesError(index);
37914     }
37915 }
37916 
37917 /* UnpackTuple2 */
__Pyx_unpack_tuple2_exact(PyObject * tuple,PyObject ** pvalue1,PyObject ** pvalue2,int decref_tuple)37918 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
37919         PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
37920     PyObject *value1 = NULL, *value2 = NULL;
37921 #if CYTHON_COMPILING_IN_PYPY
37922     value1 = PySequence_ITEM(tuple, 0);  if (unlikely(!value1)) goto bad;
37923     value2 = PySequence_ITEM(tuple, 1);  if (unlikely(!value2)) goto bad;
37924 #else
37925     value1 = PyTuple_GET_ITEM(tuple, 0);  Py_INCREF(value1);
37926     value2 = PyTuple_GET_ITEM(tuple, 1);  Py_INCREF(value2);
37927 #endif
37928     if (decref_tuple) {
37929         Py_DECREF(tuple);
37930     }
37931     *pvalue1 = value1;
37932     *pvalue2 = value2;
37933     return 0;
37934 #if CYTHON_COMPILING_IN_PYPY
37935 bad:
37936     Py_XDECREF(value1);
37937     Py_XDECREF(value2);
37938     if (decref_tuple) { Py_XDECREF(tuple); }
37939     return -1;
37940 #endif
37941 }
__Pyx_unpack_tuple2_generic(PyObject * tuple,PyObject ** pvalue1,PyObject ** pvalue2,int has_known_size,int decref_tuple)37942 static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
37943                                        int has_known_size, int decref_tuple) {
37944     Py_ssize_t index;
37945     PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
37946     iternextfunc iternext;
37947     iter = PyObject_GetIter(tuple);
37948     if (unlikely(!iter)) goto bad;
37949     if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
37950     iternext = Py_TYPE(iter)->tp_iternext;
37951     value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
37952     value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
37953     if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
37954     Py_DECREF(iter);
37955     *pvalue1 = value1;
37956     *pvalue2 = value2;
37957     return 0;
37958 unpacking_failed:
37959     if (!has_known_size && __Pyx_IterFinish() == 0)
37960         __Pyx_RaiseNeedMoreValuesError(index);
37961 bad:
37962     Py_XDECREF(iter);
37963     Py_XDECREF(value1);
37964     Py_XDECREF(value2);
37965     if (decref_tuple) { Py_XDECREF(tuple); }
37966     return -1;
37967 }
37968 
37969 /* dict_iter */
__Pyx_dict_iterator(PyObject * iterable,int is_dict,PyObject * method_name,Py_ssize_t * p_orig_length,int * p_source_is_dict)37970 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
37971                                                    Py_ssize_t* p_orig_length, int* p_source_is_dict) {
37972     is_dict = is_dict || likely(PyDict_CheckExact(iterable));
37973     *p_source_is_dict = is_dict;
37974     if (is_dict) {
37975 #if !CYTHON_COMPILING_IN_PYPY
37976         *p_orig_length = PyDict_Size(iterable);
37977         Py_INCREF(iterable);
37978         return iterable;
37979 #elif PY_MAJOR_VERSION >= 3
37980         static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
37981         PyObject **pp = NULL;
37982         if (method_name) {
37983             const char *name = PyUnicode_AsUTF8(method_name);
37984             if (strcmp(name, "iteritems") == 0) pp = &py_items;
37985             else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
37986             else if (strcmp(name, "itervalues") == 0) pp = &py_values;
37987             if (pp) {
37988                 if (!*pp) {
37989                     *pp = PyUnicode_FromString(name + 4);
37990                     if (!*pp)
37991                         return NULL;
37992                 }
37993                 method_name = *pp;
37994             }
37995         }
37996 #endif
37997     }
37998     *p_orig_length = 0;
37999     if (method_name) {
38000         PyObject* iter;
38001         iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
38002         if (!iterable)
38003             return NULL;
38004 #if !CYTHON_COMPILING_IN_PYPY
38005         if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
38006             return iterable;
38007 #endif
38008         iter = PyObject_GetIter(iterable);
38009         Py_DECREF(iterable);
38010         return iter;
38011     }
38012     return PyObject_GetIter(iterable);
38013 }
__Pyx_dict_iter_next(PyObject * iter_obj,CYTHON_NCP_UNUSED Py_ssize_t orig_length,CYTHON_NCP_UNUSED Py_ssize_t * ppos,PyObject ** pkey,PyObject ** pvalue,PyObject ** pitem,int source_is_dict)38014 static CYTHON_INLINE int __Pyx_dict_iter_next(
38015         PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
38016         PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
38017     PyObject* next_item;
38018 #if !CYTHON_COMPILING_IN_PYPY
38019     if (source_is_dict) {
38020         PyObject *key, *value;
38021         if (unlikely(orig_length != PyDict_Size(iter_obj))) {
38022             PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
38023             return -1;
38024         }
38025         if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
38026             return 0;
38027         }
38028         if (pitem) {
38029             PyObject* tuple = PyTuple_New(2);
38030             if (unlikely(!tuple)) {
38031                 return -1;
38032             }
38033             Py_INCREF(key);
38034             Py_INCREF(value);
38035             PyTuple_SET_ITEM(tuple, 0, key);
38036             PyTuple_SET_ITEM(tuple, 1, value);
38037             *pitem = tuple;
38038         } else {
38039             if (pkey) {
38040                 Py_INCREF(key);
38041                 *pkey = key;
38042             }
38043             if (pvalue) {
38044                 Py_INCREF(value);
38045                 *pvalue = value;
38046             }
38047         }
38048         return 1;
38049     } else if (PyTuple_CheckExact(iter_obj)) {
38050         Py_ssize_t pos = *ppos;
38051         if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
38052         *ppos = pos + 1;
38053         next_item = PyTuple_GET_ITEM(iter_obj, pos);
38054         Py_INCREF(next_item);
38055     } else if (PyList_CheckExact(iter_obj)) {
38056         Py_ssize_t pos = *ppos;
38057         if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
38058         *ppos = pos + 1;
38059         next_item = PyList_GET_ITEM(iter_obj, pos);
38060         Py_INCREF(next_item);
38061     } else
38062 #endif
38063     {
38064         next_item = PyIter_Next(iter_obj);
38065         if (unlikely(!next_item)) {
38066             return __Pyx_IterFinish();
38067         }
38068     }
38069     if (pitem) {
38070         *pitem = next_item;
38071     } else if (pkey && pvalue) {
38072         if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
38073             return -1;
38074     } else if (pkey) {
38075         *pkey = next_item;
38076     } else {
38077         *pvalue = next_item;
38078     }
38079     return 1;
38080 }
38081 
38082 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)38083 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
38084     PyObject *r;
38085     if (!j) return NULL;
38086     r = PyObject_GetItem(o, j);
38087     Py_DECREF(j);
38088     return r;
38089 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)38090 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
38091                                                               CYTHON_NCP_UNUSED int wraparound,
38092                                                               CYTHON_NCP_UNUSED int boundscheck) {
38093 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
38094     Py_ssize_t wrapped_i = i;
38095     if (wraparound & unlikely(i < 0)) {
38096         wrapped_i += PyList_GET_SIZE(o);
38097     }
38098     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
38099         PyObject *r = PyList_GET_ITEM(o, wrapped_i);
38100         Py_INCREF(r);
38101         return r;
38102     }
38103     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
38104 #else
38105     return PySequence_GetItem(o, i);
38106 #endif
38107 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)38108 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
38109                                                               CYTHON_NCP_UNUSED int wraparound,
38110                                                               CYTHON_NCP_UNUSED int boundscheck) {
38111 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
38112     Py_ssize_t wrapped_i = i;
38113     if (wraparound & unlikely(i < 0)) {
38114         wrapped_i += PyTuple_GET_SIZE(o);
38115     }
38116     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
38117         PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
38118         Py_INCREF(r);
38119         return r;
38120     }
38121     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
38122 #else
38123     return PySequence_GetItem(o, i);
38124 #endif
38125 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)38126 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
38127                                                      CYTHON_NCP_UNUSED int wraparound,
38128                                                      CYTHON_NCP_UNUSED int boundscheck) {
38129 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
38130     if (is_list || PyList_CheckExact(o)) {
38131         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
38132         if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
38133             PyObject *r = PyList_GET_ITEM(o, n);
38134             Py_INCREF(r);
38135             return r;
38136         }
38137     }
38138     else if (PyTuple_CheckExact(o)) {
38139         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
38140         if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
38141             PyObject *r = PyTuple_GET_ITEM(o, n);
38142             Py_INCREF(r);
38143             return r;
38144         }
38145     } else {
38146         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
38147         if (likely(m && m->sq_item)) {
38148             if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
38149                 Py_ssize_t l = m->sq_length(o);
38150                 if (likely(l >= 0)) {
38151                     i += l;
38152                 } else {
38153                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
38154                         return NULL;
38155                     PyErr_Clear();
38156                 }
38157             }
38158             return m->sq_item(o, i);
38159         }
38160     }
38161 #else
38162     if (is_list || PySequence_Check(o)) {
38163         return PySequence_GetItem(o, i);
38164     }
38165 #endif
38166     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
38167 }
38168 
38169 /* 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)38170 static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
38171                                   CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
38172                                   int full_traceback, CYTHON_UNUSED int nogil) {
38173     PyObject *old_exc, *old_val, *old_tb;
38174     PyObject *ctx;
38175     __Pyx_PyThreadState_declare
38176 #ifdef WITH_THREAD
38177     PyGILState_STATE state;
38178     if (nogil)
38179         state = PyGILState_Ensure();
38180 #ifdef _MSC_VER
38181     else state = (PyGILState_STATE)-1;
38182 #endif
38183 #endif
38184     __Pyx_PyThreadState_assign
38185     __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
38186     if (full_traceback) {
38187         Py_XINCREF(old_exc);
38188         Py_XINCREF(old_val);
38189         Py_XINCREF(old_tb);
38190         __Pyx_ErrRestore(old_exc, old_val, old_tb);
38191         PyErr_PrintEx(1);
38192     }
38193     #if PY_MAJOR_VERSION < 3
38194     ctx = PyString_FromString(name);
38195     #else
38196     ctx = PyUnicode_FromString(name);
38197     #endif
38198     __Pyx_ErrRestore(old_exc, old_val, old_tb);
38199     if (!ctx) {
38200         PyErr_WriteUnraisable(Py_None);
38201     } else {
38202         PyErr_WriteUnraisable(ctx);
38203         Py_DECREF(ctx);
38204     }
38205 #ifdef WITH_THREAD
38206     if (nogil)
38207         PyGILState_Release(state);
38208 #endif
38209 }
38210 
38211 /* None */
__Pyx_RaiseUnboundLocalError(const char * varname)38212 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
38213     PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
38214 }
38215 
38216 /* MemviewSliceInit */
38217 static int
__Pyx_init_memviewslice(struct __pyx_memoryview_obj * memview,int ndim,__Pyx_memviewslice * memviewslice,int memview_is_new_reference)38218 __Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview,
38219                         int ndim,
38220                         __Pyx_memviewslice *memviewslice,
38221                         int memview_is_new_reference)
38222 {
38223     __Pyx_RefNannyDeclarations
38224     int i, retval=-1;
38225     Py_buffer *buf = &memview->view;
38226     __Pyx_RefNannySetupContext("init_memviewslice", 0);
38227     if (unlikely(memviewslice->memview || memviewslice->data)) {
38228         PyErr_SetString(PyExc_ValueError,
38229             "memviewslice is already initialized!");
38230         goto fail;
38231     }
38232     if (buf->strides) {
38233         for (i = 0; i < ndim; i++) {
38234             memviewslice->strides[i] = buf->strides[i];
38235         }
38236     } else {
38237         Py_ssize_t stride = buf->itemsize;
38238         for (i = ndim - 1; i >= 0; i--) {
38239             memviewslice->strides[i] = stride;
38240             stride *= buf->shape[i];
38241         }
38242     }
38243     for (i = 0; i < ndim; i++) {
38244         memviewslice->shape[i]   = buf->shape[i];
38245         if (buf->suboffsets) {
38246             memviewslice->suboffsets[i] = buf->suboffsets[i];
38247         } else {
38248             memviewslice->suboffsets[i] = -1;
38249         }
38250     }
38251     memviewslice->memview = memview;
38252     memviewslice->data = (char *)buf->buf;
38253     if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) {
38254         Py_INCREF(memview);
38255     }
38256     retval = 0;
38257     goto no_fail;
38258 fail:
38259     memviewslice->memview = 0;
38260     memviewslice->data = 0;
38261     retval = -1;
38262 no_fail:
38263     __Pyx_RefNannyFinishContext();
38264     return retval;
38265 }
38266 #ifndef Py_NO_RETURN
38267 #define Py_NO_RETURN
38268 #endif
__pyx_fatalerror(const char * fmt,...)38269 static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN {
38270     va_list vargs;
38271     char msg[200];
38272 #ifdef HAVE_STDARG_PROTOTYPES
38273     va_start(vargs, fmt);
38274 #else
38275     va_start(vargs);
38276 #endif
38277     vsnprintf(msg, 200, fmt, vargs);
38278     va_end(vargs);
38279     Py_FatalError(msg);
38280 }
38281 static CYTHON_INLINE int
__pyx_add_acquisition_count_locked(__pyx_atomic_int * acquisition_count,PyThread_type_lock lock)38282 __pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
38283                                    PyThread_type_lock lock)
38284 {
38285     int result;
38286     PyThread_acquire_lock(lock, 1);
38287     result = (*acquisition_count)++;
38288     PyThread_release_lock(lock);
38289     return result;
38290 }
38291 static CYTHON_INLINE int
__pyx_sub_acquisition_count_locked(__pyx_atomic_int * acquisition_count,PyThread_type_lock lock)38292 __pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
38293                                    PyThread_type_lock lock)
38294 {
38295     int result;
38296     PyThread_acquire_lock(lock, 1);
38297     result = (*acquisition_count)--;
38298     PyThread_release_lock(lock);
38299     return result;
38300 }
38301 static CYTHON_INLINE void
__Pyx_INC_MEMVIEW(__Pyx_memviewslice * memslice,int have_gil,int lineno)38302 __Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)
38303 {
38304     int first_time;
38305     struct __pyx_memoryview_obj *memview = memslice->memview;
38306     if (unlikely(!memview || (PyObject *) memview == Py_None))
38307         return;
38308     if (unlikely(__pyx_get_slice_count(memview) < 0))
38309         __pyx_fatalerror("Acquisition count is %d (line %d)",
38310                          __pyx_get_slice_count(memview), lineno);
38311     first_time = __pyx_add_acquisition_count(memview) == 0;
38312     if (unlikely(first_time)) {
38313         if (have_gil) {
38314             Py_INCREF((PyObject *) memview);
38315         } else {
38316             PyGILState_STATE _gilstate = PyGILState_Ensure();
38317             Py_INCREF((PyObject *) memview);
38318             PyGILState_Release(_gilstate);
38319         }
38320     }
38321 }
__Pyx_XDEC_MEMVIEW(__Pyx_memviewslice * memslice,int have_gil,int lineno)38322 static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
38323                                              int have_gil, int lineno) {
38324     int last_time;
38325     struct __pyx_memoryview_obj *memview = memslice->memview;
38326     if (unlikely(!memview || (PyObject *) memview == Py_None)) {
38327         memslice->memview = NULL;
38328         return;
38329     }
38330     if (unlikely(__pyx_get_slice_count(memview) <= 0))
38331         __pyx_fatalerror("Acquisition count is %d (line %d)",
38332                          __pyx_get_slice_count(memview), lineno);
38333     last_time = __pyx_sub_acquisition_count(memview) == 1;
38334     memslice->data = NULL;
38335     if (unlikely(last_time)) {
38336         if (have_gil) {
38337             Py_CLEAR(memslice->memview);
38338         } else {
38339             PyGILState_STATE _gilstate = PyGILState_Ensure();
38340             Py_CLEAR(memslice->memview);
38341             PyGILState_Release(_gilstate);
38342         }
38343     } else {
38344         memslice->memview = NULL;
38345     }
38346 }
38347 
38348 /* GetTopmostException */
38349 #if CYTHON_USE_EXC_INFO_STACK
38350 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)38351 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
38352 {
38353     _PyErr_StackItem *exc_info = tstate->exc_info;
38354     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
38355            exc_info->previous_item != NULL)
38356     {
38357         exc_info = exc_info->previous_item;
38358     }
38359     return exc_info;
38360 }
38361 #endif
38362 
38363 /* SaveResetException */
38364 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)38365 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
38366     #if CYTHON_USE_EXC_INFO_STACK
38367     _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
38368     *type = exc_info->exc_type;
38369     *value = exc_info->exc_value;
38370     *tb = exc_info->exc_traceback;
38371     #else
38372     *type = tstate->exc_type;
38373     *value = tstate->exc_value;
38374     *tb = tstate->exc_traceback;
38375     #endif
38376     Py_XINCREF(*type);
38377     Py_XINCREF(*value);
38378     Py_XINCREF(*tb);
38379 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)38380 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
38381     PyObject *tmp_type, *tmp_value, *tmp_tb;
38382     #if CYTHON_USE_EXC_INFO_STACK
38383     _PyErr_StackItem *exc_info = tstate->exc_info;
38384     tmp_type = exc_info->exc_type;
38385     tmp_value = exc_info->exc_value;
38386     tmp_tb = exc_info->exc_traceback;
38387     exc_info->exc_type = type;
38388     exc_info->exc_value = value;
38389     exc_info->exc_traceback = tb;
38390     #else
38391     tmp_type = tstate->exc_type;
38392     tmp_value = tstate->exc_value;
38393     tmp_tb = tstate->exc_traceback;
38394     tstate->exc_type = type;
38395     tstate->exc_value = value;
38396     tstate->exc_traceback = tb;
38397     #endif
38398     Py_XDECREF(tmp_type);
38399     Py_XDECREF(tmp_value);
38400     Py_XDECREF(tmp_tb);
38401 }
38402 #endif
38403 
38404 /* PyErrExceptionMatches */
38405 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)38406 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
38407     Py_ssize_t i, n;
38408     n = PyTuple_GET_SIZE(tuple);
38409 #if PY_MAJOR_VERSION >= 3
38410     for (i=0; i<n; i++) {
38411         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
38412     }
38413 #endif
38414     for (i=0; i<n; i++) {
38415         if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
38416     }
38417     return 0;
38418 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)38419 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
38420     PyObject *exc_type = tstate->curexc_type;
38421     if (exc_type == err) return 1;
38422     if (unlikely(!exc_type)) return 0;
38423     if (unlikely(PyTuple_Check(err)))
38424         return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
38425     return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
38426 }
38427 #endif
38428 
38429 /* GetException */
38430 #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)38431 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
38432 #else
38433 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
38434 #endif
38435 {
38436     PyObject *local_type, *local_value, *local_tb;
38437 #if CYTHON_FAST_THREAD_STATE
38438     PyObject *tmp_type, *tmp_value, *tmp_tb;
38439     local_type = tstate->curexc_type;
38440     local_value = tstate->curexc_value;
38441     local_tb = tstate->curexc_traceback;
38442     tstate->curexc_type = 0;
38443     tstate->curexc_value = 0;
38444     tstate->curexc_traceback = 0;
38445 #else
38446     PyErr_Fetch(&local_type, &local_value, &local_tb);
38447 #endif
38448     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
38449 #if CYTHON_FAST_THREAD_STATE
38450     if (unlikely(tstate->curexc_type))
38451 #else
38452     if (unlikely(PyErr_Occurred()))
38453 #endif
38454         goto bad;
38455     #if PY_MAJOR_VERSION >= 3
38456     if (local_tb) {
38457         if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
38458             goto bad;
38459     }
38460     #endif
38461     Py_XINCREF(local_tb);
38462     Py_XINCREF(local_type);
38463     Py_XINCREF(local_value);
38464     *type = local_type;
38465     *value = local_value;
38466     *tb = local_tb;
38467 #if CYTHON_FAST_THREAD_STATE
38468     #if CYTHON_USE_EXC_INFO_STACK
38469     {
38470         _PyErr_StackItem *exc_info = tstate->exc_info;
38471         tmp_type = exc_info->exc_type;
38472         tmp_value = exc_info->exc_value;
38473         tmp_tb = exc_info->exc_traceback;
38474         exc_info->exc_type = local_type;
38475         exc_info->exc_value = local_value;
38476         exc_info->exc_traceback = local_tb;
38477     }
38478     #else
38479     tmp_type = tstate->exc_type;
38480     tmp_value = tstate->exc_value;
38481     tmp_tb = tstate->exc_traceback;
38482     tstate->exc_type = local_type;
38483     tstate->exc_value = local_value;
38484     tstate->exc_traceback = local_tb;
38485     #endif
38486     Py_XDECREF(tmp_type);
38487     Py_XDECREF(tmp_value);
38488     Py_XDECREF(tmp_tb);
38489 #else
38490     PyErr_SetExcInfo(local_type, local_value, local_tb);
38491 #endif
38492     return 0;
38493 bad:
38494     *type = 0;
38495     *value = 0;
38496     *tb = 0;
38497     Py_XDECREF(local_type);
38498     Py_XDECREF(local_value);
38499     Py_XDECREF(local_tb);
38500     return -1;
38501 }
38502 
38503 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)38504 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
38505 {
38506     if (unlikely(!type)) {
38507         PyErr_SetString(PyExc_SystemError, "Missing type object");
38508         return 0;
38509     }
38510     else if (exact) {
38511         #if PY_MAJOR_VERSION == 2
38512         if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
38513         #endif
38514     }
38515     else {
38516         if (likely(__Pyx_TypeCheck(obj, type))) return 1;
38517     }
38518     PyErr_Format(PyExc_TypeError,
38519         "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
38520         name, type->tp_name, Py_TYPE(obj)->tp_name);
38521     return 0;
38522 }
38523 
38524 /* BytesEquals */
__Pyx_PyBytes_Equals(PyObject * s1,PyObject * s2,int equals)38525 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
38526 #if CYTHON_COMPILING_IN_PYPY
38527     return PyObject_RichCompareBool(s1, s2, equals);
38528 #else
38529     if (s1 == s2) {
38530         return (equals == Py_EQ);
38531     } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
38532         const char *ps1, *ps2;
38533         Py_ssize_t length = PyBytes_GET_SIZE(s1);
38534         if (length != PyBytes_GET_SIZE(s2))
38535             return (equals == Py_NE);
38536         ps1 = PyBytes_AS_STRING(s1);
38537         ps2 = PyBytes_AS_STRING(s2);
38538         if (ps1[0] != ps2[0]) {
38539             return (equals == Py_NE);
38540         } else if (length == 1) {
38541             return (equals == Py_EQ);
38542         } else {
38543             int result;
38544 #if CYTHON_USE_UNICODE_INTERNALS
38545             Py_hash_t hash1, hash2;
38546             hash1 = ((PyBytesObject*)s1)->ob_shash;
38547             hash2 = ((PyBytesObject*)s2)->ob_shash;
38548             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
38549                 return (equals == Py_NE);
38550             }
38551 #endif
38552             result = memcmp(ps1, ps2, (size_t)length);
38553             return (equals == Py_EQ) ? (result == 0) : (result != 0);
38554         }
38555     } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
38556         return (equals == Py_NE);
38557     } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
38558         return (equals == Py_NE);
38559     } else {
38560         int result;
38561         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
38562         if (!py_result)
38563             return -1;
38564         result = __Pyx_PyObject_IsTrue(py_result);
38565         Py_DECREF(py_result);
38566         return result;
38567     }
38568 #endif
38569 }
38570 
38571 /* UnicodeEquals */
__Pyx_PyUnicode_Equals(PyObject * s1,PyObject * s2,int equals)38572 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
38573 #if CYTHON_COMPILING_IN_PYPY
38574     return PyObject_RichCompareBool(s1, s2, equals);
38575 #else
38576 #if PY_MAJOR_VERSION < 3
38577     PyObject* owned_ref = NULL;
38578 #endif
38579     int s1_is_unicode, s2_is_unicode;
38580     if (s1 == s2) {
38581         goto return_eq;
38582     }
38583     s1_is_unicode = PyUnicode_CheckExact(s1);
38584     s2_is_unicode = PyUnicode_CheckExact(s2);
38585 #if PY_MAJOR_VERSION < 3
38586     if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
38587         owned_ref = PyUnicode_FromObject(s2);
38588         if (unlikely(!owned_ref))
38589             return -1;
38590         s2 = owned_ref;
38591         s2_is_unicode = 1;
38592     } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
38593         owned_ref = PyUnicode_FromObject(s1);
38594         if (unlikely(!owned_ref))
38595             return -1;
38596         s1 = owned_ref;
38597         s1_is_unicode = 1;
38598     } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
38599         return __Pyx_PyBytes_Equals(s1, s2, equals);
38600     }
38601 #endif
38602     if (s1_is_unicode & s2_is_unicode) {
38603         Py_ssize_t length;
38604         int kind;
38605         void *data1, *data2;
38606         if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
38607             return -1;
38608         length = __Pyx_PyUnicode_GET_LENGTH(s1);
38609         if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
38610             goto return_ne;
38611         }
38612 #if CYTHON_USE_UNICODE_INTERNALS
38613         {
38614             Py_hash_t hash1, hash2;
38615         #if CYTHON_PEP393_ENABLED
38616             hash1 = ((PyASCIIObject*)s1)->hash;
38617             hash2 = ((PyASCIIObject*)s2)->hash;
38618         #else
38619             hash1 = ((PyUnicodeObject*)s1)->hash;
38620             hash2 = ((PyUnicodeObject*)s2)->hash;
38621         #endif
38622             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
38623                 goto return_ne;
38624             }
38625         }
38626 #endif
38627         kind = __Pyx_PyUnicode_KIND(s1);
38628         if (kind != __Pyx_PyUnicode_KIND(s2)) {
38629             goto return_ne;
38630         }
38631         data1 = __Pyx_PyUnicode_DATA(s1);
38632         data2 = __Pyx_PyUnicode_DATA(s2);
38633         if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
38634             goto return_ne;
38635         } else if (length == 1) {
38636             goto return_eq;
38637         } else {
38638             int result = memcmp(data1, data2, (size_t)(length * kind));
38639             #if PY_MAJOR_VERSION < 3
38640             Py_XDECREF(owned_ref);
38641             #endif
38642             return (equals == Py_EQ) ? (result == 0) : (result != 0);
38643         }
38644     } else if ((s1 == Py_None) & s2_is_unicode) {
38645         goto return_ne;
38646     } else if ((s2 == Py_None) & s1_is_unicode) {
38647         goto return_ne;
38648     } else {
38649         int result;
38650         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
38651         #if PY_MAJOR_VERSION < 3
38652         Py_XDECREF(owned_ref);
38653         #endif
38654         if (!py_result)
38655             return -1;
38656         result = __Pyx_PyObject_IsTrue(py_result);
38657         Py_DECREF(py_result);
38658         return result;
38659     }
38660 return_eq:
38661     #if PY_MAJOR_VERSION < 3
38662     Py_XDECREF(owned_ref);
38663     #endif
38664     return (equals == Py_EQ);
38665 return_ne:
38666     #if PY_MAJOR_VERSION < 3
38667     Py_XDECREF(owned_ref);
38668     #endif
38669     return (equals == Py_NE);
38670 #endif
38671 }
38672 
38673 /* None */
__Pyx_div_Py_ssize_t(Py_ssize_t a,Py_ssize_t b)38674 static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
38675     Py_ssize_t q = a / b;
38676     Py_ssize_t r = a - q*b;
38677     q -= ((r != 0) & ((r ^ b) < 0));
38678     return q;
38679 }
38680 
38681 /* GetAttr */
__Pyx_GetAttr(PyObject * o,PyObject * n)38682 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
38683 #if CYTHON_USE_TYPE_SLOTS
38684 #if PY_MAJOR_VERSION >= 3
38685     if (likely(PyUnicode_Check(n)))
38686 #else
38687     if (likely(PyString_Check(n)))
38688 #endif
38689         return __Pyx_PyObject_GetAttrStr(o, n);
38690 #endif
38691     return PyObject_GetAttr(o, n);
38692 }
38693 
38694 /* ObjectGetItem */
38695 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetIndex(PyObject * obj,PyObject * index)38696 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
38697     PyObject *runerr;
38698     Py_ssize_t key_value;
38699     PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
38700     if (unlikely(!(m && m->sq_item))) {
38701         PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
38702         return NULL;
38703     }
38704     key_value = __Pyx_PyIndex_AsSsize_t(index);
38705     if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
38706         return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
38707     }
38708     if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
38709         PyErr_Clear();
38710         PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
38711     }
38712     return NULL;
38713 }
__Pyx_PyObject_GetItem(PyObject * obj,PyObject * key)38714 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
38715     PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
38716     if (likely(m && m->mp_subscript)) {
38717         return m->mp_subscript(obj, key);
38718     }
38719     return __Pyx_PyObject_GetIndex(obj, key);
38720 }
38721 #endif
38722 
38723 /* 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))38724 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
38725          const char* cstring, Py_ssize_t start, Py_ssize_t stop,
38726          const char* encoding, const char* errors,
38727          PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
38728     Py_ssize_t length;
38729     if (unlikely((start < 0) | (stop < 0))) {
38730         size_t slen = strlen(cstring);
38731         if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
38732             PyErr_SetString(PyExc_OverflowError,
38733                             "c-string too long to convert to Python");
38734             return NULL;
38735         }
38736         length = (Py_ssize_t) slen;
38737         if (start < 0) {
38738             start += length;
38739             if (start < 0)
38740                 start = 0;
38741         }
38742         if (stop < 0)
38743             stop += length;
38744     }
38745     if (unlikely(stop <= start))
38746         return __Pyx_NewRef(__pyx_empty_unicode);
38747     length = stop - start;
38748     cstring += start;
38749     if (decode_func) {
38750         return decode_func(cstring, length, errors);
38751     } else {
38752         return PyUnicode_Decode(cstring, length, encoding, errors);
38753     }
38754 }
38755 
38756 /* GetAttr3 */
__Pyx_GetAttr3Default(PyObject * d)38757 static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
38758     __Pyx_PyThreadState_declare
38759     __Pyx_PyThreadState_assign
38760     if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
38761         return NULL;
38762     __Pyx_PyErr_Clear();
38763     Py_INCREF(d);
38764     return d;
38765 }
__Pyx_GetAttr3(PyObject * o,PyObject * n,PyObject * d)38766 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
38767     PyObject *r = __Pyx_GetAttr(o, n);
38768     return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
38769 }
38770 
38771 /* SwapException */
38772 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSwap(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)38773 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
38774     PyObject *tmp_type, *tmp_value, *tmp_tb;
38775     #if CYTHON_USE_EXC_INFO_STACK
38776     _PyErr_StackItem *exc_info = tstate->exc_info;
38777     tmp_type = exc_info->exc_type;
38778     tmp_value = exc_info->exc_value;
38779     tmp_tb = exc_info->exc_traceback;
38780     exc_info->exc_type = *type;
38781     exc_info->exc_value = *value;
38782     exc_info->exc_traceback = *tb;
38783     #else
38784     tmp_type = tstate->exc_type;
38785     tmp_value = tstate->exc_value;
38786     tmp_tb = tstate->exc_traceback;
38787     tstate->exc_type = *type;
38788     tstate->exc_value = *value;
38789     tstate->exc_traceback = *tb;
38790     #endif
38791     *type = tmp_type;
38792     *value = tmp_value;
38793     *tb = tmp_tb;
38794 }
38795 #else
__Pyx_ExceptionSwap(PyObject ** type,PyObject ** value,PyObject ** tb)38796 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
38797     PyObject *tmp_type, *tmp_value, *tmp_tb;
38798     PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
38799     PyErr_SetExcInfo(*type, *value, *tb);
38800     *type = tmp_type;
38801     *value = tmp_value;
38802     *tb = tmp_tb;
38803 }
38804 #endif
38805 
38806 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)38807 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
38808     PyObject *empty_list = 0;
38809     PyObject *module = 0;
38810     PyObject *global_dict = 0;
38811     PyObject *empty_dict = 0;
38812     PyObject *list;
38813     #if PY_MAJOR_VERSION < 3
38814     PyObject *py_import;
38815     py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
38816     if (!py_import)
38817         goto bad;
38818     #endif
38819     if (from_list)
38820         list = from_list;
38821     else {
38822         empty_list = PyList_New(0);
38823         if (!empty_list)
38824             goto bad;
38825         list = empty_list;
38826     }
38827     global_dict = PyModule_GetDict(__pyx_m);
38828     if (!global_dict)
38829         goto bad;
38830     empty_dict = PyDict_New();
38831     if (!empty_dict)
38832         goto bad;
38833     {
38834         #if PY_MAJOR_VERSION >= 3
38835         if (level == -1) {
38836             if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
38837                 module = PyImport_ImportModuleLevelObject(
38838                     name, global_dict, empty_dict, list, 1);
38839                 if (!module) {
38840                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
38841                         goto bad;
38842                     PyErr_Clear();
38843                 }
38844             }
38845             level = 0;
38846         }
38847         #endif
38848         if (!module) {
38849             #if PY_MAJOR_VERSION < 3
38850             PyObject *py_level = PyInt_FromLong(level);
38851             if (!py_level)
38852                 goto bad;
38853             module = PyObject_CallFunctionObjArgs(py_import,
38854                 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
38855             Py_DECREF(py_level);
38856             #else
38857             module = PyImport_ImportModuleLevelObject(
38858                 name, global_dict, empty_dict, list, level);
38859             #endif
38860         }
38861     }
38862 bad:
38863     #if PY_MAJOR_VERSION < 3
38864     Py_XDECREF(py_import);
38865     #endif
38866     Py_XDECREF(empty_list);
38867     Py_XDECREF(empty_dict);
38868     return module;
38869 }
38870 
38871 /* FastTypeChecks */
38872 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)38873 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
38874     while (a) {
38875         a = a->tp_base;
38876         if (a == b)
38877             return 1;
38878     }
38879     return b == &PyBaseObject_Type;
38880 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)38881 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
38882     PyObject *mro;
38883     if (a == b) return 1;
38884     mro = a->tp_mro;
38885     if (likely(mro)) {
38886         Py_ssize_t i, n;
38887         n = PyTuple_GET_SIZE(mro);
38888         for (i = 0; i < n; i++) {
38889             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
38890                 return 1;
38891         }
38892         return 0;
38893     }
38894     return __Pyx_InBases(a, b);
38895 }
38896 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)38897 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
38898     PyObject *exception, *value, *tb;
38899     int res;
38900     __Pyx_PyThreadState_declare
38901     __Pyx_PyThreadState_assign
38902     __Pyx_ErrFetch(&exception, &value, &tb);
38903     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
38904     if (unlikely(res == -1)) {
38905         PyErr_WriteUnraisable(err);
38906         res = 0;
38907     }
38908     if (!res) {
38909         res = PyObject_IsSubclass(err, exc_type2);
38910         if (unlikely(res == -1)) {
38911             PyErr_WriteUnraisable(err);
38912             res = 0;
38913         }
38914     }
38915     __Pyx_ErrRestore(exception, value, tb);
38916     return res;
38917 }
38918 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)38919 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
38920     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
38921     if (!res) {
38922         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
38923     }
38924     return res;
38925 }
38926 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)38927 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
38928     Py_ssize_t i, n;
38929     assert(PyExceptionClass_Check(exc_type));
38930     n = PyTuple_GET_SIZE(tuple);
38931 #if PY_MAJOR_VERSION >= 3
38932     for (i=0; i<n; i++) {
38933         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
38934     }
38935 #endif
38936     for (i=0; i<n; i++) {
38937         PyObject *t = PyTuple_GET_ITEM(tuple, i);
38938         #if PY_MAJOR_VERSION < 3
38939         if (likely(exc_type == t)) return 1;
38940         #endif
38941         if (likely(PyExceptionClass_Check(t))) {
38942             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
38943         } else {
38944         }
38945     }
38946     return 0;
38947 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)38948 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
38949     if (likely(err == exc_type)) return 1;
38950     if (likely(PyExceptionClass_Check(err))) {
38951         if (likely(PyExceptionClass_Check(exc_type))) {
38952             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
38953         } else if (likely(PyTuple_Check(exc_type))) {
38954             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
38955         } else {
38956         }
38957     }
38958     return PyErr_GivenExceptionMatches(err, exc_type);
38959 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)38960 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
38961     assert(PyExceptionClass_Check(exc_type1));
38962     assert(PyExceptionClass_Check(exc_type2));
38963     if (likely(err == exc_type1 || err == exc_type2)) return 1;
38964     if (likely(PyExceptionClass_Check(err))) {
38965         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
38966     }
38967     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
38968 }
38969 #endif
38970 
38971 /* PyIntBinop */
38972 #if !CYTHON_COMPILING_IN_PYPY
__Pyx_PyInt_AddObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,int inplace,int zerodivision_check)38973 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
38974     (void)inplace;
38975     (void)zerodivision_check;
38976     #if PY_MAJOR_VERSION < 3
38977     if (likely(PyInt_CheckExact(op1))) {
38978         const long b = intval;
38979         long x;
38980         long a = PyInt_AS_LONG(op1);
38981             x = (long)((unsigned long)a + b);
38982             if (likely((x^a) >= 0 || (x^b) >= 0))
38983                 return PyInt_FromLong(x);
38984             return PyLong_Type.tp_as_number->nb_add(op1, op2);
38985     }
38986     #endif
38987     #if CYTHON_USE_PYLONG_INTERNALS
38988     if (likely(PyLong_CheckExact(op1))) {
38989         const long b = intval;
38990         long a, x;
38991 #ifdef HAVE_LONG_LONG
38992         const PY_LONG_LONG llb = intval;
38993         PY_LONG_LONG lla, llx;
38994 #endif
38995         const digit* digits = ((PyLongObject*)op1)->ob_digit;
38996         const Py_ssize_t size = Py_SIZE(op1);
38997         if (likely(__Pyx_sst_abs(size) <= 1)) {
38998             a = likely(size) ? digits[0] : 0;
38999             if (size == -1) a = -a;
39000         } else {
39001             switch (size) {
39002                 case -2:
39003                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
39004                         a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
39005                         break;
39006 #ifdef HAVE_LONG_LONG
39007                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
39008                         lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
39009                         goto long_long;
39010 #endif
39011                     }
39012                     CYTHON_FALLTHROUGH;
39013                 case 2:
39014                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
39015                         a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
39016                         break;
39017 #ifdef HAVE_LONG_LONG
39018                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
39019                         lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
39020                         goto long_long;
39021 #endif
39022                     }
39023                     CYTHON_FALLTHROUGH;
39024                 case -3:
39025                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
39026                         a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
39027                         break;
39028 #ifdef HAVE_LONG_LONG
39029                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
39030                         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]));
39031                         goto long_long;
39032 #endif
39033                     }
39034                     CYTHON_FALLTHROUGH;
39035                 case 3:
39036                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
39037                         a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
39038                         break;
39039 #ifdef HAVE_LONG_LONG
39040                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
39041                         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]));
39042                         goto long_long;
39043 #endif
39044                     }
39045                     CYTHON_FALLTHROUGH;
39046                 case -4:
39047                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
39048                         a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
39049                         break;
39050 #ifdef HAVE_LONG_LONG
39051                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
39052                         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]));
39053                         goto long_long;
39054 #endif
39055                     }
39056                     CYTHON_FALLTHROUGH;
39057                 case 4:
39058                     if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
39059                         a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
39060                         break;
39061 #ifdef HAVE_LONG_LONG
39062                     } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
39063                         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]));
39064                         goto long_long;
39065 #endif
39066                     }
39067                     CYTHON_FALLTHROUGH;
39068                 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
39069             }
39070         }
39071                 x = a + b;
39072             return PyLong_FromLong(x);
39073 #ifdef HAVE_LONG_LONG
39074         long_long:
39075                 llx = lla + llb;
39076             return PyLong_FromLongLong(llx);
39077 #endif
39078 
39079 
39080     }
39081     #endif
39082     if (PyFloat_CheckExact(op1)) {
39083         const long b = intval;
39084         double a = PyFloat_AS_DOUBLE(op1);
39085             double result;
39086             PyFPE_START_PROTECT("add", return NULL)
39087             result = ((double)a) + (double)b;
39088             PyFPE_END_PROTECT(result)
39089             return PyFloat_FromDouble(result);
39090     }
39091     return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
39092 }
39093 #endif
39094 
39095 /* None */
__Pyx_div_long(long a,long b)39096 static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
39097     long q = a / b;
39098     long r = a - q*b;
39099     q -= ((r != 0) & ((r ^ b) < 0));
39100     return q;
39101 }
39102 
39103 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)39104 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
39105     PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
39106     if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
39107         PyErr_Format(PyExc_ImportError,
39108         #if PY_MAJOR_VERSION < 3
39109             "cannot import name %.230s", PyString_AS_STRING(name));
39110         #else
39111             "cannot import name %S", name);
39112         #endif
39113     }
39114     return value;
39115 }
39116 
39117 /* HasAttr */
__Pyx_HasAttr(PyObject * o,PyObject * n)39118 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
39119     PyObject *r;
39120     if (unlikely(!__Pyx_PyBaseString_Check(n))) {
39121         PyErr_SetString(PyExc_TypeError,
39122                         "hasattr(): attribute name must be string");
39123         return -1;
39124     }
39125     r = __Pyx_GetAttr(o, n);
39126     if (unlikely(!r)) {
39127         PyErr_Clear();
39128         return 0;
39129     } else {
39130         Py_DECREF(r);
39131         return 1;
39132     }
39133 }
39134 
39135 /* PyObject_GenericGetAttrNoDict */
39136 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)39137 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
39138     PyErr_Format(PyExc_AttributeError,
39139 #if PY_MAJOR_VERSION >= 3
39140                  "'%.50s' object has no attribute '%U'",
39141                  tp->tp_name, attr_name);
39142 #else
39143                  "'%.50s' object has no attribute '%.400s'",
39144                  tp->tp_name, PyString_AS_STRING(attr_name));
39145 #endif
39146     return NULL;
39147 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)39148 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
39149     PyObject *descr;
39150     PyTypeObject *tp = Py_TYPE(obj);
39151     if (unlikely(!PyString_Check(attr_name))) {
39152         return PyObject_GenericGetAttr(obj, attr_name);
39153     }
39154     assert(!tp->tp_dictoffset);
39155     descr = _PyType_Lookup(tp, attr_name);
39156     if (unlikely(!descr)) {
39157         return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
39158     }
39159     Py_INCREF(descr);
39160     #if PY_MAJOR_VERSION < 3
39161     if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
39162     #endif
39163     {
39164         descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
39165         if (unlikely(f)) {
39166             PyObject *res = f(descr, obj, (PyObject *)tp);
39167             Py_DECREF(descr);
39168             return res;
39169         }
39170     }
39171     return descr;
39172 }
39173 #endif
39174 
39175 /* PyObject_GenericGetAttr */
39176 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)39177 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
39178     if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
39179         return PyObject_GenericGetAttr(obj, attr_name);
39180     }
39181     return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
39182 }
39183 #endif
39184 
39185 /* SetVTable */
__Pyx_SetVtable(PyObject * dict,void * vtable)39186 static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
39187 #if PY_VERSION_HEX >= 0x02070000
39188     PyObject *ob = PyCapsule_New(vtable, 0, 0);
39189 #else
39190     PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
39191 #endif
39192     if (!ob)
39193         goto bad;
39194     if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
39195         goto bad;
39196     Py_DECREF(ob);
39197     return 0;
39198 bad:
39199     Py_XDECREF(ob);
39200     return -1;
39201 }
39202 
39203 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)39204 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
39205     __Pyx_PyThreadState_declare
39206     __Pyx_PyThreadState_assign
39207     if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
39208         __Pyx_PyErr_Clear();
39209 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)39210 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
39211     PyObject *result;
39212 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
39213     PyTypeObject* tp = Py_TYPE(obj);
39214     if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
39215         return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
39216     }
39217 #endif
39218     result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
39219     if (unlikely(!result)) {
39220         __Pyx_PyObject_GetAttrStr_ClearAttributeError();
39221     }
39222     return result;
39223 }
39224 
39225 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)39226 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
39227   int ret;
39228   PyObject *name_attr;
39229   name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
39230   if (likely(name_attr)) {
39231       ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
39232   } else {
39233       ret = -1;
39234   }
39235   if (unlikely(ret < 0)) {
39236       PyErr_Clear();
39237       ret = 0;
39238   }
39239   Py_XDECREF(name_attr);
39240   return ret;
39241 }
__Pyx_setup_reduce(PyObject * type_obj)39242 static int __Pyx_setup_reduce(PyObject* type_obj) {
39243     int ret = 0;
39244     PyObject *object_reduce = NULL;
39245     PyObject *object_reduce_ex = NULL;
39246     PyObject *reduce = NULL;
39247     PyObject *reduce_ex = NULL;
39248     PyObject *reduce_cython = NULL;
39249     PyObject *setstate = NULL;
39250     PyObject *setstate_cython = NULL;
39251 #if CYTHON_USE_PYTYPE_LOOKUP
39252     if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
39253 #else
39254     if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
39255 #endif
39256 #if CYTHON_USE_PYTYPE_LOOKUP
39257     object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
39258 #else
39259     object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
39260 #endif
39261     reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
39262     if (reduce_ex == object_reduce_ex) {
39263 #if CYTHON_USE_PYTYPE_LOOKUP
39264         object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
39265 #else
39266         object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
39267 #endif
39268         reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
39269         if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
39270             reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
39271             if (likely(reduce_cython)) {
39272                 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
39273                 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
39274             } else if (reduce == object_reduce || PyErr_Occurred()) {
39275                 goto __PYX_BAD;
39276             }
39277             setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
39278             if (!setstate) PyErr_Clear();
39279             if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
39280                 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
39281                 if (likely(setstate_cython)) {
39282                     ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
39283                     ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
39284                 } else if (!setstate || PyErr_Occurred()) {
39285                     goto __PYX_BAD;
39286                 }
39287             }
39288             PyType_Modified((PyTypeObject*)type_obj);
39289         }
39290     }
39291     goto __PYX_GOOD;
39292 __PYX_BAD:
39293     if (!PyErr_Occurred())
39294         PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
39295     ret = -1;
39296 __PYX_GOOD:
39297 #if !CYTHON_USE_PYTYPE_LOOKUP
39298     Py_XDECREF(object_reduce);
39299     Py_XDECREF(object_reduce_ex);
39300 #endif
39301     Py_XDECREF(reduce);
39302     Py_XDECREF(reduce_ex);
39303     Py_XDECREF(reduce_cython);
39304     Py_XDECREF(setstate);
39305     Py_XDECREF(setstate_cython);
39306     return ret;
39307 }
39308 
39309 /* TypeImport */
39310 #ifndef __PYX_HAVE_RT_ImportType
39311 #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)39312 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
39313     size_t size, enum __Pyx_ImportType_CheckSize check_size)
39314 {
39315     PyObject *result = 0;
39316     char warning[200];
39317     Py_ssize_t basicsize;
39318 #ifdef Py_LIMITED_API
39319     PyObject *py_basicsize;
39320 #endif
39321     result = PyObject_GetAttrString(module, class_name);
39322     if (!result)
39323         goto bad;
39324     if (!PyType_Check(result)) {
39325         PyErr_Format(PyExc_TypeError,
39326             "%.200s.%.200s is not a type object",
39327             module_name, class_name);
39328         goto bad;
39329     }
39330 #ifndef Py_LIMITED_API
39331     basicsize = ((PyTypeObject *)result)->tp_basicsize;
39332 #else
39333     py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
39334     if (!py_basicsize)
39335         goto bad;
39336     basicsize = PyLong_AsSsize_t(py_basicsize);
39337     Py_DECREF(py_basicsize);
39338     py_basicsize = 0;
39339     if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
39340         goto bad;
39341 #endif
39342     if ((size_t)basicsize < size) {
39343         PyErr_Format(PyExc_ValueError,
39344             "%.200s.%.200s size changed, may indicate binary incompatibility. "
39345             "Expected %zd from C header, got %zd from PyObject",
39346             module_name, class_name, size, basicsize);
39347         goto bad;
39348     }
39349     if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
39350         PyErr_Format(PyExc_ValueError,
39351             "%.200s.%.200s size changed, may indicate binary incompatibility. "
39352             "Expected %zd from C header, got %zd from PyObject",
39353             module_name, class_name, size, basicsize);
39354         goto bad;
39355     }
39356     else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
39357         PyOS_snprintf(warning, sizeof(warning),
39358             "%s.%s size changed, may indicate binary incompatibility. "
39359             "Expected %zd from C header, got %zd from PyObject",
39360             module_name, class_name, size, basicsize);
39361         if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
39362     }
39363     return (PyTypeObject *)result;
39364 bad:
39365     Py_XDECREF(result);
39366     return NULL;
39367 }
39368 #endif
39369 
39370 /* FetchCommonType */
__Pyx_FetchCommonType(PyTypeObject * type)39371 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
39372     PyObject* fake_module;
39373     PyTypeObject* cached_type = NULL;
39374     fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
39375     if (!fake_module) return NULL;
39376     Py_INCREF(fake_module);
39377     cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
39378     if (cached_type) {
39379         if (!PyType_Check((PyObject*)cached_type)) {
39380             PyErr_Format(PyExc_TypeError,
39381                 "Shared Cython type %.200s is not a type object",
39382                 type->tp_name);
39383             goto bad;
39384         }
39385         if (cached_type->tp_basicsize != type->tp_basicsize) {
39386             PyErr_Format(PyExc_TypeError,
39387                 "Shared Cython type %.200s has the wrong size, try recompiling",
39388                 type->tp_name);
39389             goto bad;
39390         }
39391     } else {
39392         if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
39393         PyErr_Clear();
39394         if (PyType_Ready(type) < 0) goto bad;
39395         if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
39396             goto bad;
39397         Py_INCREF(type);
39398         cached_type = type;
39399     }
39400 done:
39401     Py_DECREF(fake_module);
39402     return cached_type;
39403 bad:
39404     Py_XDECREF(cached_type);
39405     cached_type = NULL;
39406     goto done;
39407 }
39408 
39409 /* CythonFunctionShared */
39410 #include <structmember.h>
39411 static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * closure)39412 __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
39413 {
39414     if (unlikely(op->func_doc == NULL)) {
39415         if (op->func.m_ml->ml_doc) {
39416 #if PY_MAJOR_VERSION >= 3
39417             op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
39418 #else
39419             op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
39420 #endif
39421             if (unlikely(op->func_doc == NULL))
39422                 return NULL;
39423         } else {
39424             Py_INCREF(Py_None);
39425             return Py_None;
39426         }
39427     }
39428     Py_INCREF(op->func_doc);
39429     return op->func_doc;
39430 }
39431 static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)39432 __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
39433 {
39434     PyObject *tmp = op->func_doc;
39435     if (value == NULL) {
39436         value = Py_None;
39437     }
39438     Py_INCREF(value);
39439     op->func_doc = value;
39440     Py_XDECREF(tmp);
39441     return 0;
39442 }
39443 static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)39444 __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
39445 {
39446     if (unlikely(op->func_name == NULL)) {
39447 #if PY_MAJOR_VERSION >= 3
39448         op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
39449 #else
39450         op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
39451 #endif
39452         if (unlikely(op->func_name == NULL))
39453             return NULL;
39454     }
39455     Py_INCREF(op->func_name);
39456     return op->func_name;
39457 }
39458 static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)39459 __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
39460 {
39461     PyObject *tmp;
39462 #if PY_MAJOR_VERSION >= 3
39463     if (unlikely(value == NULL || !PyUnicode_Check(value)))
39464 #else
39465     if (unlikely(value == NULL || !PyString_Check(value)))
39466 #endif
39467     {
39468         PyErr_SetString(PyExc_TypeError,
39469                         "__name__ must be set to a string object");
39470         return -1;
39471     }
39472     tmp = op->func_name;
39473     Py_INCREF(value);
39474     op->func_name = value;
39475     Py_XDECREF(tmp);
39476     return 0;
39477 }
39478 static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)39479 __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
39480 {
39481     Py_INCREF(op->func_qualname);
39482     return op->func_qualname;
39483 }
39484 static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)39485 __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
39486 {
39487     PyObject *tmp;
39488 #if PY_MAJOR_VERSION >= 3
39489     if (unlikely(value == NULL || !PyUnicode_Check(value)))
39490 #else
39491     if (unlikely(value == NULL || !PyString_Check(value)))
39492 #endif
39493     {
39494         PyErr_SetString(PyExc_TypeError,
39495                         "__qualname__ must be set to a string object");
39496         return -1;
39497     }
39498     tmp = op->func_qualname;
39499     Py_INCREF(value);
39500     op->func_qualname = value;
39501     Py_XDECREF(tmp);
39502     return 0;
39503 }
39504 static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject * m,CYTHON_UNUSED void * closure)39505 __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
39506 {
39507     PyObject *self;
39508     self = m->func_closure;
39509     if (self == NULL)
39510         self = Py_None;
39511     Py_INCREF(self);
39512     return self;
39513 }
39514 static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)39515 __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
39516 {
39517     if (unlikely(op->func_dict == NULL)) {
39518         op->func_dict = PyDict_New();
39519         if (unlikely(op->func_dict == NULL))
39520             return NULL;
39521     }
39522     Py_INCREF(op->func_dict);
39523     return op->func_dict;
39524 }
39525 static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)39526 __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
39527 {
39528     PyObject *tmp;
39529     if (unlikely(value == NULL)) {
39530         PyErr_SetString(PyExc_TypeError,
39531                "function's dictionary may not be deleted");
39532         return -1;
39533     }
39534     if (unlikely(!PyDict_Check(value))) {
39535         PyErr_SetString(PyExc_TypeError,
39536                "setting function's dictionary to a non-dict");
39537         return -1;
39538     }
39539     tmp = op->func_dict;
39540     Py_INCREF(value);
39541     op->func_dict = value;
39542     Py_XDECREF(tmp);
39543     return 0;
39544 }
39545 static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)39546 __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
39547 {
39548     Py_INCREF(op->func_globals);
39549     return op->func_globals;
39550 }
39551 static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)39552 __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
39553 {
39554     Py_INCREF(Py_None);
39555     return Py_None;
39556 }
39557 static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)39558 __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
39559 {
39560     PyObject* result = (op->func_code) ? op->func_code : Py_None;
39561     Py_INCREF(result);
39562     return result;
39563 }
39564 static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject * op)39565 __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
39566     int result = 0;
39567     PyObject *res = op->defaults_getter((PyObject *) op);
39568     if (unlikely(!res))
39569         return -1;
39570     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
39571     op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
39572     Py_INCREF(op->defaults_tuple);
39573     op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
39574     Py_INCREF(op->defaults_kwdict);
39575     #else
39576     op->defaults_tuple = PySequence_ITEM(res, 0);
39577     if (unlikely(!op->defaults_tuple)) result = -1;
39578     else {
39579         op->defaults_kwdict = PySequence_ITEM(res, 1);
39580         if (unlikely(!op->defaults_kwdict)) result = -1;
39581     }
39582     #endif
39583     Py_DECREF(res);
39584     return result;
39585 }
39586 static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)39587 __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
39588     PyObject* tmp;
39589     if (!value) {
39590         value = Py_None;
39591     } else if (value != Py_None && !PyTuple_Check(value)) {
39592         PyErr_SetString(PyExc_TypeError,
39593                         "__defaults__ must be set to a tuple object");
39594         return -1;
39595     }
39596     Py_INCREF(value);
39597     tmp = op->defaults_tuple;
39598     op->defaults_tuple = value;
39599     Py_XDECREF(tmp);
39600     return 0;
39601 }
39602 static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)39603 __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
39604     PyObject* result = op->defaults_tuple;
39605     if (unlikely(!result)) {
39606         if (op->defaults_getter) {
39607             if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
39608             result = op->defaults_tuple;
39609         } else {
39610             result = Py_None;
39611         }
39612     }
39613     Py_INCREF(result);
39614     return result;
39615 }
39616 static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)39617 __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
39618     PyObject* tmp;
39619     if (!value) {
39620         value = Py_None;
39621     } else if (value != Py_None && !PyDict_Check(value)) {
39622         PyErr_SetString(PyExc_TypeError,
39623                         "__kwdefaults__ must be set to a dict object");
39624         return -1;
39625     }
39626     Py_INCREF(value);
39627     tmp = op->defaults_kwdict;
39628     op->defaults_kwdict = value;
39629     Py_XDECREF(tmp);
39630     return 0;
39631 }
39632 static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)39633 __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
39634     PyObject* result = op->defaults_kwdict;
39635     if (unlikely(!result)) {
39636         if (op->defaults_getter) {
39637             if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
39638             result = op->defaults_kwdict;
39639         } else {
39640             result = Py_None;
39641         }
39642     }
39643     Py_INCREF(result);
39644     return result;
39645 }
39646 static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)39647 __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
39648     PyObject* tmp;
39649     if (!value || value == Py_None) {
39650         value = NULL;
39651     } else if (!PyDict_Check(value)) {
39652         PyErr_SetString(PyExc_TypeError,
39653                         "__annotations__ must be set to a dict object");
39654         return -1;
39655     }
39656     Py_XINCREF(value);
39657     tmp = op->func_annotations;
39658     op->func_annotations = value;
39659     Py_XDECREF(tmp);
39660     return 0;
39661 }
39662 static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)39663 __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
39664     PyObject* result = op->func_annotations;
39665     if (unlikely(!result)) {
39666         result = PyDict_New();
39667         if (unlikely(!result)) return NULL;
39668         op->func_annotations = result;
39669     }
39670     Py_INCREF(result);
39671     return result;
39672 }
39673 static PyGetSetDef __pyx_CyFunction_getsets[] = {
39674     {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
39675     {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
39676     {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
39677     {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
39678     {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
39679     {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
39680     {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
39681     {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
39682     {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
39683     {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
39684     {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
39685     {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
39686     {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
39687     {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
39688     {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
39689     {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
39690     {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
39691     {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
39692     {0, 0, 0, 0, 0}
39693 };
39694 static PyMemberDef __pyx_CyFunction_members[] = {
39695     {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
39696     {0, 0, 0,  0, 0}
39697 };
39698 static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject * m,CYTHON_UNUSED PyObject * args)39699 __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
39700 {
39701 #if PY_MAJOR_VERSION >= 3
39702     return PyUnicode_FromString(m->func.m_ml->ml_name);
39703 #else
39704     return PyString_FromString(m->func.m_ml->ml_name);
39705 #endif
39706 }
39707 static PyMethodDef __pyx_CyFunction_methods[] = {
39708     {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
39709     {0, 0, 0, 0}
39710 };
39711 #if PY_VERSION_HEX < 0x030500A0
39712 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
39713 #else
39714 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
39715 #endif
__Pyx_CyFunction_Init(__pyx_CyFunctionObject * op,PyMethodDef * ml,int flags,PyObject * qualname,PyObject * closure,PyObject * module,PyObject * globals,PyObject * code)39716 static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
39717                                        PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
39718     if (unlikely(op == NULL))
39719         return NULL;
39720     op->flags = flags;
39721     __Pyx_CyFunction_weakreflist(op) = NULL;
39722     op->func.m_ml = ml;
39723     op->func.m_self = (PyObject *) op;
39724     Py_XINCREF(closure);
39725     op->func_closure = closure;
39726     Py_XINCREF(module);
39727     op->func.m_module = module;
39728     op->func_dict = NULL;
39729     op->func_name = NULL;
39730     Py_INCREF(qualname);
39731     op->func_qualname = qualname;
39732     op->func_doc = NULL;
39733     op->func_classobj = NULL;
39734     op->func_globals = globals;
39735     Py_INCREF(op->func_globals);
39736     Py_XINCREF(code);
39737     op->func_code = code;
39738     op->defaults_pyobjects = 0;
39739     op->defaults_size = 0;
39740     op->defaults = NULL;
39741     op->defaults_tuple = NULL;
39742     op->defaults_kwdict = NULL;
39743     op->defaults_getter = NULL;
39744     op->func_annotations = NULL;
39745     return (PyObject *) op;
39746 }
39747 static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject * m)39748 __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
39749 {
39750     Py_CLEAR(m->func_closure);
39751     Py_CLEAR(m->func.m_module);
39752     Py_CLEAR(m->func_dict);
39753     Py_CLEAR(m->func_name);
39754     Py_CLEAR(m->func_qualname);
39755     Py_CLEAR(m->func_doc);
39756     Py_CLEAR(m->func_globals);
39757     Py_CLEAR(m->func_code);
39758     Py_CLEAR(m->func_classobj);
39759     Py_CLEAR(m->defaults_tuple);
39760     Py_CLEAR(m->defaults_kwdict);
39761     Py_CLEAR(m->func_annotations);
39762     if (m->defaults) {
39763         PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
39764         int i;
39765         for (i = 0; i < m->defaults_pyobjects; i++)
39766             Py_XDECREF(pydefaults[i]);
39767         PyObject_Free(m->defaults);
39768         m->defaults = NULL;
39769     }
39770     return 0;
39771 }
__Pyx__CyFunction_dealloc(__pyx_CyFunctionObject * m)39772 static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
39773 {
39774     if (__Pyx_CyFunction_weakreflist(m) != NULL)
39775         PyObject_ClearWeakRefs((PyObject *) m);
39776     __Pyx_CyFunction_clear(m);
39777     PyObject_GC_Del(m);
39778 }
__Pyx_CyFunction_dealloc(__pyx_CyFunctionObject * m)39779 static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
39780 {
39781     PyObject_GC_UnTrack(m);
39782     __Pyx__CyFunction_dealloc(m);
39783 }
__Pyx_CyFunction_traverse(__pyx_CyFunctionObject * m,visitproc visit,void * arg)39784 static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
39785 {
39786     Py_VISIT(m->func_closure);
39787     Py_VISIT(m->func.m_module);
39788     Py_VISIT(m->func_dict);
39789     Py_VISIT(m->func_name);
39790     Py_VISIT(m->func_qualname);
39791     Py_VISIT(m->func_doc);
39792     Py_VISIT(m->func_globals);
39793     Py_VISIT(m->func_code);
39794     Py_VISIT(m->func_classobj);
39795     Py_VISIT(m->defaults_tuple);
39796     Py_VISIT(m->defaults_kwdict);
39797     if (m->defaults) {
39798         PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
39799         int i;
39800         for (i = 0; i < m->defaults_pyobjects; i++)
39801             Py_VISIT(pydefaults[i]);
39802     }
39803     return 0;
39804 }
__Pyx_CyFunction_descr_get(PyObject * func,PyObject * obj,PyObject * type)39805 static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
39806 {
39807 #if PY_MAJOR_VERSION < 3
39808     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
39809     if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
39810         Py_INCREF(func);
39811         return func;
39812     }
39813     if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
39814         if (type == NULL)
39815             type = (PyObject *)(Py_TYPE(obj));
39816         return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
39817     }
39818     if (obj == Py_None)
39819         obj = NULL;
39820 #endif
39821     return __Pyx_PyMethod_New(func, obj, type);
39822 }
39823 static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject * op)39824 __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
39825 {
39826 #if PY_MAJOR_VERSION >= 3
39827     return PyUnicode_FromFormat("<cyfunction %U at %p>",
39828                                 op->func_qualname, (void *)op);
39829 #else
39830     return PyString_FromFormat("<cyfunction %s at %p>",
39831                                PyString_AsString(op->func_qualname), (void *)op);
39832 #endif
39833 }
__Pyx_CyFunction_CallMethod(PyObject * func,PyObject * self,PyObject * arg,PyObject * kw)39834 static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
39835     PyCFunctionObject* f = (PyCFunctionObject*)func;
39836     PyCFunction meth = f->m_ml->ml_meth;
39837     Py_ssize_t size;
39838     switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
39839     case METH_VARARGS:
39840         if (likely(kw == NULL || PyDict_Size(kw) == 0))
39841             return (*meth)(self, arg);
39842         break;
39843     case METH_VARARGS | METH_KEYWORDS:
39844         return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
39845     case METH_NOARGS:
39846         if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
39847             size = PyTuple_GET_SIZE(arg);
39848             if (likely(size == 0))
39849                 return (*meth)(self, NULL);
39850             PyErr_Format(PyExc_TypeError,
39851                 "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
39852                 f->m_ml->ml_name, size);
39853             return NULL;
39854         }
39855         break;
39856     case METH_O:
39857         if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
39858             size = PyTuple_GET_SIZE(arg);
39859             if (likely(size == 1)) {
39860                 PyObject *result, *arg0;
39861                 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
39862                 arg0 = PyTuple_GET_ITEM(arg, 0);
39863                 #else
39864                 arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
39865                 #endif
39866                 result = (*meth)(self, arg0);
39867                 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
39868                 Py_DECREF(arg0);
39869                 #endif
39870                 return result;
39871             }
39872             PyErr_Format(PyExc_TypeError,
39873                 "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
39874                 f->m_ml->ml_name, size);
39875             return NULL;
39876         }
39877         break;
39878     default:
39879         PyErr_SetString(PyExc_SystemError, "Bad call flags in "
39880                         "__Pyx_CyFunction_Call. METH_OLDARGS is no "
39881                         "longer supported!");
39882         return NULL;
39883     }
39884     PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
39885                  f->m_ml->ml_name);
39886     return NULL;
39887 }
__Pyx_CyFunction_Call(PyObject * func,PyObject * arg,PyObject * kw)39888 static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
39889     return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
39890 }
__Pyx_CyFunction_CallAsMethod(PyObject * func,PyObject * args,PyObject * kw)39891 static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
39892     PyObject *result;
39893     __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
39894     if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
39895         Py_ssize_t argc;
39896         PyObject *new_args;
39897         PyObject *self;
39898         argc = PyTuple_GET_SIZE(args);
39899         new_args = PyTuple_GetSlice(args, 1, argc);
39900         if (unlikely(!new_args))
39901             return NULL;
39902         self = PyTuple_GetItem(args, 0);
39903         if (unlikely(!self)) {
39904             Py_DECREF(new_args);
39905             return NULL;
39906         }
39907         result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
39908         Py_DECREF(new_args);
39909     } else {
39910         result = __Pyx_CyFunction_Call(func, args, kw);
39911     }
39912     return result;
39913 }
39914 static PyTypeObject __pyx_CyFunctionType_type = {
39915     PyVarObject_HEAD_INIT(0, 0)
39916     "cython_function_or_method",
39917     sizeof(__pyx_CyFunctionObject),
39918     0,
39919     (destructor) __Pyx_CyFunction_dealloc,
39920     0,
39921     0,
39922     0,
39923 #if PY_MAJOR_VERSION < 3
39924     0,
39925 #else
39926     0,
39927 #endif
39928     (reprfunc) __Pyx_CyFunction_repr,
39929     0,
39930     0,
39931     0,
39932     0,
39933     __Pyx_CyFunction_CallAsMethod,
39934     0,
39935     0,
39936     0,
39937     0,
39938     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
39939     0,
39940     (traverseproc) __Pyx_CyFunction_traverse,
39941     (inquiry) __Pyx_CyFunction_clear,
39942     0,
39943 #if PY_VERSION_HEX < 0x030500A0
39944     offsetof(__pyx_CyFunctionObject, func_weakreflist),
39945 #else
39946     offsetof(PyCFunctionObject, m_weakreflist),
39947 #endif
39948     0,
39949     0,
39950     __pyx_CyFunction_methods,
39951     __pyx_CyFunction_members,
39952     __pyx_CyFunction_getsets,
39953     0,
39954     0,
39955     __Pyx_CyFunction_descr_get,
39956     0,
39957     offsetof(__pyx_CyFunctionObject, func_dict),
39958     0,
39959     0,
39960     0,
39961     0,
39962     0,
39963     0,
39964     0,
39965     0,
39966     0,
39967     0,
39968     0,
39969     0,
39970 #if PY_VERSION_HEX >= 0x030400a1
39971     0,
39972 #endif
39973 #if PY_VERSION_HEX >= 0x030800b1
39974     0,
39975 #endif
39976 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
39977     0,
39978 #endif
39979 };
__pyx_CyFunction_init(void)39980 static int __pyx_CyFunction_init(void) {
39981     __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
39982     if (unlikely(__pyx_CyFunctionType == NULL)) {
39983         return -1;
39984     }
39985     return 0;
39986 }
__Pyx_CyFunction_InitDefaults(PyObject * func,size_t size,int pyobjects)39987 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
39988     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
39989     m->defaults = PyObject_Malloc(size);
39990     if (unlikely(!m->defaults))
39991         return PyErr_NoMemory();
39992     memset(m->defaults, 0, size);
39993     m->defaults_pyobjects = pyobjects;
39994     m->defaults_size = size;
39995     return m->defaults;
39996 }
__Pyx_CyFunction_SetDefaultsTuple(PyObject * func,PyObject * tuple)39997 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
39998     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
39999     m->defaults_tuple = tuple;
40000     Py_INCREF(tuple);
40001 }
__Pyx_CyFunction_SetDefaultsKwDict(PyObject * func,PyObject * dict)40002 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
40003     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
40004     m->defaults_kwdict = dict;
40005     Py_INCREF(dict);
40006 }
__Pyx_CyFunction_SetAnnotationsDict(PyObject * func,PyObject * dict)40007 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
40008     __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
40009     m->func_annotations = dict;
40010     Py_INCREF(dict);
40011 }
40012 
40013 /* FusedFunction */
40014 static PyObject *
__pyx_FusedFunction_New(PyMethodDef * ml,int flags,PyObject * qualname,PyObject * closure,PyObject * module,PyObject * globals,PyObject * code)40015 __pyx_FusedFunction_New(PyMethodDef *ml, int flags,
40016                         PyObject *qualname, PyObject *closure,
40017                         PyObject *module, PyObject *globals,
40018                         PyObject *code)
40019 {
40020     PyObject *op = __Pyx_CyFunction_Init(
40021         PyObject_GC_New(__pyx_CyFunctionObject, __pyx_FusedFunctionType),
40022         ml, flags, qualname, closure, module, globals, code
40023     );
40024     if (likely(op)) {
40025         __pyx_FusedFunctionObject *fusedfunc = (__pyx_FusedFunctionObject *) op;
40026         fusedfunc->__signatures__ = NULL;
40027         fusedfunc->type = NULL;
40028         fusedfunc->self = NULL;
40029         PyObject_GC_Track(op);
40030     }
40031     return op;
40032 }
40033 static void
__pyx_FusedFunction_dealloc(__pyx_FusedFunctionObject * self)40034 __pyx_FusedFunction_dealloc(__pyx_FusedFunctionObject *self)
40035 {
40036     PyObject_GC_UnTrack(self);
40037     Py_CLEAR(self->self);
40038     Py_CLEAR(self->type);
40039     Py_CLEAR(self->__signatures__);
40040     __Pyx__CyFunction_dealloc((__pyx_CyFunctionObject *) self);
40041 }
40042 static int
__pyx_FusedFunction_traverse(__pyx_FusedFunctionObject * self,visitproc visit,void * arg)40043 __pyx_FusedFunction_traverse(__pyx_FusedFunctionObject *self,
40044                              visitproc visit,
40045                              void *arg)
40046 {
40047     Py_VISIT(self->self);
40048     Py_VISIT(self->type);
40049     Py_VISIT(self->__signatures__);
40050     return __Pyx_CyFunction_traverse((__pyx_CyFunctionObject *) self, visit, arg);
40051 }
40052 static int
__pyx_FusedFunction_clear(__pyx_FusedFunctionObject * self)40053 __pyx_FusedFunction_clear(__pyx_FusedFunctionObject *self)
40054 {
40055     Py_CLEAR(self->self);
40056     Py_CLEAR(self->type);
40057     Py_CLEAR(self->__signatures__);
40058     return __Pyx_CyFunction_clear((__pyx_CyFunctionObject *) self);
40059 }
40060 static PyObject *
__pyx_FusedFunction_descr_get(PyObject * self,PyObject * obj,PyObject * type)40061 __pyx_FusedFunction_descr_get(PyObject *self, PyObject *obj, PyObject *type)
40062 {
40063     __pyx_FusedFunctionObject *func, *meth;
40064     func = (__pyx_FusedFunctionObject *) self;
40065     if (func->self || func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD) {
40066         Py_INCREF(self);
40067         return self;
40068     }
40069     if (obj == Py_None)
40070         obj = NULL;
40071     meth = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_New(
40072                     ((PyCFunctionObject *) func)->m_ml,
40073                     ((__pyx_CyFunctionObject *) func)->flags,
40074                     ((__pyx_CyFunctionObject *) func)->func_qualname,
40075                     ((__pyx_CyFunctionObject *) func)->func_closure,
40076                     ((PyCFunctionObject *) func)->m_module,
40077                     ((__pyx_CyFunctionObject *) func)->func_globals,
40078                     ((__pyx_CyFunctionObject *) func)->func_code);
40079     if (!meth)
40080         return NULL;
40081     if (func->func.defaults) {
40082         PyObject **pydefaults;
40083         int i;
40084         if (!__Pyx_CyFunction_InitDefaults((PyObject*)meth,
40085                                       func->func.defaults_size,
40086                                       func->func.defaults_pyobjects)) {
40087             Py_XDECREF((PyObject*)meth);
40088             return NULL;
40089         }
40090         memcpy(meth->func.defaults, func->func.defaults, func->func.defaults_size);
40091         pydefaults = __Pyx_CyFunction_Defaults(PyObject *, meth);
40092         for (i = 0; i < meth->func.defaults_pyobjects; i++)
40093             Py_XINCREF(pydefaults[i]);
40094     }
40095     Py_XINCREF(func->func.func_classobj);
40096     meth->func.func_classobj = func->func.func_classobj;
40097     Py_XINCREF(func->__signatures__);
40098     meth->__signatures__ = func->__signatures__;
40099     Py_XINCREF(type);
40100     meth->type = type;
40101     Py_XINCREF(func->func.defaults_tuple);
40102     meth->func.defaults_tuple = func->func.defaults_tuple;
40103     if (func->func.flags & __Pyx_CYFUNCTION_CLASSMETHOD)
40104         obj = type;
40105     Py_XINCREF(obj);
40106     meth->self = obj;
40107     return (PyObject *) meth;
40108 }
40109 static PyObject *
_obj_to_str(PyObject * obj)40110 _obj_to_str(PyObject *obj)
40111 {
40112     if (PyType_Check(obj))
40113         return PyObject_GetAttr(obj, __pyx_n_s_name_2);
40114     else
40115         return PyObject_Str(obj);
40116 }
40117 static PyObject *
__pyx_FusedFunction_getitem(__pyx_FusedFunctionObject * self,PyObject * idx)40118 __pyx_FusedFunction_getitem(__pyx_FusedFunctionObject *self, PyObject *idx)
40119 {
40120     PyObject *signature = NULL;
40121     PyObject *unbound_result_func;
40122     PyObject *result_func = NULL;
40123     if (self->__signatures__ == NULL) {
40124         PyErr_SetString(PyExc_TypeError, "Function is not fused");
40125         return NULL;
40126     }
40127     if (PyTuple_Check(idx)) {
40128         PyObject *list = PyList_New(0);
40129         Py_ssize_t n = PyTuple_GET_SIZE(idx);
40130         PyObject *sep = NULL;
40131         int i;
40132         if (unlikely(!list))
40133             return NULL;
40134         for (i = 0; i < n; i++) {
40135             int ret;
40136             PyObject *string;
40137 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
40138             PyObject *item = PyTuple_GET_ITEM(idx, i);
40139 #else
40140             PyObject *item = PySequence_ITEM(idx, i);  if (unlikely(!item)) goto __pyx_err;
40141 #endif
40142             string = _obj_to_str(item);
40143 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
40144             Py_DECREF(item);
40145 #endif
40146             if (unlikely(!string)) goto __pyx_err;
40147             ret = PyList_Append(list, string);
40148             Py_DECREF(string);
40149             if (unlikely(ret < 0)) goto __pyx_err;
40150         }
40151         sep = PyUnicode_FromString("|");
40152         if (likely(sep))
40153             signature = PyUnicode_Join(sep, list);
40154 __pyx_err:
40155 ;
40156         Py_DECREF(list);
40157         Py_XDECREF(sep);
40158     } else {
40159         signature = _obj_to_str(idx);
40160     }
40161     if (!signature)
40162         return NULL;
40163     unbound_result_func = PyObject_GetItem(self->__signatures__, signature);
40164     if (unbound_result_func) {
40165         if (self->self || self->type) {
40166             __pyx_FusedFunctionObject *unbound = (__pyx_FusedFunctionObject *) unbound_result_func;
40167             Py_CLEAR(unbound->func.func_classobj);
40168             Py_XINCREF(self->func.func_classobj);
40169             unbound->func.func_classobj = self->func.func_classobj;
40170             result_func = __pyx_FusedFunction_descr_get(unbound_result_func,
40171                                                         self->self, self->type);
40172         } else {
40173             result_func = unbound_result_func;
40174             Py_INCREF(result_func);
40175         }
40176     }
40177     Py_DECREF(signature);
40178     Py_XDECREF(unbound_result_func);
40179     return result_func;
40180 }
40181 static PyObject *
__pyx_FusedFunction_callfunction(PyObject * func,PyObject * args,PyObject * kw)40182 __pyx_FusedFunction_callfunction(PyObject *func, PyObject *args, PyObject *kw)
40183 {
40184      __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
40185     int static_specialized = (cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD &&
40186                               !((__pyx_FusedFunctionObject *) func)->__signatures__);
40187     if (cyfunc->flags & __Pyx_CYFUNCTION_CCLASS && !static_specialized) {
40188         return __Pyx_CyFunction_CallAsMethod(func, args, kw);
40189     } else {
40190         return __Pyx_CyFunction_Call(func, args, kw);
40191     }
40192 }
40193 static PyObject *
__pyx_FusedFunction_call(PyObject * func,PyObject * args,PyObject * kw)40194 __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
40195 {
40196     __pyx_FusedFunctionObject *binding_func = (__pyx_FusedFunctionObject *) func;
40197     Py_ssize_t argc = PyTuple_GET_SIZE(args);
40198     PyObject *new_args = NULL;
40199     __pyx_FusedFunctionObject *new_func = NULL;
40200     PyObject *result = NULL;
40201     PyObject *self = NULL;
40202     int is_staticmethod = binding_func->func.flags & __Pyx_CYFUNCTION_STATICMETHOD;
40203     int is_classmethod = binding_func->func.flags & __Pyx_CYFUNCTION_CLASSMETHOD;
40204     if (binding_func->self) {
40205         Py_ssize_t i;
40206         new_args = PyTuple_New(argc + 1);
40207         if (!new_args)
40208             return NULL;
40209         self = binding_func->self;
40210 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
40211         Py_INCREF(self);
40212 #endif
40213         Py_INCREF(self);
40214         PyTuple_SET_ITEM(new_args, 0, self);
40215         for (i = 0; i < argc; i++) {
40216 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
40217             PyObject *item = PyTuple_GET_ITEM(args, i);
40218             Py_INCREF(item);
40219 #else
40220             PyObject *item = PySequence_ITEM(args, i);  if (unlikely(!item)) goto bad;
40221 #endif
40222             PyTuple_SET_ITEM(new_args, i + 1, item);
40223         }
40224         args = new_args;
40225     } else if (binding_func->type) {
40226         if (argc < 1) {
40227             PyErr_SetString(PyExc_TypeError, "Need at least one argument, 0 given.");
40228             return NULL;
40229         }
40230 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
40231         self = PyTuple_GET_ITEM(args, 0);
40232 #else
40233         self = PySequence_ITEM(args, 0);  if (unlikely(!self)) return NULL;
40234 #endif
40235     }
40236     if (self && !is_classmethod && !is_staticmethod) {
40237         int is_instance = PyObject_IsInstance(self, binding_func->type);
40238         if (unlikely(!is_instance)) {
40239             PyErr_Format(PyExc_TypeError,
40240                          "First argument should be of type %.200s, got %.200s.",
40241                          ((PyTypeObject *) binding_func->type)->tp_name,
40242                          self->ob_type->tp_name);
40243             goto bad;
40244         } else if (unlikely(is_instance == -1)) {
40245             goto bad;
40246         }
40247     }
40248 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
40249     Py_XDECREF(self);
40250     self = NULL;
40251 #endif
40252     if (binding_func->__signatures__) {
40253         PyObject *tup;
40254         if (is_staticmethod && binding_func->func.flags & __Pyx_CYFUNCTION_CCLASS) {
40255             tup = PyTuple_Pack(3, args,
40256                                kw == NULL ? Py_None : kw,
40257                                binding_func->func.defaults_tuple);
40258             if (unlikely(!tup)) goto bad;
40259             new_func = (__pyx_FusedFunctionObject *) __Pyx_CyFunction_CallMethod(
40260                 func, binding_func->__signatures__, tup, NULL);
40261         } else {
40262             tup = PyTuple_Pack(4, binding_func->__signatures__, args,
40263                                kw == NULL ? Py_None : kw,
40264                                binding_func->func.defaults_tuple);
40265             if (unlikely(!tup)) goto bad;
40266             new_func = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_callfunction(func, tup, NULL);
40267         }
40268         Py_DECREF(tup);
40269         if (unlikely(!new_func))
40270             goto bad;
40271         Py_XINCREF(binding_func->func.func_classobj);
40272         Py_CLEAR(new_func->func.func_classobj);
40273         new_func->func.func_classobj = binding_func->func.func_classobj;
40274         func = (PyObject *) new_func;
40275     }
40276     result = __pyx_FusedFunction_callfunction(func, args, kw);
40277 bad:
40278 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
40279     Py_XDECREF(self);
40280 #endif
40281     Py_XDECREF(new_args);
40282     Py_XDECREF((PyObject *) new_func);
40283     return result;
40284 }
40285 static PyMemberDef __pyx_FusedFunction_members[] = {
40286     {(char *) "__signatures__",
40287      T_OBJECT,
40288      offsetof(__pyx_FusedFunctionObject, __signatures__),
40289      READONLY,
40290      0},
40291     {0, 0, 0, 0, 0},
40292 };
40293 static PyMappingMethods __pyx_FusedFunction_mapping_methods = {
40294     0,
40295     (binaryfunc) __pyx_FusedFunction_getitem,
40296     0,
40297 };
40298 static PyTypeObject __pyx_FusedFunctionType_type = {
40299     PyVarObject_HEAD_INIT(0, 0)
40300     "fused_cython_function",
40301     sizeof(__pyx_FusedFunctionObject),
40302     0,
40303     (destructor) __pyx_FusedFunction_dealloc,
40304     0,
40305     0,
40306     0,
40307 #if PY_MAJOR_VERSION < 3
40308     0,
40309 #else
40310     0,
40311 #endif
40312     0,
40313     0,
40314     0,
40315     &__pyx_FusedFunction_mapping_methods,
40316     0,
40317     (ternaryfunc) __pyx_FusedFunction_call,
40318     0,
40319     0,
40320     0,
40321     0,
40322     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
40323     0,
40324     (traverseproc) __pyx_FusedFunction_traverse,
40325     (inquiry) __pyx_FusedFunction_clear,
40326     0,
40327     0,
40328     0,
40329     0,
40330     0,
40331     __pyx_FusedFunction_members,
40332     __pyx_CyFunction_getsets,
40333     &__pyx_CyFunctionType_type,
40334     0,
40335     __pyx_FusedFunction_descr_get,
40336     0,
40337     0,
40338     0,
40339     0,
40340     0,
40341     0,
40342     0,
40343     0,
40344     0,
40345     0,
40346     0,
40347     0,
40348     0,
40349     0,
40350 #if PY_VERSION_HEX >= 0x030400a1
40351     0,
40352 #endif
40353 #if PY_VERSION_HEX >= 0x030800b1
40354     0,
40355 #endif
40356 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
40357     0,
40358 #endif
40359 };
__pyx_FusedFunction_init(void)40360 static int __pyx_FusedFunction_init(void) {
40361     __pyx_FusedFunctionType_type.tp_base = __pyx_CyFunctionType;
40362     __pyx_FusedFunctionType = __Pyx_FetchCommonType(&__pyx_FusedFunctionType_type);
40363     if (__pyx_FusedFunctionType == NULL) {
40364         return -1;
40365     }
40366     return 0;
40367 }
40368 
40369 /* CLineInTraceback */
40370 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)40371 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
40372     PyObject *use_cline;
40373     PyObject *ptype, *pvalue, *ptraceback;
40374 #if CYTHON_COMPILING_IN_CPYTHON
40375     PyObject **cython_runtime_dict;
40376 #endif
40377     if (unlikely(!__pyx_cython_runtime)) {
40378         return c_line;
40379     }
40380     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
40381 #if CYTHON_COMPILING_IN_CPYTHON
40382     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
40383     if (likely(cython_runtime_dict)) {
40384         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
40385             use_cline, *cython_runtime_dict,
40386             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
40387     } else
40388 #endif
40389     {
40390       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
40391       if (use_cline_obj) {
40392         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
40393         Py_DECREF(use_cline_obj);
40394       } else {
40395         PyErr_Clear();
40396         use_cline = NULL;
40397       }
40398     }
40399     if (!use_cline) {
40400         c_line = 0;
40401         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
40402     }
40403     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
40404         c_line = 0;
40405     }
40406     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
40407     return c_line;
40408 }
40409 #endif
40410 
40411 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)40412 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
40413     int start = 0, mid = 0, end = count - 1;
40414     if (end >= 0 && code_line > entries[end].code_line) {
40415         return count;
40416     }
40417     while (start < end) {
40418         mid = start + (end - start) / 2;
40419         if (code_line < entries[mid].code_line) {
40420             end = mid;
40421         } else if (code_line > entries[mid].code_line) {
40422              start = mid + 1;
40423         } else {
40424             return mid;
40425         }
40426     }
40427     if (code_line <= entries[mid].code_line) {
40428         return mid;
40429     } else {
40430         return mid + 1;
40431     }
40432 }
__pyx_find_code_object(int code_line)40433 static PyCodeObject *__pyx_find_code_object(int code_line) {
40434     PyCodeObject* code_object;
40435     int pos;
40436     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
40437         return NULL;
40438     }
40439     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
40440     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
40441         return NULL;
40442     }
40443     code_object = __pyx_code_cache.entries[pos].code_object;
40444     Py_INCREF(code_object);
40445     return code_object;
40446 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)40447 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
40448     int pos, i;
40449     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
40450     if (unlikely(!code_line)) {
40451         return;
40452     }
40453     if (unlikely(!entries)) {
40454         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
40455         if (likely(entries)) {
40456             __pyx_code_cache.entries = entries;
40457             __pyx_code_cache.max_count = 64;
40458             __pyx_code_cache.count = 1;
40459             entries[0].code_line = code_line;
40460             entries[0].code_object = code_object;
40461             Py_INCREF(code_object);
40462         }
40463         return;
40464     }
40465     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
40466     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
40467         PyCodeObject* tmp = entries[pos].code_object;
40468         entries[pos].code_object = code_object;
40469         Py_DECREF(tmp);
40470         return;
40471     }
40472     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
40473         int new_max = __pyx_code_cache.max_count + 64;
40474         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
40475             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
40476         if (unlikely(!entries)) {
40477             return;
40478         }
40479         __pyx_code_cache.entries = entries;
40480         __pyx_code_cache.max_count = new_max;
40481     }
40482     for (i=__pyx_code_cache.count; i>pos; i--) {
40483         entries[i] = entries[i-1];
40484     }
40485     entries[pos].code_line = code_line;
40486     entries[pos].code_object = code_object;
40487     __pyx_code_cache.count++;
40488     Py_INCREF(code_object);
40489 }
40490 
40491 /* AddTraceback */
40492 #include "compile.h"
40493 #include "frameobject.h"
40494 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)40495 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
40496             const char *funcname, int c_line,
40497             int py_line, const char *filename) {
40498     PyCodeObject *py_code = 0;
40499     PyObject *py_srcfile = 0;
40500     PyObject *py_funcname = 0;
40501     #if PY_MAJOR_VERSION < 3
40502     py_srcfile = PyString_FromString(filename);
40503     #else
40504     py_srcfile = PyUnicode_FromString(filename);
40505     #endif
40506     if (!py_srcfile) goto bad;
40507     if (c_line) {
40508         #if PY_MAJOR_VERSION < 3
40509         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
40510         #else
40511         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
40512         #endif
40513     }
40514     else {
40515         #if PY_MAJOR_VERSION < 3
40516         py_funcname = PyString_FromString(funcname);
40517         #else
40518         py_funcname = PyUnicode_FromString(funcname);
40519         #endif
40520     }
40521     if (!py_funcname) goto bad;
40522     py_code = __Pyx_PyCode_New(
40523         0,
40524         0,
40525         0,
40526         0,
40527         0,
40528         __pyx_empty_bytes, /*PyObject *code,*/
40529         __pyx_empty_tuple, /*PyObject *consts,*/
40530         __pyx_empty_tuple, /*PyObject *names,*/
40531         __pyx_empty_tuple, /*PyObject *varnames,*/
40532         __pyx_empty_tuple, /*PyObject *freevars,*/
40533         __pyx_empty_tuple, /*PyObject *cellvars,*/
40534         py_srcfile,   /*PyObject *filename,*/
40535         py_funcname,  /*PyObject *name,*/
40536         py_line,
40537         __pyx_empty_bytes  /*PyObject *lnotab*/
40538     );
40539     Py_DECREF(py_srcfile);
40540     Py_DECREF(py_funcname);
40541     return py_code;
40542 bad:
40543     Py_XDECREF(py_srcfile);
40544     Py_XDECREF(py_funcname);
40545     return NULL;
40546 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)40547 static void __Pyx_AddTraceback(const char *funcname, int c_line,
40548                                int py_line, const char *filename) {
40549     PyCodeObject *py_code = 0;
40550     PyFrameObject *py_frame = 0;
40551     PyThreadState *tstate = __Pyx_PyThreadState_Current;
40552     if (c_line) {
40553         c_line = __Pyx_CLineForTraceback(tstate, c_line);
40554     }
40555     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
40556     if (!py_code) {
40557         py_code = __Pyx_CreateCodeObjectForTraceback(
40558             funcname, c_line, py_line, filename);
40559         if (!py_code) goto bad;
40560         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
40561     }
40562     py_frame = PyFrame_New(
40563         tstate,            /*PyThreadState *tstate,*/
40564         py_code,           /*PyCodeObject *code,*/
40565         __pyx_d,    /*PyObject *globals,*/
40566         0                  /*PyObject *locals*/
40567     );
40568     if (!py_frame) goto bad;
40569     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
40570     PyTraceBack_Here(py_frame);
40571 bad:
40572     Py_XDECREF(py_code);
40573     Py_XDECREF(py_frame);
40574 }
40575 
40576 #if PY_MAJOR_VERSION < 3
__Pyx_GetBuffer(PyObject * obj,Py_buffer * view,int flags)40577 static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
40578     if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
40579         if (__Pyx_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
40580         if (__Pyx_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags);
40581     PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
40582     return -1;
40583 }
__Pyx_ReleaseBuffer(Py_buffer * view)40584 static void __Pyx_ReleaseBuffer(Py_buffer *view) {
40585     PyObject *obj = view->obj;
40586     if (!obj) return;
40587     if (PyObject_CheckBuffer(obj)) {
40588         PyBuffer_Release(view);
40589         return;
40590     }
40591     if ((0)) {}
40592     view->obj = NULL;
40593     Py_DECREF(obj);
40594 }
40595 #endif
40596 
40597 
40598 /* MemviewSliceIsContig */
40599 static int
__pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs,char order,int ndim)40600 __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim)
40601 {
40602     int i, index, step, start;
40603     Py_ssize_t itemsize = mvs.memview->view.itemsize;
40604     if (order == 'F') {
40605         step = 1;
40606         start = 0;
40607     } else {
40608         step = -1;
40609         start = ndim - 1;
40610     }
40611     for (i = 0; i < ndim; i++) {
40612         index = start + step * i;
40613         if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize)
40614             return 0;
40615         itemsize *= mvs.shape[index];
40616     }
40617     return 1;
40618 }
40619 
40620 /* OverlappingSlices */
40621 static void
__pyx_get_array_memory_extents(__Pyx_memviewslice * slice,void ** out_start,void ** out_end,int ndim,size_t itemsize)40622 __pyx_get_array_memory_extents(__Pyx_memviewslice *slice,
40623                                void **out_start, void **out_end,
40624                                int ndim, size_t itemsize)
40625 {
40626     char *start, *end;
40627     int i;
40628     start = end = slice->data;
40629     for (i = 0; i < ndim; i++) {
40630         Py_ssize_t stride = slice->strides[i];
40631         Py_ssize_t extent = slice->shape[i];
40632         if (extent == 0) {
40633             *out_start = *out_end = start;
40634             return;
40635         } else {
40636             if (stride > 0)
40637                 end += stride * (extent - 1);
40638             else
40639                 start += stride * (extent - 1);
40640         }
40641     }
40642     *out_start = start;
40643     *out_end = end + itemsize;
40644 }
40645 static int
__pyx_slices_overlap(__Pyx_memviewslice * slice1,__Pyx_memviewslice * slice2,int ndim,size_t itemsize)40646 __pyx_slices_overlap(__Pyx_memviewslice *slice1,
40647                      __Pyx_memviewslice *slice2,
40648                      int ndim, size_t itemsize)
40649 {
40650     void *start1, *end1, *start2, *end2;
40651     __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize);
40652     __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize);
40653     return (start1 < end2) && (start2 < end1);
40654 }
40655 
40656 /* Capsule */
40657 static CYTHON_INLINE PyObject *
__pyx_capsule_create(void * p,CYTHON_UNUSED const char * sig)40658 __pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig)
40659 {
40660     PyObject *cobj;
40661 #if PY_VERSION_HEX >= 0x02070000
40662     cobj = PyCapsule_New(p, sig, NULL);
40663 #else
40664     cobj = PyCObject_FromVoidPtr(p, NULL);
40665 #endif
40666     return cobj;
40667 }
40668 
40669 /* IsLittleEndian */
__Pyx_Is_Little_Endian(void)40670 static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
40671 {
40672   union {
40673     uint32_t u32;
40674     uint8_t u8[4];
40675   } S;
40676   S.u32 = 0x01020304;
40677   return S.u8[0] == 4;
40678 }
40679 
40680 /* BufferFormatCheck */
__Pyx_BufFmt_Init(__Pyx_BufFmt_Context * ctx,__Pyx_BufFmt_StackElem * stack,__Pyx_TypeInfo * type)40681 static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
40682                               __Pyx_BufFmt_StackElem* stack,
40683                               __Pyx_TypeInfo* type) {
40684   stack[0].field = &ctx->root;
40685   stack[0].parent_offset = 0;
40686   ctx->root.type = type;
40687   ctx->root.name = "buffer dtype";
40688   ctx->root.offset = 0;
40689   ctx->head = stack;
40690   ctx->head->field = &ctx->root;
40691   ctx->fmt_offset = 0;
40692   ctx->head->parent_offset = 0;
40693   ctx->new_packmode = '@';
40694   ctx->enc_packmode = '@';
40695   ctx->new_count = 1;
40696   ctx->enc_count = 0;
40697   ctx->enc_type = 0;
40698   ctx->is_complex = 0;
40699   ctx->is_valid_array = 0;
40700   ctx->struct_alignment = 0;
40701   while (type->typegroup == 'S') {
40702     ++ctx->head;
40703     ctx->head->field = type->fields;
40704     ctx->head->parent_offset = 0;
40705     type = type->fields->type;
40706   }
40707 }
__Pyx_BufFmt_ParseNumber(const char ** ts)40708 static int __Pyx_BufFmt_ParseNumber(const char** ts) {
40709     int count;
40710     const char* t = *ts;
40711     if (*t < '0' || *t > '9') {
40712       return -1;
40713     } else {
40714         count = *t++ - '0';
40715         while (*t >= '0' && *t <= '9') {
40716             count *= 10;
40717             count += *t++ - '0';
40718         }
40719     }
40720     *ts = t;
40721     return count;
40722 }
__Pyx_BufFmt_ExpectNumber(const char ** ts)40723 static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
40724     int number = __Pyx_BufFmt_ParseNumber(ts);
40725     if (number == -1)
40726         PyErr_Format(PyExc_ValueError,\
40727                      "Does not understand character buffer dtype format string ('%c')", **ts);
40728     return number;
40729 }
__Pyx_BufFmt_RaiseUnexpectedChar(char ch)40730 static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
40731   PyErr_Format(PyExc_ValueError,
40732                "Unexpected format string character: '%c'", ch);
40733 }
__Pyx_BufFmt_DescribeTypeChar(char ch,int is_complex)40734 static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
40735   switch (ch) {
40736     case '?': return "'bool'";
40737     case 'c': return "'char'";
40738     case 'b': return "'signed char'";
40739     case 'B': return "'unsigned char'";
40740     case 'h': return "'short'";
40741     case 'H': return "'unsigned short'";
40742     case 'i': return "'int'";
40743     case 'I': return "'unsigned int'";
40744     case 'l': return "'long'";
40745     case 'L': return "'unsigned long'";
40746     case 'q': return "'long long'";
40747     case 'Q': return "'unsigned long long'";
40748     case 'f': return (is_complex ? "'complex float'" : "'float'");
40749     case 'd': return (is_complex ? "'complex double'" : "'double'");
40750     case 'g': return (is_complex ? "'complex long double'" : "'long double'");
40751     case 'T': return "a struct";
40752     case 'O': return "Python object";
40753     case 'P': return "a pointer";
40754     case 's': case 'p': return "a string";
40755     case 0: return "end";
40756     default: return "unparseable format string";
40757   }
40758 }
__Pyx_BufFmt_TypeCharToStandardSize(char ch,int is_complex)40759 static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
40760   switch (ch) {
40761     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
40762     case 'h': case 'H': return 2;
40763     case 'i': case 'I': case 'l': case 'L': return 4;
40764     case 'q': case 'Q': return 8;
40765     case 'f': return (is_complex ? 8 : 4);
40766     case 'd': return (is_complex ? 16 : 8);
40767     case 'g': {
40768       PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
40769       return 0;
40770     }
40771     case 'O': case 'P': return sizeof(void*);
40772     default:
40773       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
40774       return 0;
40775     }
40776 }
__Pyx_BufFmt_TypeCharToNativeSize(char ch,int is_complex)40777 static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
40778   switch (ch) {
40779     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
40780     case 'h': case 'H': return sizeof(short);
40781     case 'i': case 'I': return sizeof(int);
40782     case 'l': case 'L': return sizeof(long);
40783     #ifdef HAVE_LONG_LONG
40784     case 'q': case 'Q': return sizeof(PY_LONG_LONG);
40785     #endif
40786     case 'f': return sizeof(float) * (is_complex ? 2 : 1);
40787     case 'd': return sizeof(double) * (is_complex ? 2 : 1);
40788     case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
40789     case 'O': case 'P': return sizeof(void*);
40790     default: {
40791       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
40792       return 0;
40793     }
40794   }
40795 }
40796 typedef struct { char c; short x; } __Pyx_st_short;
40797 typedef struct { char c; int x; } __Pyx_st_int;
40798 typedef struct { char c; long x; } __Pyx_st_long;
40799 typedef struct { char c; float x; } __Pyx_st_float;
40800 typedef struct { char c; double x; } __Pyx_st_double;
40801 typedef struct { char c; long double x; } __Pyx_st_longdouble;
40802 typedef struct { char c; void *x; } __Pyx_st_void_p;
40803 #ifdef HAVE_LONG_LONG
40804 typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
40805 #endif
__Pyx_BufFmt_TypeCharToAlignment(char ch,CYTHON_UNUSED int is_complex)40806 static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
40807   switch (ch) {
40808     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
40809     case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
40810     case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
40811     case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
40812 #ifdef HAVE_LONG_LONG
40813     case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
40814 #endif
40815     case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
40816     case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
40817     case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
40818     case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
40819     default:
40820       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
40821       return 0;
40822     }
40823 }
40824 /* These are for computing the padding at the end of the struct to align
40825    on the first member of the struct. This will probably the same as above,
40826    but we don't have any guarantees.
40827  */
40828 typedef struct { short x; char c; } __Pyx_pad_short;
40829 typedef struct { int x; char c; } __Pyx_pad_int;
40830 typedef struct { long x; char c; } __Pyx_pad_long;
40831 typedef struct { float x; char c; } __Pyx_pad_float;
40832 typedef struct { double x; char c; } __Pyx_pad_double;
40833 typedef struct { long double x; char c; } __Pyx_pad_longdouble;
40834 typedef struct { void *x; char c; } __Pyx_pad_void_p;
40835 #ifdef HAVE_LONG_LONG
40836 typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
40837 #endif
__Pyx_BufFmt_TypeCharToPadding(char ch,CYTHON_UNUSED int is_complex)40838 static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
40839   switch (ch) {
40840     case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
40841     case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
40842     case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
40843     case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
40844 #ifdef HAVE_LONG_LONG
40845     case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
40846 #endif
40847     case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
40848     case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
40849     case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
40850     case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
40851     default:
40852       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
40853       return 0;
40854     }
40855 }
__Pyx_BufFmt_TypeCharToGroup(char ch,int is_complex)40856 static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
40857   switch (ch) {
40858     case 'c':
40859         return 'H';
40860     case 'b': case 'h': case 'i':
40861     case 'l': case 'q': case 's': case 'p':
40862         return 'I';
40863     case '?': case 'B': case 'H': case 'I': case 'L': case 'Q':
40864         return 'U';
40865     case 'f': case 'd': case 'g':
40866         return (is_complex ? 'C' : 'R');
40867     case 'O':
40868         return 'O';
40869     case 'P':
40870         return 'P';
40871     default: {
40872       __Pyx_BufFmt_RaiseUnexpectedChar(ch);
40873       return 0;
40874     }
40875   }
40876 }
__Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context * ctx)40877 static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
40878   if (ctx->head == NULL || ctx->head->field == &ctx->root) {
40879     const char* expected;
40880     const char* quote;
40881     if (ctx->head == NULL) {
40882       expected = "end";
40883       quote = "";
40884     } else {
40885       expected = ctx->head->field->type->name;
40886       quote = "'";
40887     }
40888     PyErr_Format(PyExc_ValueError,
40889                  "Buffer dtype mismatch, expected %s%s%s but got %s",
40890                  quote, expected, quote,
40891                  __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
40892   } else {
40893     __Pyx_StructField* field = ctx->head->field;
40894     __Pyx_StructField* parent = (ctx->head - 1)->field;
40895     PyErr_Format(PyExc_ValueError,
40896                  "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
40897                  field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
40898                  parent->type->name, field->name);
40899   }
40900 }
__Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context * ctx)40901 static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
40902   char group;
40903   size_t size, offset, arraysize = 1;
40904   if (ctx->enc_type == 0) return 0;
40905   if (ctx->head->field->type->arraysize[0]) {
40906     int i, ndim = 0;
40907     if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
40908         ctx->is_valid_array = ctx->head->field->type->ndim == 1;
40909         ndim = 1;
40910         if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
40911             PyErr_Format(PyExc_ValueError,
40912                          "Expected a dimension of size %zu, got %zu",
40913                          ctx->head->field->type->arraysize[0], ctx->enc_count);
40914             return -1;
40915         }
40916     }
40917     if (!ctx->is_valid_array) {
40918       PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
40919                    ctx->head->field->type->ndim, ndim);
40920       return -1;
40921     }
40922     for (i = 0; i < ctx->head->field->type->ndim; i++) {
40923       arraysize *= ctx->head->field->type->arraysize[i];
40924     }
40925     ctx->is_valid_array = 0;
40926     ctx->enc_count = 1;
40927   }
40928   group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
40929   do {
40930     __Pyx_StructField* field = ctx->head->field;
40931     __Pyx_TypeInfo* type = field->type;
40932     if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
40933       size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
40934     } else {
40935       size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
40936     }
40937     if (ctx->enc_packmode == '@') {
40938       size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
40939       size_t align_mod_offset;
40940       if (align_at == 0) return -1;
40941       align_mod_offset = ctx->fmt_offset % align_at;
40942       if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
40943       if (ctx->struct_alignment == 0)
40944           ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
40945                                                                  ctx->is_complex);
40946     }
40947     if (type->size != size || type->typegroup != group) {
40948       if (type->typegroup == 'C' && type->fields != NULL) {
40949         size_t parent_offset = ctx->head->parent_offset + field->offset;
40950         ++ctx->head;
40951         ctx->head->field = type->fields;
40952         ctx->head->parent_offset = parent_offset;
40953         continue;
40954       }
40955       if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
40956       } else {
40957           __Pyx_BufFmt_RaiseExpected(ctx);
40958           return -1;
40959       }
40960     }
40961     offset = ctx->head->parent_offset + field->offset;
40962     if (ctx->fmt_offset != offset) {
40963       PyErr_Format(PyExc_ValueError,
40964                    "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
40965                    (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
40966       return -1;
40967     }
40968     ctx->fmt_offset += size;
40969     if (arraysize)
40970       ctx->fmt_offset += (arraysize - 1) * size;
40971     --ctx->enc_count;
40972     while (1) {
40973       if (field == &ctx->root) {
40974         ctx->head = NULL;
40975         if (ctx->enc_count != 0) {
40976           __Pyx_BufFmt_RaiseExpected(ctx);
40977           return -1;
40978         }
40979         break;
40980       }
40981       ctx->head->field = ++field;
40982       if (field->type == NULL) {
40983         --ctx->head;
40984         field = ctx->head->field;
40985         continue;
40986       } else if (field->type->typegroup == 'S') {
40987         size_t parent_offset = ctx->head->parent_offset + field->offset;
40988         if (field->type->fields->type == NULL) continue;
40989         field = field->type->fields;
40990         ++ctx->head;
40991         ctx->head->field = field;
40992         ctx->head->parent_offset = parent_offset;
40993         break;
40994       } else {
40995         break;
40996       }
40997     }
40998   } while (ctx->enc_count);
40999   ctx->enc_type = 0;
41000   ctx->is_complex = 0;
41001   return 0;
41002 }
41003 static PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context * ctx,const char ** tsp)41004 __pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
41005 {
41006     const char *ts = *tsp;
41007     int i = 0, number, ndim;
41008     ++ts;
41009     if (ctx->new_count != 1) {
41010         PyErr_SetString(PyExc_ValueError,
41011                         "Cannot handle repeated arrays in format string");
41012         return NULL;
41013     }
41014     if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
41015     ndim = ctx->head->field->type->ndim;
41016     while (*ts && *ts != ')') {
41017         switch (*ts) {
41018             case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
41019             default:  break;
41020         }
41021         number = __Pyx_BufFmt_ExpectNumber(&ts);
41022         if (number == -1) return NULL;
41023         if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
41024             return PyErr_Format(PyExc_ValueError,
41025                         "Expected a dimension of size %zu, got %d",
41026                         ctx->head->field->type->arraysize[i], number);
41027         if (*ts != ',' && *ts != ')')
41028             return PyErr_Format(PyExc_ValueError,
41029                                 "Expected a comma in format string, got '%c'", *ts);
41030         if (*ts == ',') ts++;
41031         i++;
41032     }
41033     if (i != ndim)
41034         return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
41035                             ctx->head->field->type->ndim, i);
41036     if (!*ts) {
41037         PyErr_SetString(PyExc_ValueError,
41038                         "Unexpected end of format string, expected ')'");
41039         return NULL;
41040     }
41041     ctx->is_valid_array = 1;
41042     ctx->new_count = 1;
41043     *tsp = ++ts;
41044     return Py_None;
41045 }
__Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context * ctx,const char * ts)41046 static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
41047   int got_Z = 0;
41048   while (1) {
41049     switch(*ts) {
41050       case 0:
41051         if (ctx->enc_type != 0 && ctx->head == NULL) {
41052           __Pyx_BufFmt_RaiseExpected(ctx);
41053           return NULL;
41054         }
41055         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
41056         if (ctx->head != NULL) {
41057           __Pyx_BufFmt_RaiseExpected(ctx);
41058           return NULL;
41059         }
41060         return ts;
41061       case ' ':
41062       case '\r':
41063       case '\n':
41064         ++ts;
41065         break;
41066       case '<':
41067         if (!__Pyx_Is_Little_Endian()) {
41068           PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
41069           return NULL;
41070         }
41071         ctx->new_packmode = '=';
41072         ++ts;
41073         break;
41074       case '>':
41075       case '!':
41076         if (__Pyx_Is_Little_Endian()) {
41077           PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
41078           return NULL;
41079         }
41080         ctx->new_packmode = '=';
41081         ++ts;
41082         break;
41083       case '=':
41084       case '@':
41085       case '^':
41086         ctx->new_packmode = *ts++;
41087         break;
41088       case 'T':
41089         {
41090           const char* ts_after_sub;
41091           size_t i, struct_count = ctx->new_count;
41092           size_t struct_alignment = ctx->struct_alignment;
41093           ctx->new_count = 1;
41094           ++ts;
41095           if (*ts != '{') {
41096             PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
41097             return NULL;
41098           }
41099           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
41100           ctx->enc_type = 0;
41101           ctx->enc_count = 0;
41102           ctx->struct_alignment = 0;
41103           ++ts;
41104           ts_after_sub = ts;
41105           for (i = 0; i != struct_count; ++i) {
41106             ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
41107             if (!ts_after_sub) return NULL;
41108           }
41109           ts = ts_after_sub;
41110           if (struct_alignment) ctx->struct_alignment = struct_alignment;
41111         }
41112         break;
41113       case '}':
41114         {
41115           size_t alignment = ctx->struct_alignment;
41116           ++ts;
41117           if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
41118           ctx->enc_type = 0;
41119           if (alignment && ctx->fmt_offset % alignment) {
41120             ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
41121           }
41122         }
41123         return ts;
41124       case 'x':
41125         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
41126         ctx->fmt_offset += ctx->new_count;
41127         ctx->new_count = 1;
41128         ctx->enc_count = 0;
41129         ctx->enc_type = 0;
41130         ctx->enc_packmode = ctx->new_packmode;
41131         ++ts;
41132         break;
41133       case 'Z':
41134         got_Z = 1;
41135         ++ts;
41136         if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
41137           __Pyx_BufFmt_RaiseUnexpectedChar('Z');
41138           return NULL;
41139         }
41140         CYTHON_FALLTHROUGH;
41141       case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
41142       case 'l': case 'L': case 'q': case 'Q':
41143       case 'f': case 'd': case 'g':
41144       case 'O': case 'p':
41145         if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) &&
41146             (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) {
41147           ctx->enc_count += ctx->new_count;
41148           ctx->new_count = 1;
41149           got_Z = 0;
41150           ++ts;
41151           break;
41152         }
41153         CYTHON_FALLTHROUGH;
41154       case 's':
41155         if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
41156         ctx->enc_count = ctx->new_count;
41157         ctx->enc_packmode = ctx->new_packmode;
41158         ctx->enc_type = *ts;
41159         ctx->is_complex = got_Z;
41160         ++ts;
41161         ctx->new_count = 1;
41162         got_Z = 0;
41163         break;
41164       case ':':
41165         ++ts;
41166         while(*ts != ':') ++ts;
41167         ++ts;
41168         break;
41169       case '(':
41170         if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
41171         break;
41172       default:
41173         {
41174           int number = __Pyx_BufFmt_ExpectNumber(&ts);
41175           if (number == -1) return NULL;
41176           ctx->new_count = (size_t)number;
41177         }
41178     }
41179   }
41180 }
41181 
41182 /* TypeInfoCompare */
41183   static int
__pyx_typeinfo_cmp(__Pyx_TypeInfo * a,__Pyx_TypeInfo * b)41184 __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
41185 {
41186     int i;
41187     if (!a || !b)
41188         return 0;
41189     if (a == b)
41190         return 1;
41191     if (a->size != b->size || a->typegroup != b->typegroup ||
41192             a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
41193         if (a->typegroup == 'H' || b->typegroup == 'H') {
41194             return a->size == b->size;
41195         } else {
41196             return 0;
41197         }
41198     }
41199     if (a->ndim) {
41200         for (i = 0; i < a->ndim; i++)
41201             if (a->arraysize[i] != b->arraysize[i])
41202                 return 0;
41203     }
41204     if (a->typegroup == 'S') {
41205         if (a->flags != b->flags)
41206             return 0;
41207         if (a->fields || b->fields) {
41208             if (!(a->fields && b->fields))
41209                 return 0;
41210             for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
41211                 __Pyx_StructField *field_a = a->fields + i;
41212                 __Pyx_StructField *field_b = b->fields + i;
41213                 if (field_a->offset != field_b->offset ||
41214                     !__pyx_typeinfo_cmp(field_a->type, field_b->type))
41215                     return 0;
41216             }
41217             return !a->fields[i].type && !b->fields[i].type;
41218         }
41219     }
41220     return 1;
41221 }
41222 
41223 /* MemviewSliceValidateAndInit */
41224   static int
__pyx_check_strides(Py_buffer * buf,int dim,int ndim,int spec)41225 __pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
41226 {
41227     if (buf->shape[dim] <= 1)
41228         return 1;
41229     if (buf->strides) {
41230         if (spec & __Pyx_MEMVIEW_CONTIG) {
41231             if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
41232                 if (unlikely(buf->strides[dim] != sizeof(void *))) {
41233                     PyErr_Format(PyExc_ValueError,
41234                                  "Buffer is not indirectly contiguous "
41235                                  "in dimension %d.", dim);
41236                     goto fail;
41237                 }
41238             } else if (unlikely(buf->strides[dim] != buf->itemsize)) {
41239                 PyErr_SetString(PyExc_ValueError,
41240                                 "Buffer and memoryview are not contiguous "
41241                                 "in the same dimension.");
41242                 goto fail;
41243             }
41244         }
41245         if (spec & __Pyx_MEMVIEW_FOLLOW) {
41246             Py_ssize_t stride = buf->strides[dim];
41247             if (stride < 0)
41248                 stride = -stride;
41249             if (unlikely(stride < buf->itemsize)) {
41250                 PyErr_SetString(PyExc_ValueError,
41251                                 "Buffer and memoryview are not contiguous "
41252                                 "in the same dimension.");
41253                 goto fail;
41254             }
41255         }
41256     } else {
41257         if (unlikely(spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1)) {
41258             PyErr_Format(PyExc_ValueError,
41259                          "C-contiguous buffer is not contiguous in "
41260                          "dimension %d", dim);
41261             goto fail;
41262         } else if (unlikely(spec & (__Pyx_MEMVIEW_PTR))) {
41263             PyErr_Format(PyExc_ValueError,
41264                          "C-contiguous buffer is not indirect in "
41265                          "dimension %d", dim);
41266             goto fail;
41267         } else if (unlikely(buf->suboffsets)) {
41268             PyErr_SetString(PyExc_ValueError,
41269                             "Buffer exposes suboffsets but no strides");
41270             goto fail;
41271         }
41272     }
41273     return 1;
41274 fail:
41275     return 0;
41276 }
41277 static int
__pyx_check_suboffsets(Py_buffer * buf,int dim,CYTHON_UNUSED int ndim,int spec)41278 __pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
41279 {
41280     if (spec & __Pyx_MEMVIEW_DIRECT) {
41281         if (unlikely(buf->suboffsets && buf->suboffsets[dim] >= 0)) {
41282             PyErr_Format(PyExc_ValueError,
41283                          "Buffer not compatible with direct access "
41284                          "in dimension %d.", dim);
41285             goto fail;
41286         }
41287     }
41288     if (spec & __Pyx_MEMVIEW_PTR) {
41289         if (unlikely(!buf->suboffsets || (buf->suboffsets[dim] < 0))) {
41290             PyErr_Format(PyExc_ValueError,
41291                          "Buffer is not indirectly accessible "
41292                          "in dimension %d.", dim);
41293             goto fail;
41294         }
41295     }
41296     return 1;
41297 fail:
41298     return 0;
41299 }
41300 static int
__pyx_verify_contig(Py_buffer * buf,int ndim,int c_or_f_flag)41301 __pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
41302 {
41303     int i;
41304     if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
41305         Py_ssize_t stride = 1;
41306         for (i = 0; i < ndim; i++) {
41307             if (unlikely(stride * buf->itemsize != buf->strides[i]  &&  buf->shape[i] > 1)) {
41308                 PyErr_SetString(PyExc_ValueError,
41309                     "Buffer not fortran contiguous.");
41310                 goto fail;
41311             }
41312             stride = stride * buf->shape[i];
41313         }
41314     } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
41315         Py_ssize_t stride = 1;
41316         for (i = ndim - 1; i >- 1; i--) {
41317             if (unlikely(stride * buf->itemsize != buf->strides[i]  &&  buf->shape[i] > 1)) {
41318                 PyErr_SetString(PyExc_ValueError,
41319                     "Buffer not C contiguous.");
41320                 goto fail;
41321             }
41322             stride = stride * buf->shape[i];
41323         }
41324     }
41325     return 1;
41326 fail:
41327     return 0;
41328 }
__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)41329 static int __Pyx_ValidateAndInit_memviewslice(
41330                 int *axes_specs,
41331                 int c_or_f_flag,
41332                 int buf_flags,
41333                 int ndim,
41334                 __Pyx_TypeInfo *dtype,
41335                 __Pyx_BufFmt_StackElem stack[],
41336                 __Pyx_memviewslice *memviewslice,
41337                 PyObject *original_obj)
41338 {
41339     struct __pyx_memoryview_obj *memview, *new_memview;
41340     __Pyx_RefNannyDeclarations
41341     Py_buffer *buf;
41342     int i, spec = 0, retval = -1;
41343     __Pyx_BufFmt_Context ctx;
41344     int from_memoryview = __pyx_memoryview_check(original_obj);
41345     __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
41346     if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
41347                                                             original_obj)->typeinfo)) {
41348         memview = (struct __pyx_memoryview_obj *) original_obj;
41349         new_memview = NULL;
41350     } else {
41351         memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
41352                                             original_obj, buf_flags, 0, dtype);
41353         new_memview = memview;
41354         if (unlikely(!memview))
41355             goto fail;
41356     }
41357     buf = &memview->view;
41358     if (unlikely(buf->ndim != ndim)) {
41359         PyErr_Format(PyExc_ValueError,
41360                 "Buffer has wrong number of dimensions (expected %d, got %d)",
41361                 ndim, buf->ndim);
41362         goto fail;
41363     }
41364     if (new_memview) {
41365         __Pyx_BufFmt_Init(&ctx, stack, dtype);
41366         if (unlikely(!__Pyx_BufFmt_CheckString(&ctx, buf->format))) goto fail;
41367     }
41368     if (unlikely((unsigned) buf->itemsize != dtype->size)) {
41369         PyErr_Format(PyExc_ValueError,
41370                      "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) "
41371                      "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
41372                      buf->itemsize,
41373                      (buf->itemsize > 1) ? "s" : "",
41374                      dtype->name,
41375                      dtype->size,
41376                      (dtype->size > 1) ? "s" : "");
41377         goto fail;
41378     }
41379     if (buf->len > 0) {
41380         for (i = 0; i < ndim; i++) {
41381             spec = axes_specs[i];
41382             if (unlikely(!__pyx_check_strides(buf, i, ndim, spec)))
41383                 goto fail;
41384             if (unlikely(!__pyx_check_suboffsets(buf, i, ndim, spec)))
41385                 goto fail;
41386         }
41387         if (unlikely(buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag)))
41388             goto fail;
41389     }
41390     if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
41391                                          new_memview != NULL) == -1)) {
41392         goto fail;
41393     }
41394     retval = 0;
41395     goto no_fail;
41396 fail:
41397     Py_XDECREF(new_memview);
41398     retval = -1;
41399 no_fail:
41400     __Pyx_RefNannyFinishContext();
41401     return retval;
41402 }
41403 
41404 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dsds_float(PyObject * obj,int writable_flag)41405   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_float(PyObject *obj, int writable_flag) {
41406     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
41407     __Pyx_BufFmt_StackElem stack[1];
41408     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
41409     int retcode;
41410     if (obj == Py_None) {
41411         result.memview = (struct __pyx_memoryview_obj *) Py_None;
41412         return result;
41413     }
41414     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
41415                                                  PyBUF_RECORDS_RO | writable_flag, 2,
41416                                                  &__Pyx_TypeInfo_float, stack,
41417                                                  &result, obj);
41418     if (unlikely(retcode == -1))
41419         goto __pyx_fail;
41420     return result;
41421 __pyx_fail:
41422     result.memview = NULL;
41423     result.data = NULL;
41424     return result;
41425 }
41426 
41427 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dsds_double(PyObject * obj,int writable_flag)41428   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsds_double(PyObject *obj, int writable_flag) {
41429     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
41430     __Pyx_BufFmt_StackElem stack[1];
41431     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
41432     int retcode;
41433     if (obj == Py_None) {
41434         result.memview = (struct __pyx_memoryview_obj *) Py_None;
41435         return result;
41436     }
41437     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
41438                                                  PyBUF_RECORDS_RO | writable_flag, 2,
41439                                                  &__Pyx_TypeInfo_double, stack,
41440                                                  &result, obj);
41441     if (unlikely(retcode == -1))
41442         goto __pyx_fail;
41443     return result;
41444 __pyx_fail:
41445     result.memview = NULL;
41446     result.data = NULL;
41447     return result;
41448 }
41449 
41450 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(PyObject * obj,int writable_flag)41451   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(PyObject *obj, int writable_flag) {
41452     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
41453     __Pyx_BufFmt_StackElem stack[1];
41454     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
41455     int retcode;
41456     if (obj == Py_None) {
41457         result.memview = (struct __pyx_memoryview_obj *) Py_None;
41458         return result;
41459     }
41460     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
41461                                                  PyBUF_RECORDS_RO | writable_flag, 3,
41462                                                  &__Pyx_TypeInfo_float, stack,
41463                                                  &result, obj);
41464     if (unlikely(retcode == -1))
41465         goto __pyx_fail;
41466     return result;
41467 __pyx_fail:
41468     result.memview = NULL;
41469     result.data = NULL;
41470     return result;
41471 }
41472 
41473 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(PyObject * obj,int writable_flag)41474   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsdsds_double(PyObject *obj, int writable_flag) {
41475     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
41476     __Pyx_BufFmt_StackElem stack[1];
41477     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
41478     int retcode;
41479     if (obj == Py_None) {
41480         result.memview = (struct __pyx_memoryview_obj *) Py_None;
41481         return result;
41482     }
41483     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
41484                                                  PyBUF_RECORDS_RO | writable_flag, 3,
41485                                                  &__Pyx_TypeInfo_double, stack,
41486                                                  &result, obj);
41487     if (unlikely(retcode == -1))
41488         goto __pyx_fail;
41489     return result;
41490 __pyx_fail:
41491     result.memview = NULL;
41492     result.data = NULL;
41493     return result;
41494 }
41495 
41496 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(PyObject * obj,int writable_flag)41497   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(PyObject *obj, int writable_flag) {
41498     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
41499     __Pyx_BufFmt_StackElem stack[1];
41500     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
41501     int retcode;
41502     if (obj == Py_None) {
41503         result.memview = (struct __pyx_memoryview_obj *) Py_None;
41504         return result;
41505     }
41506     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
41507                                                  PyBUF_RECORDS_RO | writable_flag, 4,
41508                                                  &__Pyx_TypeInfo_float, stack,
41509                                                  &result, obj);
41510     if (unlikely(retcode == -1))
41511         goto __pyx_fail;
41512     return result;
41513 __pyx_fail:
41514     result.memview = NULL;
41515     result.data = NULL;
41516     return result;
41517 }
41518 
41519 /* ObjectToMemviewSlice */
__Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(PyObject * obj,int writable_flag)41520   static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_double(PyObject *obj, int writable_flag) {
41521     __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
41522     __Pyx_BufFmt_StackElem stack[1];
41523     int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_STRIDED) };
41524     int retcode;
41525     if (obj == Py_None) {
41526         result.memview = (struct __pyx_memoryview_obj *) Py_None;
41527         return result;
41528     }
41529     retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, 0,
41530                                                  PyBUF_RECORDS_RO | writable_flag, 4,
41531                                                  &__Pyx_TypeInfo_double, stack,
41532                                                  &result, obj);
41533     if (unlikely(retcode == -1))
41534         goto __pyx_fail;
41535     return result;
41536 __pyx_fail:
41537     result.memview = NULL;
41538     result.data = NULL;
41539     return result;
41540 }
41541 
41542 /* MemviewDtypeToObject */
__pyx_memview_get_float(const char * itemp)41543   static CYTHON_INLINE PyObject *__pyx_memview_get_float(const char *itemp) {
41544     return (PyObject *) PyFloat_FromDouble(*(float *) itemp);
41545 }
__pyx_memview_set_float(const char * itemp,PyObject * obj)41546 static CYTHON_INLINE int __pyx_memview_set_float(const char *itemp, PyObject *obj) {
41547     float value = __pyx_PyFloat_AsFloat(obj);
41548     if ((value == (float)-1) && PyErr_Occurred())
41549         return 0;
41550     *(float *) itemp = value;
41551     return 1;
41552 }
41553 
41554 /* CIntFromPyVerify */
41555   #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
41556     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
41557 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
41558     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
41559 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
41560     {\
41561         func_type value = func_value;\
41562         if (sizeof(target_type) < sizeof(func_type)) {\
41563             if (unlikely(value != (func_type) (target_type) value)) {\
41564                 func_type zero = 0;\
41565                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
41566                     return (target_type) -1;\
41567                 if (is_unsigned && unlikely(value < zero))\
41568                     goto raise_neg_overflow;\
41569                 else\
41570                     goto raise_overflow;\
41571             }\
41572         }\
41573         return (target_type) value;\
41574     }
41575 
41576 /* MemviewDtypeToObject */
__pyx_memview_get_double(const char * itemp)41577   static CYTHON_INLINE PyObject *__pyx_memview_get_double(const char *itemp) {
41578     return (PyObject *) PyFloat_FromDouble(*(double *) itemp);
41579 }
__pyx_memview_set_double(const char * itemp,PyObject * obj)41580 static CYTHON_INLINE int __pyx_memview_set_double(const char *itemp, PyObject *obj) {
41581     double value = __pyx_PyFloat_AsDouble(obj);
41582     if ((value == (double)-1) && PyErr_Occurred())
41583         return 0;
41584     *(double *) itemp = value;
41585     return 1;
41586 }
41587 
41588 /* Declarations */
41589   #if CYTHON_CCOMPLEX
41590   #ifdef __cplusplus
__pyx_t_float_complex_from_parts(float x,float y)41591     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
41592       return ::std::complex< float >(x, y);
41593     }
41594   #else
__pyx_t_float_complex_from_parts(float x,float y)41595     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
41596       return x + y*(__pyx_t_float_complex)_Complex_I;
41597     }
41598   #endif
41599 #else
__pyx_t_float_complex_from_parts(float x,float y)41600     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
41601       __pyx_t_float_complex z;
41602       z.real = x;
41603       z.imag = y;
41604       return z;
41605     }
41606 #endif
41607 
41608 /* Arithmetic */
41609   #if CYTHON_CCOMPLEX
41610 #else
__Pyx_c_eq_float(__pyx_t_float_complex a,__pyx_t_float_complex b)41611     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
41612        return (a.real == b.real) && (a.imag == b.imag);
41613     }
__Pyx_c_sum_float(__pyx_t_float_complex a,__pyx_t_float_complex b)41614     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
41615         __pyx_t_float_complex z;
41616         z.real = a.real + b.real;
41617         z.imag = a.imag + b.imag;
41618         return z;
41619     }
__Pyx_c_diff_float(__pyx_t_float_complex a,__pyx_t_float_complex b)41620     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
41621         __pyx_t_float_complex z;
41622         z.real = a.real - b.real;
41623         z.imag = a.imag - b.imag;
41624         return z;
41625     }
__Pyx_c_prod_float(__pyx_t_float_complex a,__pyx_t_float_complex b)41626     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
41627         __pyx_t_float_complex z;
41628         z.real = a.real * b.real - a.imag * b.imag;
41629         z.imag = a.real * b.imag + a.imag * b.real;
41630         return z;
41631     }
41632     #if 1
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)41633     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
41634         if (b.imag == 0) {
41635             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
41636         } else if (fabsf(b.real) >= fabsf(b.imag)) {
41637             if (b.real == 0 && b.imag == 0) {
41638                 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
41639             } else {
41640                 float r = b.imag / b.real;
41641                 float s = (float)(1.0) / (b.real + b.imag * r);
41642                 return __pyx_t_float_complex_from_parts(
41643                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
41644             }
41645         } else {
41646             float r = b.real / b.imag;
41647             float s = (float)(1.0) / (b.imag + b.real * r);
41648             return __pyx_t_float_complex_from_parts(
41649                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
41650         }
41651     }
41652     #else
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)41653     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
41654         if (b.imag == 0) {
41655             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
41656         } else {
41657             float denom = b.real * b.real + b.imag * b.imag;
41658             return __pyx_t_float_complex_from_parts(
41659                 (a.real * b.real + a.imag * b.imag) / denom,
41660                 (a.imag * b.real - a.real * b.imag) / denom);
41661         }
41662     }
41663     #endif
__Pyx_c_neg_float(__pyx_t_float_complex a)41664     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
41665         __pyx_t_float_complex z;
41666         z.real = -a.real;
41667         z.imag = -a.imag;
41668         return z;
41669     }
__Pyx_c_is_zero_float(__pyx_t_float_complex a)41670     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
41671        return (a.real == 0) && (a.imag == 0);
41672     }
__Pyx_c_conj_float(__pyx_t_float_complex a)41673     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
41674         __pyx_t_float_complex z;
41675         z.real =  a.real;
41676         z.imag = -a.imag;
41677         return z;
41678     }
41679     #if 1
__Pyx_c_abs_float(__pyx_t_float_complex z)41680         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
41681           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
41682             return sqrtf(z.real*z.real + z.imag*z.imag);
41683           #else
41684             return hypotf(z.real, z.imag);
41685           #endif
41686         }
__Pyx_c_pow_float(__pyx_t_float_complex a,__pyx_t_float_complex b)41687         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
41688             __pyx_t_float_complex z;
41689             float r, lnr, theta, z_r, z_theta;
41690             if (b.imag == 0 && b.real == (int)b.real) {
41691                 if (b.real < 0) {
41692                     float denom = a.real * a.real + a.imag * a.imag;
41693                     a.real = a.real / denom;
41694                     a.imag = -a.imag / denom;
41695                     b.real = -b.real;
41696                 }
41697                 switch ((int)b.real) {
41698                     case 0:
41699                         z.real = 1;
41700                         z.imag = 0;
41701                         return z;
41702                     case 1:
41703                         return a;
41704                     case 2:
41705                         return __Pyx_c_prod_float(a, a);
41706                     case 3:
41707                         z = __Pyx_c_prod_float(a, a);
41708                         return __Pyx_c_prod_float(z, a);
41709                     case 4:
41710                         z = __Pyx_c_prod_float(a, a);
41711                         return __Pyx_c_prod_float(z, z);
41712                 }
41713             }
41714             if (a.imag == 0) {
41715                 if (a.real == 0) {
41716                     return a;
41717                 } else if (b.imag == 0) {
41718                     z.real = powf(a.real, b.real);
41719                     z.imag = 0;
41720                     return z;
41721                 } else if (a.real > 0) {
41722                     r = a.real;
41723                     theta = 0;
41724                 } else {
41725                     r = -a.real;
41726                     theta = atan2f(0.0, -1.0);
41727                 }
41728             } else {
41729                 r = __Pyx_c_abs_float(a);
41730                 theta = atan2f(a.imag, a.real);
41731             }
41732             lnr = logf(r);
41733             z_r = expf(lnr * b.real - theta * b.imag);
41734             z_theta = theta * b.real + lnr * b.imag;
41735             z.real = z_r * cosf(z_theta);
41736             z.imag = z_r * sinf(z_theta);
41737             return z;
41738         }
41739     #endif
41740 #endif
41741 
41742 /* Declarations */
41743   #if CYTHON_CCOMPLEX
41744   #ifdef __cplusplus
__pyx_t_double_complex_from_parts(double x,double y)41745     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
41746       return ::std::complex< double >(x, y);
41747     }
41748   #else
__pyx_t_double_complex_from_parts(double x,double y)41749     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
41750       return x + y*(__pyx_t_double_complex)_Complex_I;
41751     }
41752   #endif
41753 #else
__pyx_t_double_complex_from_parts(double x,double y)41754     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
41755       __pyx_t_double_complex z;
41756       z.real = x;
41757       z.imag = y;
41758       return z;
41759     }
41760 #endif
41761 
41762 /* Arithmetic */
41763   #if CYTHON_CCOMPLEX
41764 #else
__Pyx_c_eq_double(__pyx_t_double_complex a,__pyx_t_double_complex b)41765     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
41766        return (a.real == b.real) && (a.imag == b.imag);
41767     }
__Pyx_c_sum_double(__pyx_t_double_complex a,__pyx_t_double_complex b)41768     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
41769         __pyx_t_double_complex z;
41770         z.real = a.real + b.real;
41771         z.imag = a.imag + b.imag;
41772         return z;
41773     }
__Pyx_c_diff_double(__pyx_t_double_complex a,__pyx_t_double_complex b)41774     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
41775         __pyx_t_double_complex z;
41776         z.real = a.real - b.real;
41777         z.imag = a.imag - b.imag;
41778         return z;
41779     }
__Pyx_c_prod_double(__pyx_t_double_complex a,__pyx_t_double_complex b)41780     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
41781         __pyx_t_double_complex z;
41782         z.real = a.real * b.real - a.imag * b.imag;
41783         z.imag = a.real * b.imag + a.imag * b.real;
41784         return z;
41785     }
41786     #if 1
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)41787     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
41788         if (b.imag == 0) {
41789             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
41790         } else if (fabs(b.real) >= fabs(b.imag)) {
41791             if (b.real == 0 && b.imag == 0) {
41792                 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
41793             } else {
41794                 double r = b.imag / b.real;
41795                 double s = (double)(1.0) / (b.real + b.imag * r);
41796                 return __pyx_t_double_complex_from_parts(
41797                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
41798             }
41799         } else {
41800             double r = b.real / b.imag;
41801             double s = (double)(1.0) / (b.imag + b.real * r);
41802             return __pyx_t_double_complex_from_parts(
41803                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
41804         }
41805     }
41806     #else
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)41807     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
41808         if (b.imag == 0) {
41809             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
41810         } else {
41811             double denom = b.real * b.real + b.imag * b.imag;
41812             return __pyx_t_double_complex_from_parts(
41813                 (a.real * b.real + a.imag * b.imag) / denom,
41814                 (a.imag * b.real - a.real * b.imag) / denom);
41815         }
41816     }
41817     #endif
__Pyx_c_neg_double(__pyx_t_double_complex a)41818     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
41819         __pyx_t_double_complex z;
41820         z.real = -a.real;
41821         z.imag = -a.imag;
41822         return z;
41823     }
__Pyx_c_is_zero_double(__pyx_t_double_complex a)41824     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
41825        return (a.real == 0) && (a.imag == 0);
41826     }
__Pyx_c_conj_double(__pyx_t_double_complex a)41827     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
41828         __pyx_t_double_complex z;
41829         z.real =  a.real;
41830         z.imag = -a.imag;
41831         return z;
41832     }
41833     #if 1
__Pyx_c_abs_double(__pyx_t_double_complex z)41834         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
41835           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
41836             return sqrt(z.real*z.real + z.imag*z.imag);
41837           #else
41838             return hypot(z.real, z.imag);
41839           #endif
41840         }
__Pyx_c_pow_double(__pyx_t_double_complex a,__pyx_t_double_complex b)41841         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
41842             __pyx_t_double_complex z;
41843             double r, lnr, theta, z_r, z_theta;
41844             if (b.imag == 0 && b.real == (int)b.real) {
41845                 if (b.real < 0) {
41846                     double denom = a.real * a.real + a.imag * a.imag;
41847                     a.real = a.real / denom;
41848                     a.imag = -a.imag / denom;
41849                     b.real = -b.real;
41850                 }
41851                 switch ((int)b.real) {
41852                     case 0:
41853                         z.real = 1;
41854                         z.imag = 0;
41855                         return z;
41856                     case 1:
41857                         return a;
41858                     case 2:
41859                         return __Pyx_c_prod_double(a, a);
41860                     case 3:
41861                         z = __Pyx_c_prod_double(a, a);
41862                         return __Pyx_c_prod_double(z, a);
41863                     case 4:
41864                         z = __Pyx_c_prod_double(a, a);
41865                         return __Pyx_c_prod_double(z, z);
41866                 }
41867             }
41868             if (a.imag == 0) {
41869                 if (a.real == 0) {
41870                     return a;
41871                 } else if (b.imag == 0) {
41872                     z.real = pow(a.real, b.real);
41873                     z.imag = 0;
41874                     return z;
41875                 } else if (a.real > 0) {
41876                     r = a.real;
41877                     theta = 0;
41878                 } else {
41879                     r = -a.real;
41880                     theta = atan2(0.0, -1.0);
41881                 }
41882             } else {
41883                 r = __Pyx_c_abs_double(a);
41884                 theta = atan2(a.imag, a.real);
41885             }
41886             lnr = log(r);
41887             z_r = exp(lnr * b.real - theta * b.imag);
41888             z_theta = theta * b.real + lnr * b.imag;
41889             z.real = z_r * cos(z_theta);
41890             z.imag = z_r * sin(z_theta);
41891             return z;
41892         }
41893     #endif
41894 #endif
41895 
41896 /* MemviewSliceCopyTemplate */
41897   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)41898 __pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
41899                                  const char *mode, int ndim,
41900                                  size_t sizeof_dtype, int contig_flag,
41901                                  int dtype_is_object)
41902 {
41903     __Pyx_RefNannyDeclarations
41904     int i;
41905     __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } };
41906     struct __pyx_memoryview_obj *from_memview = from_mvs->memview;
41907     Py_buffer *buf = &from_memview->view;
41908     PyObject *shape_tuple = NULL;
41909     PyObject *temp_int = NULL;
41910     struct __pyx_array_obj *array_obj = NULL;
41911     struct __pyx_memoryview_obj *memview_obj = NULL;
41912     __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0);
41913     for (i = 0; i < ndim; i++) {
41914         if (unlikely(from_mvs->suboffsets[i] >= 0)) {
41915             PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with "
41916                                            "indirect dimensions (axis %d)", i);
41917             goto fail;
41918         }
41919     }
41920     shape_tuple = PyTuple_New(ndim);
41921     if (unlikely(!shape_tuple)) {
41922         goto fail;
41923     }
41924     __Pyx_GOTREF(shape_tuple);
41925     for(i = 0; i < ndim; i++) {
41926         temp_int = PyInt_FromSsize_t(from_mvs->shape[i]);
41927         if(unlikely(!temp_int)) {
41928             goto fail;
41929         } else {
41930             PyTuple_SET_ITEM(shape_tuple, i, temp_int);
41931             temp_int = NULL;
41932         }
41933     }
41934     array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL);
41935     if (unlikely(!array_obj)) {
41936         goto fail;
41937     }
41938     __Pyx_GOTREF(array_obj);
41939     memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
41940                                     (PyObject *) array_obj, contig_flag,
41941                                     dtype_is_object,
41942                                     from_mvs->memview->typeinfo);
41943     if (unlikely(!memview_obj))
41944         goto fail;
41945     if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0))
41946         goto fail;
41947     if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim,
41948                                                 dtype_is_object) < 0))
41949         goto fail;
41950     goto no_fail;
41951 fail:
41952     __Pyx_XDECREF(new_mvs.memview);
41953     new_mvs.memview = NULL;
41954     new_mvs.data = NULL;
41955 no_fail:
41956     __Pyx_XDECREF(shape_tuple);
41957     __Pyx_XDECREF(temp_int);
41958     __Pyx_XDECREF(array_obj);
41959     __Pyx_RefNannyFinishContext();
41960     return new_mvs;
41961 }
41962 
41963 /* CIntToPy */
__Pyx_PyInt_From_int(int value)41964   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
41965 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
41966 #pragma GCC diagnostic push
41967 #pragma GCC diagnostic ignored "-Wconversion"
41968 #endif
41969     const int neg_one = (int) -1, const_zero = (int) 0;
41970 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
41971 #pragma GCC diagnostic pop
41972 #endif
41973     const int is_unsigned = neg_one > const_zero;
41974     if (is_unsigned) {
41975         if (sizeof(int) < sizeof(long)) {
41976             return PyInt_FromLong((long) value);
41977         } else if (sizeof(int) <= sizeof(unsigned long)) {
41978             return PyLong_FromUnsignedLong((unsigned long) value);
41979 #ifdef HAVE_LONG_LONG
41980         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
41981             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
41982 #endif
41983         }
41984     } else {
41985         if (sizeof(int) <= sizeof(long)) {
41986             return PyInt_FromLong((long) value);
41987 #ifdef HAVE_LONG_LONG
41988         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
41989             return PyLong_FromLongLong((PY_LONG_LONG) value);
41990 #endif
41991         }
41992     }
41993     {
41994         int one = 1; int little = (int)*(unsigned char *)&one;
41995         unsigned char *bytes = (unsigned char *)&value;
41996         return _PyLong_FromByteArray(bytes, sizeof(int),
41997                                      little, !is_unsigned);
41998     }
41999 }
42000 
42001 /* CIntToPy */
__Pyx_PyInt_From_long(long value)42002   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
42003 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42004 #pragma GCC diagnostic push
42005 #pragma GCC diagnostic ignored "-Wconversion"
42006 #endif
42007     const long neg_one = (long) -1, const_zero = (long) 0;
42008 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42009 #pragma GCC diagnostic pop
42010 #endif
42011     const int is_unsigned = neg_one > const_zero;
42012     if (is_unsigned) {
42013         if (sizeof(long) < sizeof(long)) {
42014             return PyInt_FromLong((long) value);
42015         } else if (sizeof(long) <= sizeof(unsigned long)) {
42016             return PyLong_FromUnsignedLong((unsigned long) value);
42017 #ifdef HAVE_LONG_LONG
42018         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
42019             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
42020 #endif
42021         }
42022     } else {
42023         if (sizeof(long) <= sizeof(long)) {
42024             return PyInt_FromLong((long) value);
42025 #ifdef HAVE_LONG_LONG
42026         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
42027             return PyLong_FromLongLong((PY_LONG_LONG) value);
42028 #endif
42029         }
42030     }
42031     {
42032         int one = 1; int little = (int)*(unsigned char *)&one;
42033         unsigned char *bytes = (unsigned char *)&value;
42034         return _PyLong_FromByteArray(bytes, sizeof(long),
42035                                      little, !is_unsigned);
42036     }
42037 }
42038 
42039 /* BytesContains */
__Pyx_BytesContains(PyObject * bytes,char character)42040   static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character) {
42041     const Py_ssize_t length = PyBytes_GET_SIZE(bytes);
42042     char* char_start = PyBytes_AS_STRING(bytes);
42043     return memchr(char_start, (unsigned char)character, (size_t)length) != NULL;
42044 }
42045 
42046 /* CIntToPy */
__Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value)42047   static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) {
42048 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42049 #pragma GCC diagnostic push
42050 #pragma GCC diagnostic ignored "-Wconversion"
42051 #endif
42052     const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = (Py_intptr_t) 0;
42053 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42054 #pragma GCC diagnostic pop
42055 #endif
42056     const int is_unsigned = neg_one > const_zero;
42057     if (is_unsigned) {
42058         if (sizeof(Py_intptr_t) < sizeof(long)) {
42059             return PyInt_FromLong((long) value);
42060         } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) {
42061             return PyLong_FromUnsignedLong((unsigned long) value);
42062 #ifdef HAVE_LONG_LONG
42063         } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) {
42064             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
42065 #endif
42066         }
42067     } else {
42068         if (sizeof(Py_intptr_t) <= sizeof(long)) {
42069             return PyInt_FromLong((long) value);
42070 #ifdef HAVE_LONG_LONG
42071         } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) {
42072             return PyLong_FromLongLong((PY_LONG_LONG) value);
42073 #endif
42074         }
42075     }
42076     {
42077         int one = 1; int little = (int)*(unsigned char *)&one;
42078         unsigned char *bytes = (unsigned char *)&value;
42079         return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t),
42080                                      little, !is_unsigned);
42081     }
42082 }
42083 
42084 /* CIntFromPy */
__Pyx_PyInt_As_Py_intptr_t(PyObject * x)42085   static CYTHON_INLINE Py_intptr_t __Pyx_PyInt_As_Py_intptr_t(PyObject *x) {
42086 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42087 #pragma GCC diagnostic push
42088 #pragma GCC diagnostic ignored "-Wconversion"
42089 #endif
42090     const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = (Py_intptr_t) 0;
42091 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42092 #pragma GCC diagnostic pop
42093 #endif
42094     const int is_unsigned = neg_one > const_zero;
42095 #if PY_MAJOR_VERSION < 3
42096     if (likely(PyInt_Check(x))) {
42097         if (sizeof(Py_intptr_t) < sizeof(long)) {
42098             __PYX_VERIFY_RETURN_INT(Py_intptr_t, long, PyInt_AS_LONG(x))
42099         } else {
42100             long val = PyInt_AS_LONG(x);
42101             if (is_unsigned && unlikely(val < 0)) {
42102                 goto raise_neg_overflow;
42103             }
42104             return (Py_intptr_t) val;
42105         }
42106     } else
42107 #endif
42108     if (likely(PyLong_Check(x))) {
42109         if (is_unsigned) {
42110 #if CYTHON_USE_PYLONG_INTERNALS
42111             const digit* digits = ((PyLongObject*)x)->ob_digit;
42112             switch (Py_SIZE(x)) {
42113                 case  0: return (Py_intptr_t) 0;
42114                 case  1: __PYX_VERIFY_RETURN_INT(Py_intptr_t, digit, digits[0])
42115                 case 2:
42116                     if (8 * sizeof(Py_intptr_t) > 1 * PyLong_SHIFT) {
42117                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42118                             __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42119                         } else if (8 * sizeof(Py_intptr_t) >= 2 * PyLong_SHIFT) {
42120                             return (Py_intptr_t) (((((Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0]));
42121                         }
42122                     }
42123                     break;
42124                 case 3:
42125                     if (8 * sizeof(Py_intptr_t) > 2 * PyLong_SHIFT) {
42126                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42127                             __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42128                         } else if (8 * sizeof(Py_intptr_t) >= 3 * PyLong_SHIFT) {
42129                             return (Py_intptr_t) (((((((Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0]));
42130                         }
42131                     }
42132                     break;
42133                 case 4:
42134                     if (8 * sizeof(Py_intptr_t) > 3 * PyLong_SHIFT) {
42135                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42136                             __PYX_VERIFY_RETURN_INT(Py_intptr_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])))
42137                         } else if (8 * sizeof(Py_intptr_t) >= 4 * PyLong_SHIFT) {
42138                             return (Py_intptr_t) (((((((((Py_intptr_t)digits[3]) << PyLong_SHIFT) | (Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0]));
42139                         }
42140                     }
42141                     break;
42142             }
42143 #endif
42144 #if CYTHON_COMPILING_IN_CPYTHON
42145             if (unlikely(Py_SIZE(x) < 0)) {
42146                 goto raise_neg_overflow;
42147             }
42148 #else
42149             {
42150                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
42151                 if (unlikely(result < 0))
42152                     return (Py_intptr_t) -1;
42153                 if (unlikely(result == 1))
42154                     goto raise_neg_overflow;
42155             }
42156 #endif
42157             if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) {
42158                 __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, unsigned long, PyLong_AsUnsignedLong(x))
42159 #ifdef HAVE_LONG_LONG
42160             } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) {
42161                 __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
42162 #endif
42163             }
42164         } else {
42165 #if CYTHON_USE_PYLONG_INTERNALS
42166             const digit* digits = ((PyLongObject*)x)->ob_digit;
42167             switch (Py_SIZE(x)) {
42168                 case  0: return (Py_intptr_t) 0;
42169                 case -1: __PYX_VERIFY_RETURN_INT(Py_intptr_t, sdigit, (sdigit) (-(sdigit)digits[0]))
42170                 case  1: __PYX_VERIFY_RETURN_INT(Py_intptr_t,  digit, +digits[0])
42171                 case -2:
42172                     if (8 * sizeof(Py_intptr_t) - 1 > 1 * PyLong_SHIFT) {
42173                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42174                             __PYX_VERIFY_RETURN_INT(Py_intptr_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42175                         } else if (8 * sizeof(Py_intptr_t) - 1 > 2 * PyLong_SHIFT) {
42176                             return (Py_intptr_t) (((Py_intptr_t)-1)*(((((Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
42177                         }
42178                     }
42179                     break;
42180                 case 2:
42181                     if (8 * sizeof(Py_intptr_t) > 1 * PyLong_SHIFT) {
42182                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42183                             __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42184                         } else if (8 * sizeof(Py_intptr_t) - 1 > 2 * PyLong_SHIFT) {
42185                             return (Py_intptr_t) ((((((Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
42186                         }
42187                     }
42188                     break;
42189                 case -3:
42190                     if (8 * sizeof(Py_intptr_t) - 1 > 2 * PyLong_SHIFT) {
42191                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42192                             __PYX_VERIFY_RETURN_INT(Py_intptr_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42193                         } else if (8 * sizeof(Py_intptr_t) - 1 > 3 * PyLong_SHIFT) {
42194                             return (Py_intptr_t) (((Py_intptr_t)-1)*(((((((Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
42195                         }
42196                     }
42197                     break;
42198                 case 3:
42199                     if (8 * sizeof(Py_intptr_t) > 2 * PyLong_SHIFT) {
42200                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42201                             __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42202                         } else if (8 * sizeof(Py_intptr_t) - 1 > 3 * PyLong_SHIFT) {
42203                             return (Py_intptr_t) ((((((((Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
42204                         }
42205                     }
42206                     break;
42207                 case -4:
42208                     if (8 * sizeof(Py_intptr_t) - 1 > 3 * PyLong_SHIFT) {
42209                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42210                             __PYX_VERIFY_RETURN_INT(Py_intptr_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])))
42211                         } else if (8 * sizeof(Py_intptr_t) - 1 > 4 * PyLong_SHIFT) {
42212                             return (Py_intptr_t) (((Py_intptr_t)-1)*(((((((((Py_intptr_t)digits[3]) << PyLong_SHIFT) | (Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
42213                         }
42214                     }
42215                     break;
42216                 case 4:
42217                     if (8 * sizeof(Py_intptr_t) > 3 * PyLong_SHIFT) {
42218                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42219                             __PYX_VERIFY_RETURN_INT(Py_intptr_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])))
42220                         } else if (8 * sizeof(Py_intptr_t) - 1 > 4 * PyLong_SHIFT) {
42221                             return (Py_intptr_t) ((((((((((Py_intptr_t)digits[3]) << PyLong_SHIFT) | (Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
42222                         }
42223                     }
42224                     break;
42225             }
42226 #endif
42227             if (sizeof(Py_intptr_t) <= sizeof(long)) {
42228                 __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, long, PyLong_AsLong(x))
42229 #ifdef HAVE_LONG_LONG
42230             } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) {
42231                 __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, PY_LONG_LONG, PyLong_AsLongLong(x))
42232 #endif
42233             }
42234         }
42235         {
42236 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
42237             PyErr_SetString(PyExc_RuntimeError,
42238                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
42239 #else
42240             Py_intptr_t val;
42241             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
42242  #if PY_MAJOR_VERSION < 3
42243             if (likely(v) && !PyLong_Check(v)) {
42244                 PyObject *tmp = v;
42245                 v = PyNumber_Long(tmp);
42246                 Py_DECREF(tmp);
42247             }
42248  #endif
42249             if (likely(v)) {
42250                 int one = 1; int is_little = (int)*(unsigned char *)&one;
42251                 unsigned char *bytes = (unsigned char *)&val;
42252                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
42253                                               bytes, sizeof(val),
42254                                               is_little, !is_unsigned);
42255                 Py_DECREF(v);
42256                 if (likely(!ret))
42257                     return val;
42258             }
42259 #endif
42260             return (Py_intptr_t) -1;
42261         }
42262     } else {
42263         Py_intptr_t val;
42264         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
42265         if (!tmp) return (Py_intptr_t) -1;
42266         val = __Pyx_PyInt_As_Py_intptr_t(tmp);
42267         Py_DECREF(tmp);
42268         return val;
42269     }
42270 raise_overflow:
42271     PyErr_SetString(PyExc_OverflowError,
42272         "value too large to convert to Py_intptr_t");
42273     return (Py_intptr_t) -1;
42274 raise_neg_overflow:
42275     PyErr_SetString(PyExc_OverflowError,
42276         "can't convert negative value to Py_intptr_t");
42277     return (Py_intptr_t) -1;
42278 }
42279 
42280 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)42281   static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
42282 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42283 #pragma GCC diagnostic push
42284 #pragma GCC diagnostic ignored "-Wconversion"
42285 #endif
42286     const int neg_one = (int) -1, const_zero = (int) 0;
42287 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42288 #pragma GCC diagnostic pop
42289 #endif
42290     const int is_unsigned = neg_one > const_zero;
42291 #if PY_MAJOR_VERSION < 3
42292     if (likely(PyInt_Check(x))) {
42293         if (sizeof(int) < sizeof(long)) {
42294             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
42295         } else {
42296             long val = PyInt_AS_LONG(x);
42297             if (is_unsigned && unlikely(val < 0)) {
42298                 goto raise_neg_overflow;
42299             }
42300             return (int) val;
42301         }
42302     } else
42303 #endif
42304     if (likely(PyLong_Check(x))) {
42305         if (is_unsigned) {
42306 #if CYTHON_USE_PYLONG_INTERNALS
42307             const digit* digits = ((PyLongObject*)x)->ob_digit;
42308             switch (Py_SIZE(x)) {
42309                 case  0: return (int) 0;
42310                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
42311                 case 2:
42312                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
42313                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42314                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42315                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
42316                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
42317                         }
42318                     }
42319                     break;
42320                 case 3:
42321                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
42322                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42323                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42324                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
42325                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
42326                         }
42327                     }
42328                     break;
42329                 case 4:
42330                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
42331                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42332                             __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])))
42333                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
42334                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
42335                         }
42336                     }
42337                     break;
42338             }
42339 #endif
42340 #if CYTHON_COMPILING_IN_CPYTHON
42341             if (unlikely(Py_SIZE(x) < 0)) {
42342                 goto raise_neg_overflow;
42343             }
42344 #else
42345             {
42346                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
42347                 if (unlikely(result < 0))
42348                     return (int) -1;
42349                 if (unlikely(result == 1))
42350                     goto raise_neg_overflow;
42351             }
42352 #endif
42353             if (sizeof(int) <= sizeof(unsigned long)) {
42354                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
42355 #ifdef HAVE_LONG_LONG
42356             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
42357                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
42358 #endif
42359             }
42360         } else {
42361 #if CYTHON_USE_PYLONG_INTERNALS
42362             const digit* digits = ((PyLongObject*)x)->ob_digit;
42363             switch (Py_SIZE(x)) {
42364                 case  0: return (int) 0;
42365                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
42366                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
42367                 case -2:
42368                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
42369                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42370                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42371                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
42372                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
42373                         }
42374                     }
42375                     break;
42376                 case 2:
42377                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
42378                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42379                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42380                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
42381                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
42382                         }
42383                     }
42384                     break;
42385                 case -3:
42386                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
42387                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42388                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42389                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
42390                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
42391                         }
42392                     }
42393                     break;
42394                 case 3:
42395                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
42396                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42397                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42398                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
42399                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
42400                         }
42401                     }
42402                     break;
42403                 case -4:
42404                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
42405                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42406                             __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])))
42407                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
42408                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
42409                         }
42410                     }
42411                     break;
42412                 case 4:
42413                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
42414                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42415                             __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])))
42416                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
42417                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
42418                         }
42419                     }
42420                     break;
42421             }
42422 #endif
42423             if (sizeof(int) <= sizeof(long)) {
42424                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
42425 #ifdef HAVE_LONG_LONG
42426             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
42427                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
42428 #endif
42429             }
42430         }
42431         {
42432 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
42433             PyErr_SetString(PyExc_RuntimeError,
42434                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
42435 #else
42436             int val;
42437             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
42438  #if PY_MAJOR_VERSION < 3
42439             if (likely(v) && !PyLong_Check(v)) {
42440                 PyObject *tmp = v;
42441                 v = PyNumber_Long(tmp);
42442                 Py_DECREF(tmp);
42443             }
42444  #endif
42445             if (likely(v)) {
42446                 int one = 1; int is_little = (int)*(unsigned char *)&one;
42447                 unsigned char *bytes = (unsigned char *)&val;
42448                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
42449                                               bytes, sizeof(val),
42450                                               is_little, !is_unsigned);
42451                 Py_DECREF(v);
42452                 if (likely(!ret))
42453                     return val;
42454             }
42455 #endif
42456             return (int) -1;
42457         }
42458     } else {
42459         int val;
42460         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
42461         if (!tmp) return (int) -1;
42462         val = __Pyx_PyInt_As_int(tmp);
42463         Py_DECREF(tmp);
42464         return val;
42465     }
42466 raise_overflow:
42467     PyErr_SetString(PyExc_OverflowError,
42468         "value too large to convert to int");
42469     return (int) -1;
42470 raise_neg_overflow:
42471     PyErr_SetString(PyExc_OverflowError,
42472         "can't convert negative value to int");
42473     return (int) -1;
42474 }
42475 
42476 /* ImportNumPyArray */
__Pyx__ImportNumPyArray(void)42477   static PyObject* __Pyx__ImportNumPyArray(void) {
42478     PyObject *numpy_module, *ndarray_object = NULL;
42479     numpy_module = __Pyx_Import(__pyx_n_s_numpy, NULL, 0);
42480     if (likely(numpy_module)) {
42481         ndarray_object = PyObject_GetAttrString(numpy_module, "ndarray");
42482         Py_DECREF(numpy_module);
42483     }
42484     if (unlikely(!ndarray_object)) {
42485         PyErr_Clear();
42486     }
42487     if (unlikely(!ndarray_object || !PyObject_TypeCheck(ndarray_object, &PyType_Type))) {
42488         Py_XDECREF(ndarray_object);
42489         Py_INCREF(Py_None);
42490         ndarray_object = Py_None;
42491     }
42492     return ndarray_object;
42493 }
__Pyx_ImportNumPyArrayTypeIfAvailable(void)42494 static CYTHON_INLINE PyObject* __Pyx_ImportNumPyArrayTypeIfAvailable(void) {
42495     if (unlikely(!__pyx_numpy_ndarray)) {
42496         __pyx_numpy_ndarray = __Pyx__ImportNumPyArray();
42497     }
42498     Py_INCREF(__pyx_numpy_ndarray);
42499     return __pyx_numpy_ndarray;
42500 }
42501 
42502 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)42503   static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
42504 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42505 #pragma GCC diagnostic push
42506 #pragma GCC diagnostic ignored "-Wconversion"
42507 #endif
42508     const long neg_one = (long) -1, const_zero = (long) 0;
42509 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42510 #pragma GCC diagnostic pop
42511 #endif
42512     const int is_unsigned = neg_one > const_zero;
42513 #if PY_MAJOR_VERSION < 3
42514     if (likely(PyInt_Check(x))) {
42515         if (sizeof(long) < sizeof(long)) {
42516             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
42517         } else {
42518             long val = PyInt_AS_LONG(x);
42519             if (is_unsigned && unlikely(val < 0)) {
42520                 goto raise_neg_overflow;
42521             }
42522             return (long) val;
42523         }
42524     } else
42525 #endif
42526     if (likely(PyLong_Check(x))) {
42527         if (is_unsigned) {
42528 #if CYTHON_USE_PYLONG_INTERNALS
42529             const digit* digits = ((PyLongObject*)x)->ob_digit;
42530             switch (Py_SIZE(x)) {
42531                 case  0: return (long) 0;
42532                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
42533                 case 2:
42534                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
42535                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42536                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42537                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
42538                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
42539                         }
42540                     }
42541                     break;
42542                 case 3:
42543                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
42544                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42545                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42546                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
42547                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
42548                         }
42549                     }
42550                     break;
42551                 case 4:
42552                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
42553                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42554                             __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])))
42555                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
42556                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
42557                         }
42558                     }
42559                     break;
42560             }
42561 #endif
42562 #if CYTHON_COMPILING_IN_CPYTHON
42563             if (unlikely(Py_SIZE(x) < 0)) {
42564                 goto raise_neg_overflow;
42565             }
42566 #else
42567             {
42568                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
42569                 if (unlikely(result < 0))
42570                     return (long) -1;
42571                 if (unlikely(result == 1))
42572                     goto raise_neg_overflow;
42573             }
42574 #endif
42575             if (sizeof(long) <= sizeof(unsigned long)) {
42576                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
42577 #ifdef HAVE_LONG_LONG
42578             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
42579                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
42580 #endif
42581             }
42582         } else {
42583 #if CYTHON_USE_PYLONG_INTERNALS
42584             const digit* digits = ((PyLongObject*)x)->ob_digit;
42585             switch (Py_SIZE(x)) {
42586                 case  0: return (long) 0;
42587                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
42588                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
42589                 case -2:
42590                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
42591                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42592                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42593                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
42594                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
42595                         }
42596                     }
42597                     break;
42598                 case 2:
42599                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
42600                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42601                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42602                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
42603                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
42604                         }
42605                     }
42606                     break;
42607                 case -3:
42608                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
42609                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42610                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42611                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
42612                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
42613                         }
42614                     }
42615                     break;
42616                 case 3:
42617                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
42618                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42619                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42620                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
42621                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
42622                         }
42623                     }
42624                     break;
42625                 case -4:
42626                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
42627                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42628                             __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])))
42629                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
42630                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
42631                         }
42632                     }
42633                     break;
42634                 case 4:
42635                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
42636                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42637                             __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])))
42638                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
42639                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
42640                         }
42641                     }
42642                     break;
42643             }
42644 #endif
42645             if (sizeof(long) <= sizeof(long)) {
42646                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
42647 #ifdef HAVE_LONG_LONG
42648             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
42649                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
42650 #endif
42651             }
42652         }
42653         {
42654 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
42655             PyErr_SetString(PyExc_RuntimeError,
42656                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
42657 #else
42658             long val;
42659             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
42660  #if PY_MAJOR_VERSION < 3
42661             if (likely(v) && !PyLong_Check(v)) {
42662                 PyObject *tmp = v;
42663                 v = PyNumber_Long(tmp);
42664                 Py_DECREF(tmp);
42665             }
42666  #endif
42667             if (likely(v)) {
42668                 int one = 1; int is_little = (int)*(unsigned char *)&one;
42669                 unsigned char *bytes = (unsigned char *)&val;
42670                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
42671                                               bytes, sizeof(val),
42672                                               is_little, !is_unsigned);
42673                 Py_DECREF(v);
42674                 if (likely(!ret))
42675                     return val;
42676             }
42677 #endif
42678             return (long) -1;
42679         }
42680     } else {
42681         long val;
42682         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
42683         if (!tmp) return (long) -1;
42684         val = __Pyx_PyInt_As_long(tmp);
42685         Py_DECREF(tmp);
42686         return val;
42687     }
42688 raise_overflow:
42689     PyErr_SetString(PyExc_OverflowError,
42690         "value too large to convert to long");
42691     return (long) -1;
42692 raise_neg_overflow:
42693     PyErr_SetString(PyExc_OverflowError,
42694         "can't convert negative value to long");
42695     return (long) -1;
42696 }
42697 
42698 /* CIntFromPy */
__Pyx_PyInt_As_char(PyObject * x)42699   static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
42700 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42701 #pragma GCC diagnostic push
42702 #pragma GCC diagnostic ignored "-Wconversion"
42703 #endif
42704     const char neg_one = (char) -1, const_zero = (char) 0;
42705 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
42706 #pragma GCC diagnostic pop
42707 #endif
42708     const int is_unsigned = neg_one > const_zero;
42709 #if PY_MAJOR_VERSION < 3
42710     if (likely(PyInt_Check(x))) {
42711         if (sizeof(char) < sizeof(long)) {
42712             __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
42713         } else {
42714             long val = PyInt_AS_LONG(x);
42715             if (is_unsigned && unlikely(val < 0)) {
42716                 goto raise_neg_overflow;
42717             }
42718             return (char) val;
42719         }
42720     } else
42721 #endif
42722     if (likely(PyLong_Check(x))) {
42723         if (is_unsigned) {
42724 #if CYTHON_USE_PYLONG_INTERNALS
42725             const digit* digits = ((PyLongObject*)x)->ob_digit;
42726             switch (Py_SIZE(x)) {
42727                 case  0: return (char) 0;
42728                 case  1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
42729                 case 2:
42730                     if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
42731                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42732                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42733                         } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
42734                             return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
42735                         }
42736                     }
42737                     break;
42738                 case 3:
42739                     if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
42740                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42741                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42742                         } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
42743                             return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
42744                         }
42745                     }
42746                     break;
42747                 case 4:
42748                     if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
42749                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42750                             __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])))
42751                         } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
42752                             return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
42753                         }
42754                     }
42755                     break;
42756             }
42757 #endif
42758 #if CYTHON_COMPILING_IN_CPYTHON
42759             if (unlikely(Py_SIZE(x) < 0)) {
42760                 goto raise_neg_overflow;
42761             }
42762 #else
42763             {
42764                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
42765                 if (unlikely(result < 0))
42766                     return (char) -1;
42767                 if (unlikely(result == 1))
42768                     goto raise_neg_overflow;
42769             }
42770 #endif
42771             if (sizeof(char) <= sizeof(unsigned long)) {
42772                 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
42773 #ifdef HAVE_LONG_LONG
42774             } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
42775                 __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
42776 #endif
42777             }
42778         } else {
42779 #if CYTHON_USE_PYLONG_INTERNALS
42780             const digit* digits = ((PyLongObject*)x)->ob_digit;
42781             switch (Py_SIZE(x)) {
42782                 case  0: return (char) 0;
42783                 case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
42784                 case  1: __PYX_VERIFY_RETURN_INT(char,  digit, +digits[0])
42785                 case -2:
42786                     if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
42787                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42788                             __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42789                         } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
42790                             return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
42791                         }
42792                     }
42793                     break;
42794                 case 2:
42795                     if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
42796                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
42797                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42798                         } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
42799                             return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
42800                         }
42801                     }
42802                     break;
42803                 case -3:
42804                     if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
42805                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42806                             __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42807                         } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
42808                             return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
42809                         }
42810                     }
42811                     break;
42812                 case 3:
42813                     if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
42814                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
42815                             __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
42816                         } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
42817                             return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
42818                         }
42819                     }
42820                     break;
42821                 case -4:
42822                     if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
42823                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42824                             __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])))
42825                         } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
42826                             return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
42827                         }
42828                     }
42829                     break;
42830                 case 4:
42831                     if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
42832                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
42833                             __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])))
42834                         } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
42835                             return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
42836                         }
42837                     }
42838                     break;
42839             }
42840 #endif
42841             if (sizeof(char) <= sizeof(long)) {
42842                 __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
42843 #ifdef HAVE_LONG_LONG
42844             } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
42845                 __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
42846 #endif
42847             }
42848         }
42849         {
42850 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
42851             PyErr_SetString(PyExc_RuntimeError,
42852                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
42853 #else
42854             char val;
42855             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
42856  #if PY_MAJOR_VERSION < 3
42857             if (likely(v) && !PyLong_Check(v)) {
42858                 PyObject *tmp = v;
42859                 v = PyNumber_Long(tmp);
42860                 Py_DECREF(tmp);
42861             }
42862  #endif
42863             if (likely(v)) {
42864                 int one = 1; int is_little = (int)*(unsigned char *)&one;
42865                 unsigned char *bytes = (unsigned char *)&val;
42866                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
42867                                               bytes, sizeof(val),
42868                                               is_little, !is_unsigned);
42869                 Py_DECREF(v);
42870                 if (likely(!ret))
42871                     return val;
42872             }
42873 #endif
42874             return (char) -1;
42875         }
42876     } else {
42877         char val;
42878         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
42879         if (!tmp) return (char) -1;
42880         val = __Pyx_PyInt_As_char(tmp);
42881         Py_DECREF(tmp);
42882         return val;
42883     }
42884 raise_overflow:
42885     PyErr_SetString(PyExc_OverflowError,
42886         "value too large to convert to char");
42887     return (char) -1;
42888 raise_neg_overflow:
42889     PyErr_SetString(PyExc_OverflowError,
42890         "can't convert negative value to char");
42891     return (char) -1;
42892 }
42893 
42894 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)42895   static int __Pyx_check_binary_version(void) {
42896     char ctversion[4], rtversion[4];
42897     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
42898     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
42899     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
42900         char message[200];
42901         PyOS_snprintf(message, sizeof(message),
42902                       "compiletime version %s of module '%.100s' "
42903                       "does not match runtime version %s",
42904                       ctversion, __Pyx_MODULE_NAME, rtversion);
42905         return PyErr_WarnEx(NULL, message, 1);
42906     }
42907     return 0;
42908 }
42909 
42910 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)42911   static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
42912     while (t->p) {
42913         #if PY_MAJOR_VERSION < 3
42914         if (t->is_unicode) {
42915             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
42916         } else if (t->intern) {
42917             *t->p = PyString_InternFromString(t->s);
42918         } else {
42919             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
42920         }
42921         #else
42922         if (t->is_unicode | t->is_str) {
42923             if (t->intern) {
42924                 *t->p = PyUnicode_InternFromString(t->s);
42925             } else if (t->encoding) {
42926                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
42927             } else {
42928                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
42929             }
42930         } else {
42931             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
42932         }
42933         #endif
42934         if (!*t->p)
42935             return -1;
42936         if (PyObject_Hash(*t->p) == -1)
42937             return -1;
42938         ++t;
42939     }
42940     return 0;
42941 }
42942 
__Pyx_PyUnicode_FromString(const char * c_str)42943 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
42944     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
42945 }
__Pyx_PyObject_AsString(PyObject * o)42946 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
42947     Py_ssize_t ignore;
42948     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
42949 }
42950 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
42951 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)42952 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
42953     char* defenc_c;
42954     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
42955     if (!defenc) return NULL;
42956     defenc_c = PyBytes_AS_STRING(defenc);
42957 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
42958     {
42959         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
42960         char* c;
42961         for (c = defenc_c; c < end; c++) {
42962             if ((unsigned char) (*c) >= 128) {
42963                 PyUnicode_AsASCIIString(o);
42964                 return NULL;
42965             }
42966         }
42967     }
42968 #endif
42969     *length = PyBytes_GET_SIZE(defenc);
42970     return defenc_c;
42971 }
42972 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)42973 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
42974     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
42975 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
42976     if (likely(PyUnicode_IS_ASCII(o))) {
42977         *length = PyUnicode_GET_LENGTH(o);
42978         return PyUnicode_AsUTF8(o);
42979     } else {
42980         PyUnicode_AsASCIIString(o);
42981         return NULL;
42982     }
42983 #else
42984     return PyUnicode_AsUTF8AndSize(o, length);
42985 #endif
42986 }
42987 #endif
42988 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)42989 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
42990 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
42991     if (
42992 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
42993             __Pyx_sys_getdefaultencoding_not_ascii &&
42994 #endif
42995             PyUnicode_Check(o)) {
42996         return __Pyx_PyUnicode_AsStringAndSize(o, length);
42997     } else
42998 #endif
42999 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
43000     if (PyByteArray_Check(o)) {
43001         *length = PyByteArray_GET_SIZE(o);
43002         return PyByteArray_AS_STRING(o);
43003     } else
43004 #endif
43005     {
43006         char* result;
43007         int r = PyBytes_AsStringAndSize(o, &result, length);
43008         if (unlikely(r < 0)) {
43009             return NULL;
43010         } else {
43011             return result;
43012         }
43013     }
43014 }
__Pyx_PyObject_IsTrue(PyObject * x)43015 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
43016    int is_true = x == Py_True;
43017    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
43018    else return PyObject_IsTrue(x);
43019 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)43020 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
43021     int retval;
43022     if (unlikely(!x)) return -1;
43023     retval = __Pyx_PyObject_IsTrue(x);
43024     Py_DECREF(x);
43025     return retval;
43026 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)43027 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
43028 #if PY_MAJOR_VERSION >= 3
43029     if (PyLong_Check(result)) {
43030         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
43031                 "__int__ returned non-int (type %.200s).  "
43032                 "The ability to return an instance of a strict subclass of int "
43033                 "is deprecated, and may be removed in a future version of Python.",
43034                 Py_TYPE(result)->tp_name)) {
43035             Py_DECREF(result);
43036             return NULL;
43037         }
43038         return result;
43039     }
43040 #endif
43041     PyErr_Format(PyExc_TypeError,
43042                  "__%.4s__ returned non-%.4s (type %.200s)",
43043                  type_name, type_name, Py_TYPE(result)->tp_name);
43044     Py_DECREF(result);
43045     return NULL;
43046 }
__Pyx_PyNumber_IntOrLong(PyObject * x)43047 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
43048 #if CYTHON_USE_TYPE_SLOTS
43049   PyNumberMethods *m;
43050 #endif
43051   const char *name = NULL;
43052   PyObject *res = NULL;
43053 #if PY_MAJOR_VERSION < 3
43054   if (likely(PyInt_Check(x) || PyLong_Check(x)))
43055 #else
43056   if (likely(PyLong_Check(x)))
43057 #endif
43058     return __Pyx_NewRef(x);
43059 #if CYTHON_USE_TYPE_SLOTS
43060   m = Py_TYPE(x)->tp_as_number;
43061   #if PY_MAJOR_VERSION < 3
43062   if (m && m->nb_int) {
43063     name = "int";
43064     res = m->nb_int(x);
43065   }
43066   else if (m && m->nb_long) {
43067     name = "long";
43068     res = m->nb_long(x);
43069   }
43070   #else
43071   if (likely(m && m->nb_int)) {
43072     name = "int";
43073     res = m->nb_int(x);
43074   }
43075   #endif
43076 #else
43077   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
43078     res = PyNumber_Int(x);
43079   }
43080 #endif
43081   if (likely(res)) {
43082 #if PY_MAJOR_VERSION < 3
43083     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
43084 #else
43085     if (unlikely(!PyLong_CheckExact(res))) {
43086 #endif
43087         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
43088     }
43089   }
43090   else if (!PyErr_Occurred()) {
43091     PyErr_SetString(PyExc_TypeError,
43092                     "an integer is required");
43093   }
43094   return res;
43095 }
43096 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
43097   Py_ssize_t ival;
43098   PyObject *x;
43099 #if PY_MAJOR_VERSION < 3
43100   if (likely(PyInt_CheckExact(b))) {
43101     if (sizeof(Py_ssize_t) >= sizeof(long))
43102         return PyInt_AS_LONG(b);
43103     else
43104         return PyInt_AsSsize_t(b);
43105   }
43106 #endif
43107   if (likely(PyLong_CheckExact(b))) {
43108     #if CYTHON_USE_PYLONG_INTERNALS
43109     const digit* digits = ((PyLongObject*)b)->ob_digit;
43110     const Py_ssize_t size = Py_SIZE(b);
43111     if (likely(__Pyx_sst_abs(size) <= 1)) {
43112         ival = likely(size) ? digits[0] : 0;
43113         if (size == -1) ival = -ival;
43114         return ival;
43115     } else {
43116       switch (size) {
43117          case 2:
43118            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
43119              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
43120            }
43121            break;
43122          case -2:
43123            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
43124              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
43125            }
43126            break;
43127          case 3:
43128            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
43129              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
43130            }
43131            break;
43132          case -3:
43133            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
43134              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
43135            }
43136            break;
43137          case 4:
43138            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
43139              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]));
43140            }
43141            break;
43142          case -4:
43143            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
43144              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]));
43145            }
43146            break;
43147       }
43148     }
43149     #endif
43150     return PyLong_AsSsize_t(b);
43151   }
43152   x = PyNumber_Index(b);
43153   if (!x) return -1;
43154   ival = PyInt_AsSsize_t(x);
43155   Py_DECREF(x);
43156   return ival;
43157 }
43158 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
43159   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
43160 }
43161 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
43162     return PyInt_FromSize_t(ival);
43163 }
43164 
43165 
43166 #endif /* Py_PYTHON_H */
43167