Generated by Cython 3.0.10

Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.

Raw output: cutils.c

+001: # -*- coding: utf-8 -*-
  __Pyx_TraceLine(1,0,__PYX_ERR(0, 1, __pyx_L1_error))
  __pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_7) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 002: #cython: language_level=3
 003: #cython: wraparound=False
 004: #cython: boundscheck=False
 005: #cython: nonecheck=False
 006: #cython: cdivision=True
 007: #cython: initializedcheck=False
 008: #
 009: # Copyright © 2016-2019 Cyril Desjouy <cyril.desjouy@univ-lemans.fr>
 010: #
 011: # This file is part of ofdlib2
 012: #
 013: # ofdlib2 is free software: you can redistribute it and/or modify
 014: # it under the terms of the GNU General Public License as published by
 015: # the Free Software Foundation, either version 3 of the License, or
 016: # (at your option) any later version.
 017: #
 018: # ofdlib2 is distributed in the hope that it will be useful,
 019: # but WITHOUT ANY WARRANTY; without even the implied warranty of
 020: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 021: # GNU General Public License for more details.
 022: #
 023: # You should have received a copy of the GNU General Public License
 024: # along with ofdlib2. If not, see <http://www.gnu.org/licenses/>.
 025: #
 026: #
 027: # Creation Date : 2017-03-21 - 16:51:13
 028: """
 029: -----------
 030: Derivations classes :
 031: 
 032:     * du : classical derivation with finite differences (2D)
 033:     * duA : helpers for PML areas
 034: 
 035: @author: Cyril Desjouy
 036: """
 037: 
+038: import numpy as np
  __Pyx_TraceLine(38,0,__PYX_ERR(0, 38, __pyx_L1_error))
  __pyx_t_7 = __Pyx_ImportDottedModule(__pyx_n_s_numpy, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_7) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 039: cimport numpy as np
 040: cimport cython
 041: from cython.parallel cimport prange, parallel
 042: from numpy cimport int64_t, uint8_t
 043: 
 044: 
+045: cpdef where(mask, pattern):
static PyObject *__pyx_pw_6libfds_6cutils_1where(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyObject *__pyx_f_6libfds_6cutils_where(PyObject *__pyx_v_mask, PyObject *__pyx_v_pattern, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_px;
  Py_ssize_t __pyx_v_py;
  Py_ssize_t __pyx_v_pz;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__11)
  __Pyx_TraceCall("where", __pyx_f[0], 45, 0, __PYX_ERR(0, 45, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_10, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_11, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_13, 1);
  __Pyx_AddTraceback("libfds.cutils.where", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6libfds_6cutils_1where(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6libfds_6cutils_1where = {"where", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6libfds_6cutils_1where, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6libfds_6cutils_1where(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_mask = 0;
  PyObject *__pyx_v_pattern = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("where (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_MACROS
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mask,&__pyx_n_s_pattern,0};
  PyObject* values[2] = {0,0};
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        case  2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
      switch (__pyx_nargs) {
        case  0:
        if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_mask)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L3_error)
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pattern)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("where", 1, 2, 2, 1); __PYX_ERR(0, 45, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t kwd_pos_args = __pyx_nargs;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "where") < 0)) __PYX_ERR(0, 45, __pyx_L3_error)
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
      values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
    }
    __pyx_v_mask = values[0];
    __pyx_v_pattern = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("where", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 45, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_AddTraceback("libfds.cutils.where", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6libfds_6cutils_where(__pyx_self, __pyx_v_mask, __pyx_v_pattern);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6libfds_6cutils_where(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mask, PyObject *__pyx_v_pattern) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__11)
  __Pyx_TraceCall("where (wrapper)", __pyx_f[0], 45, 0, __PYX_ERR(0, 45, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6libfds_6cutils_where(__pyx_v_mask, __pyx_v_pattern, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libfds.cutils.where", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __Pyx_TraceLine(45,0,__PYX_ERR(0, 45, __pyx_L1_error))
/* … */
  __pyx_tuple__29 = PyTuple_Pack(2, __pyx_n_s_mask, __pyx_n_s_pattern); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_6libfds_6cutils_1where, 0, __pyx_n_s_where, NULL, __pyx_n_s_libfds_cutils, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_where, __pyx_t_7) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_libfds_cutils_pyx, __pyx_n_s_where, 45, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 45, __pyx_L1_error)
 046: 
 047:     cdef Py_ssize_t px, py, pz
 048: 
+049:     if mask.ndim == 4:
  __Pyx_TraceLine(49,0,__PYX_ERR(0, 49, __pyx_L1_error))
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mask, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_1, __pyx_int_4, 4, 0)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {
/* … */
  }
+050:         px, py, pz = pattern
    __Pyx_TraceLine(50,0,__PYX_ERR(0, 50, __pyx_L1_error))
    if ((likely(PyTuple_CheckExact(__pyx_v_pattern))) || (PyList_CheckExact(__pyx_v_pattern))) {
      PyObject* sequence = __pyx_v_pattern;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 50, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
    } else {
      Py_ssize_t index = -1;
      __pyx_t_5 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 50, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5);
      index = 0; __pyx_t_1 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) __PYX_ERR(0, 50, __pyx_L1_error)
      __pyx_t_6 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L5_unpacking_done;
      __pyx_L4_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 50, __pyx_L1_error)
      __pyx_L5_unpacking_done:;
    }
    __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 50, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 50, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 50, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_px = __pyx_t_7;
    __pyx_v_py = __pyx_t_8;
    __pyx_v_pz = __pyx_t_9;
+051:         return np.asarray(where3d(mask, px, py, pz))
    __Pyx_TraceLine(51,0,__PYX_ERR(0, 51, __pyx_L1_error))
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_d_d_dc_nn___pyx_t_6libfds_6cutils_INT8(__pyx_v_mask, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 51, __pyx_L1_error)
    __pyx_t_11 = __pyx_f_6libfds_6cutils_where3d(__pyx_t_10, __pyx_v_px, __pyx_v_py, __pyx_v_pz); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 51, __pyx_L1_error)
    __PYX_XCLEAR_MEMVIEW(&__pyx_t_10, 1);
    __pyx_t_10.memview = NULL; __pyx_t_10.data = NULL;
    __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_t_11, 2, (PyObject *(*)(char *)) __pyx_memview_get_short, (int (*)(char *, PyObject *)) __pyx_memview_set_short, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __PYX_XCLEAR_MEMVIEW(&__pyx_t_11, 1);
    __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL;
    __pyx_t_5 = NULL;
    __pyx_t_12 = 0;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_12 = 1;
      }
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_3};
      __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 51, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
+052:     elif mask.ndim == 3:
  __Pyx_TraceLine(52,0,__PYX_ERR(0, 52, __pyx_L1_error))
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_mask, __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_4, __pyx_int_3, 3, 0)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 52, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(__pyx_t_2)) {
/* … */
  }
+053:         px, py = pattern
    __Pyx_TraceLine(53,0,__PYX_ERR(0, 53, __pyx_L1_error))
    if ((likely(PyTuple_CheckExact(__pyx_v_pattern))) || (PyList_CheckExact(__pyx_v_pattern))) {
      PyObject* sequence = __pyx_v_pattern;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 53, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
    } else {
      Py_ssize_t index = -1;
      __pyx_t_3 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3);
      index = 0; __pyx_t_4 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      index = 1; __pyx_t_1 = __pyx_t_6(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_3), 2) < 0) __PYX_ERR(0, 53, __pyx_L1_error)
      __pyx_t_6 = NULL;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 53, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_px = __pyx_t_9;
    __pyx_v_py = __pyx_t_8;
+054:         return np.asarray(where2d(mask, px, py))
    __Pyx_TraceLine(54,0,__PYX_ERR(0, 54, __pyx_L1_error))
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 54, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 54, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_6libfds_6cutils_INT8(__pyx_v_mask, PyBUF_WRITABLE); if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 54, __pyx_L1_error)
    __pyx_t_11 = __pyx_f_6libfds_6cutils_where2d(__pyx_t_13, __pyx_v_px, __pyx_v_py); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 54, __pyx_L1_error)
    __PYX_XCLEAR_MEMVIEW(&__pyx_t_13, 1);
    __pyx_t_13.memview = NULL; __pyx_t_13.data = NULL;
    __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_t_11, 2, (PyObject *(*)(char *)) __pyx_memview_get_short, (int (*)(char *, PyObject *)) __pyx_memview_set_short, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 54, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __PYX_XCLEAR_MEMVIEW(&__pyx_t_11, 1);
    __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL;
    __pyx_t_5 = NULL;
    __pyx_t_12 = 0;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_12 = 1;
      }
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
 055:     else:
+056:         raise ValueError('Bad dimensions')
  __Pyx_TraceLine(56,0,__PYX_ERR(0, 56, __pyx_L1_error))
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 56, __pyx_L1_error)
  }
/* … */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_Bad_dimensions); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);
 057: 
 058: 
+059: cpdef nonzeros(mask):
static PyObject *__pyx_pw_6libfds_6cutils_3nonzeros(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyObject *__pyx_f_6libfds_6cutils_nonzeros(PyObject *__pyx_v_mask, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__13)
  __Pyx_TraceCall("nonzeros", __pyx_f[0], 59, 0, __PYX_ERR(0, 59, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_5, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
  __Pyx_XDECREF(__pyx_t_7);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_9, 1);
  __Pyx_AddTraceback("libfds.cutils.nonzeros", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6libfds_6cutils_3nonzeros(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6libfds_6cutils_3nonzeros = {"nonzeros", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6libfds_6cutils_3nonzeros, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6libfds_6cutils_3nonzeros(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_mask = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("nonzeros (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_MACROS
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mask,0};
  PyObject* values[1] = {0};
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
      switch (__pyx_nargs) {
        case  0:
        if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_mask)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L3_error)
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t kwd_pos_args = __pyx_nargs;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "nonzeros") < 0)) __PYX_ERR(0, 59, __pyx_L3_error)
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
    }
    __pyx_v_mask = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("nonzeros", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 59, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_AddTraceback("libfds.cutils.nonzeros", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6libfds_6cutils_2nonzeros(__pyx_self, __pyx_v_mask);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6libfds_6cutils_2nonzeros(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mask) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__13)
  __Pyx_TraceCall("nonzeros (wrapper)", __pyx_f[0], 59, 0, __PYX_ERR(0, 59, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6libfds_6cutils_nonzeros(__pyx_v_mask, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libfds.cutils.nonzeros", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __Pyx_TraceLine(59,0,__PYX_ERR(0, 59, __pyx_L1_error))
/* … */
  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_n_s_mask); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_6libfds_6cutils_3nonzeros, 0, __pyx_n_s_nonzeros, NULL, __pyx_n_s_libfds_cutils, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_nonzeros, __pyx_t_7) < 0) __PYX_ERR(0, 59, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 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_src_libfds_cutils_pyx, __pyx_n_s_nonzeros, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 59, __pyx_L1_error)
+060:     if mask.ndim == 3:
  __Pyx_TraceLine(60,0,__PYX_ERR(0, 60, __pyx_L1_error))
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mask, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_1, __pyx_int_3, 3, 0)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {
/* … */
  }
+061:         return np.asarray(nonzeros3d(mask))
    __Pyx_TraceLine(61,0,__PYX_ERR(0, 61, __pyx_L1_error))
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_6libfds_6cutils_INT8(__pyx_v_mask, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 61, __pyx_L1_error)
    __pyx_t_6 = __pyx_f_6libfds_6cutils_nonzeros3d(__pyx_t_5); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 61, __pyx_L1_error)
    __PYX_XCLEAR_MEMVIEW(&__pyx_t_5, 1);
    __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
    __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_t_6, 2, (PyObject *(*)(char *)) __pyx_memview_get_short, (int (*)(char *, PyObject *)) __pyx_memview_set_short, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
    __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_8 = 1;
      }
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_3};
      __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
+062:     elif mask.ndim == 2:
  __Pyx_TraceLine(62,0,__PYX_ERR(0, 62, __pyx_L1_error))
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mask, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_1, __pyx_int_2, 2, 0)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_2)) {
/* … */
  }
+063:         return np.asarray(nonzeros2d(mask))
    __Pyx_TraceLine(63,0,__PYX_ERR(0, 63, __pyx_L1_error))
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 63, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 63, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_6libfds_6cutils_INT8(__pyx_v_mask, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 63, __pyx_L1_error)
    __pyx_t_6 = __pyx_f_6libfds_6cutils_nonzeros2d(__pyx_t_9); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 63, __pyx_L1_error)
    __PYX_XCLEAR_MEMVIEW(&__pyx_t_9, 1);
    __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
    __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_t_6, 2, (PyObject *(*)(char *)) __pyx_memview_get_short, (int (*)(char *, PyObject *)) __pyx_memview_set_short, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 63, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
    __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
    __pyx_t_7 = NULL;
    __pyx_t_8 = 0;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_8 = 1;
      }
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
 064:     else:
+065:         raise ValueError('Bad dimensions')
  __Pyx_TraceLine(65,0,__PYX_ERR(0, 65, __pyx_L1_error))
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 65, __pyx_L1_error)
  }
 066: 
 067: 
+068: cdef short[:, ::1] where3d(INT8[:, :, :, ::1] mask,
static __Pyx_memviewslice __pyx_f_6libfds_6cutils_where3d(__Pyx_memviewslice __pyx_v_mask, Py_ssize_t __pyx_v_px, Py_ssize_t __pyx_v_py, Py_ssize_t __pyx_v_pz) {
  Py_ssize_t __pyx_v_ix;
  Py_ssize_t __pyx_v_iy;
  Py_ssize_t __pyx_v_iz;
  Py_ssize_t __pyx_v_ii;
  int __pyx_v_nx;
  int __pyx_v_ny;
  int __pyx_v_nz;
  __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("where3d", __pyx_f[0], 68, 0, __PYX_ERR(0, 68, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
  __pyx_r.data = NULL;
  __pyx_r.memview = NULL;
  __Pyx_AddTraceback("libfds.cutils.where3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  goto __pyx_L2;
  __pyx_L0:;
  if (unlikely(!__pyx_r.memview)) {
    PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized");
  }
  __pyx_L2:;
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_out, 1);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __Pyx_TraceLine(68,0,__PYX_ERR(0, 68, __pyx_L1_error))

 069:                Py_ssize_t px, Py_ssize_t py, Py_ssize_t pz):
 070: 
+071:     cdef Py_ssize_t ix, iy, iz, ii = 0
  __Pyx_TraceLine(71,0,__PYX_ERR(0, 71, __pyx_L1_error))
  __pyx_v_ii = 0;
+072:     cdef int nx = mask.shape[0]
  __Pyx_TraceLine(72,0,__PYX_ERR(0, 72, __pyx_L1_error))
  __pyx_v_nx = (__pyx_v_mask.shape[0]);
+073:     cdef int ny = mask.shape[1]
  __Pyx_TraceLine(73,0,__PYX_ERR(0, 73, __pyx_L1_error))
  __pyx_v_ny = (__pyx_v_mask.shape[1]);
+074:     cdef int nz = mask.shape[2]
  __Pyx_TraceLine(74,0,__PYX_ERR(0, 74, __pyx_L1_error))
  __pyx_v_nz = (__pyx_v_mask.shape[2]);
 075: 
+076:     cdef short[:, ::1] out = np.empty((nx*ny*nz, 3), dtype=np.int16)
  __Pyx_TraceLine(76,0,__PYX_ERR(0, 76, __pyx_L1_error))
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(((__pyx_v_nx * __pyx_v_ny) * __pyx_v_nz)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_3)) __PYX_ERR(0, 76, __pyx_L1_error);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int16); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_out = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
 077: 
 078:     #for ix in prange(nx, nogil=True, num_threads=4):
+079:     for ix in range(nx):
  __Pyx_TraceLine(79,0,__PYX_ERR(0, 79, __pyx_L1_error))
  __pyx_t_7 = __pyx_v_nx;
  __pyx_t_8 = __pyx_t_7;
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
    __pyx_v_ix = __pyx_t_9;
+080:         for iy in range(ny):
    __Pyx_TraceLine(80,0,__PYX_ERR(0, 80, __pyx_L1_error))
    __pyx_t_10 = __pyx_v_ny;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_iy = __pyx_t_12;
+081:             for iz in range(nz):
      __Pyx_TraceLine(81,0,__PYX_ERR(0, 81, __pyx_L1_error))
      __pyx_t_13 = __pyx_v_nz;
      __pyx_t_14 = __pyx_t_13;
      for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
        __pyx_v_iz = __pyx_t_15;
+082:                 if mask[ix, iy, iz, 0] == px and \
        __Pyx_TraceLine(82,0,__PYX_ERR(0, 82, __pyx_L1_error))
        __pyx_t_17 = __pyx_v_ix;
        __pyx_t_18 = __pyx_v_iy;
        __pyx_t_19 = __pyx_v_iz;
        __pyx_t_20 = 0;
        __pyx_t_21 = ((*((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=3 */ ((char *) (((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_mask.data + __pyx_t_17 * __pyx_v_mask.strides[0]) ) + __pyx_t_18 * __pyx_v_mask.strides[1]) ) + __pyx_t_19 * __pyx_v_mask.strides[2]) )) + __pyx_t_20)) ))) == __pyx_v_px);
        if (__pyx_t_21) {
        } else {
          __pyx_t_16 = __pyx_t_21;
          goto __pyx_L10_bool_binop_done;
        }
/* … */
        __Pyx_TraceLine(82,0,__PYX_ERR(0, 82, __pyx_L1_error))
        if (__pyx_t_16) {
/* … */
        }
      }
    }
  }
+083:                    mask[ix, iy, iz, 1] == py and \
        __Pyx_TraceLine(83,0,__PYX_ERR(0, 83, __pyx_L1_error))
        __pyx_t_20 = __pyx_v_ix;
        __pyx_t_19 = __pyx_v_iy;
        __pyx_t_18 = __pyx_v_iz;
        __pyx_t_17 = 1;
        __pyx_t_21 = ((*((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=3 */ ((char *) (((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_mask.data + __pyx_t_20 * __pyx_v_mask.strides[0]) ) + __pyx_t_19 * __pyx_v_mask.strides[1]) ) + __pyx_t_18 * __pyx_v_mask.strides[2]) )) + __pyx_t_17)) ))) == __pyx_v_py);
        if (__pyx_t_21) {
        } else {
          __pyx_t_16 = __pyx_t_21;
          goto __pyx_L10_bool_binop_done;
        }
+084:                    mask[ix, iy, iz, 2] == pz:
        __Pyx_TraceLine(84,0,__PYX_ERR(0, 84, __pyx_L1_error))
        __pyx_t_17 = __pyx_v_ix;
        __pyx_t_18 = __pyx_v_iy;
        __pyx_t_19 = __pyx_v_iz;
        __pyx_t_20 = 2;
        __pyx_t_21 = ((*((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=3 */ ((char *) (((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_mask.data + __pyx_t_17 * __pyx_v_mask.strides[0]) ) + __pyx_t_18 * __pyx_v_mask.strides[1]) ) + __pyx_t_19 * __pyx_v_mask.strides[2]) )) + __pyx_t_20)) ))) == __pyx_v_pz);
        __pyx_t_16 = __pyx_t_21;
        __pyx_L10_bool_binop_done:;
+085:                     out[ii, 0] = ix
          __Pyx_TraceLine(85,0,__PYX_ERR(0, 85, __pyx_L1_error))
          __pyx_t_20 = __pyx_v_ii;
          __pyx_t_19 = 0;
          *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_20 * __pyx_v_out.strides[0]) )) + __pyx_t_19)) )) = __pyx_v_ix;
+086:                     out[ii, 1] = iy
          __Pyx_TraceLine(86,0,__PYX_ERR(0, 86, __pyx_L1_error))
          __pyx_t_19 = __pyx_v_ii;
          __pyx_t_20 = 1;
          *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_19 * __pyx_v_out.strides[0]) )) + __pyx_t_20)) )) = __pyx_v_iy;
+087:                     out[ii, 2] = iz
          __Pyx_TraceLine(87,0,__PYX_ERR(0, 87, __pyx_L1_error))
          __pyx_t_20 = __pyx_v_ii;
          __pyx_t_19 = 2;
          *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_20 * __pyx_v_out.strides[0]) )) + __pyx_t_19)) )) = __pyx_v_iz;
+088:                     ii = ii + 1
          __Pyx_TraceLine(88,0,__PYX_ERR(0, 88, __pyx_L1_error))
          __pyx_v_ii = (__pyx_v_ii + 1);
 089: 
+090:     return out[:ii, :]
  __Pyx_TraceLine(90,0,__PYX_ERR(0, 90, __pyx_L1_error))
  __pyx_t_6.data = __pyx_v_out.data;
  __pyx_t_6.memview = __pyx_v_out.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_6, 1);
  __pyx_t_7 = -1;
  if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_6,
    __pyx_v_out.shape[0], __pyx_v_out.strides[0], __pyx_v_out.suboffsets[0],
    0,
    0,
    &__pyx_t_7,
    0,
    __pyx_v_ii,
    0,
    0,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 90, __pyx_L1_error)
}

__pyx_t_6.shape[1] = __pyx_v_out.shape[1];
__pyx_t_6.strides[1] = __pyx_v_out.strides[1];
    __pyx_t_6.suboffsets[1] = -1;

__pyx_r = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
  goto __pyx_L0;
 091: 
 092: 
+093: cdef short[:, ::1] where2d(INT8[:, :, ::1] mask, Py_ssize_t px, Py_ssize_t py):
static __Pyx_memviewslice __pyx_f_6libfds_6cutils_where2d(__Pyx_memviewslice __pyx_v_mask, Py_ssize_t __pyx_v_px, Py_ssize_t __pyx_v_py) {
  Py_ssize_t __pyx_v_ix;
  Py_ssize_t __pyx_v_iy;
  Py_ssize_t __pyx_v_ii;
  int __pyx_v_nx;
  int __pyx_v_ny;
  __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("where2d", __pyx_f[0], 93, 0, __PYX_ERR(0, 93, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
  __pyx_r.data = NULL;
  __pyx_r.memview = NULL;
  __Pyx_AddTraceback("libfds.cutils.where2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  goto __pyx_L2;
  __pyx_L0:;
  if (unlikely(!__pyx_r.memview)) {
    PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized");
  }
  __pyx_L2:;
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_out, 1);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __Pyx_TraceLine(93,0,__PYX_ERR(0, 93, __pyx_L1_error))

 094: 
+095:     cdef Py_ssize_t ix, iy, ii = 0
  __Pyx_TraceLine(95,0,__PYX_ERR(0, 95, __pyx_L1_error))
  __pyx_v_ii = 0;
+096:     cdef int nx = mask.shape[0]
  __Pyx_TraceLine(96,0,__PYX_ERR(0, 96, __pyx_L1_error))
  __pyx_v_nx = (__pyx_v_mask.shape[0]);
+097:     cdef int ny = mask.shape[1]
  __Pyx_TraceLine(97,0,__PYX_ERR(0, 97, __pyx_L1_error))
  __pyx_v_ny = (__pyx_v_mask.shape[1]);
 098: 
+099:     cdef short[:, ::1] out = np.empty((nx*ny, 3), dtype=np.int16)
  __Pyx_TraceLine(99,0,__PYX_ERR(0, 99, __pyx_L1_error))
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_nx * __pyx_v_ny)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_3)) __PYX_ERR(0, 99, __pyx_L1_error);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3)) __PYX_ERR(0, 99, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 99, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int16); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 99, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 99, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 99, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 99, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_out = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
 100: 
 101:     #for ix in prange(nx, nogil=True, num_threads=4):
+102:     for ix in range(nx):
  __Pyx_TraceLine(102,0,__PYX_ERR(0, 102, __pyx_L1_error))
  __pyx_t_7 = __pyx_v_nx;
  __pyx_t_8 = __pyx_t_7;
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
    __pyx_v_ix = __pyx_t_9;
+103:         for iy in range(ny):
    __Pyx_TraceLine(103,0,__PYX_ERR(0, 103, __pyx_L1_error))
    __pyx_t_10 = __pyx_v_ny;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_iy = __pyx_t_12;
+104:             if mask[ix, iy, 0] == px and mask[ix, iy, 1] == py:
      __Pyx_TraceLine(104,0,__PYX_ERR(0, 104, __pyx_L1_error))
      __pyx_t_14 = __pyx_v_ix;
      __pyx_t_15 = __pyx_v_iy;
      __pyx_t_16 = 0;
      __pyx_t_17 = ((*((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=2 */ ((char *) (((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_mask.data + __pyx_t_14 * __pyx_v_mask.strides[0]) ) + __pyx_t_15 * __pyx_v_mask.strides[1]) )) + __pyx_t_16)) ))) == __pyx_v_px);
      if (__pyx_t_17) {
      } else {
        __pyx_t_13 = __pyx_t_17;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_16 = __pyx_v_ix;
      __pyx_t_15 = __pyx_v_iy;
      __pyx_t_14 = 1;
      __pyx_t_17 = ((*((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=2 */ ((char *) (((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_mask.data + __pyx_t_16 * __pyx_v_mask.strides[0]) ) + __pyx_t_15 * __pyx_v_mask.strides[1]) )) + __pyx_t_14)) ))) == __pyx_v_py);
      __pyx_t_13 = __pyx_t_17;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_13) {
/* … */
      }
    }
  }
+105:                 out[ii, 0] = ix
        __Pyx_TraceLine(105,0,__PYX_ERR(0, 105, __pyx_L1_error))
        __pyx_t_14 = __pyx_v_ii;
        __pyx_t_15 = 0;
        *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_14 * __pyx_v_out.strides[0]) )) + __pyx_t_15)) )) = __pyx_v_ix;
+106:                 out[ii, 1] = iy
        __Pyx_TraceLine(106,0,__PYX_ERR(0, 106, __pyx_L1_error))
        __pyx_t_15 = __pyx_v_ii;
        __pyx_t_14 = 1;
        *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_15 * __pyx_v_out.strides[0]) )) + __pyx_t_14)) )) = __pyx_v_iy;
+107:                 ii = ii + 1
        __Pyx_TraceLine(107,0,__PYX_ERR(0, 107, __pyx_L1_error))
        __pyx_v_ii = (__pyx_v_ii + 1);
 108: 
+109:     return out[:ii, :]
  __Pyx_TraceLine(109,0,__PYX_ERR(0, 109, __pyx_L1_error))
  __pyx_t_6.data = __pyx_v_out.data;
  __pyx_t_6.memview = __pyx_v_out.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_6, 1);
  __pyx_t_7 = -1;
  if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_6,
    __pyx_v_out.shape[0], __pyx_v_out.strides[0], __pyx_v_out.suboffsets[0],
    0,
    0,
    &__pyx_t_7,
    0,
    __pyx_v_ii,
    0,
    0,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 109, __pyx_L1_error)
}

__pyx_t_6.shape[1] = __pyx_v_out.shape[1];
__pyx_t_6.strides[1] = __pyx_v_out.strides[1];
    __pyx_t_6.suboffsets[1] = -1;

__pyx_r = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
  goto __pyx_L0;
 110: 
 111: 
+112: cdef short[:, ::1] nonzeros3d(INT8[:, :, ::1] mask):
static __Pyx_memviewslice __pyx_f_6libfds_6cutils_nonzeros3d(__Pyx_memviewslice __pyx_v_mask) {
  Py_ssize_t __pyx_v_ix;
  Py_ssize_t __pyx_v_iy;
  Py_ssize_t __pyx_v_iz;
  Py_ssize_t __pyx_v_ii;
  int __pyx_v_nx;
  int __pyx_v_ny;
  int __pyx_v_nz;
  __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("nonzeros3d", __pyx_f[0], 112, 0, __PYX_ERR(0, 112, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
  __pyx_r.data = NULL;
  __pyx_r.memview = NULL;
  __Pyx_AddTraceback("libfds.cutils.nonzeros3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  goto __pyx_L2;
  __pyx_L0:;
  if (unlikely(!__pyx_r.memview)) {
    PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized");
  }
  __pyx_L2:;
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_out, 1);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __Pyx_TraceLine(112,0,__PYX_ERR(0, 112, __pyx_L1_error))

 113: 
+114:     cdef Py_ssize_t ix, iy, iz, ii = 0
  __Pyx_TraceLine(114,0,__PYX_ERR(0, 114, __pyx_L1_error))
  __pyx_v_ii = 0;
+115:     cdef int nx = mask.shape[0]
  __Pyx_TraceLine(115,0,__PYX_ERR(0, 115, __pyx_L1_error))
  __pyx_v_nx = (__pyx_v_mask.shape[0]);
+116:     cdef int ny = mask.shape[1]
  __Pyx_TraceLine(116,0,__PYX_ERR(0, 116, __pyx_L1_error))
  __pyx_v_ny = (__pyx_v_mask.shape[1]);
+117:     cdef int nz = mask.shape[2]
  __Pyx_TraceLine(117,0,__PYX_ERR(0, 117, __pyx_L1_error))
  __pyx_v_nz = (__pyx_v_mask.shape[2]);
 118: 
+119:     cdef short[:, ::1] out = np.empty((nx*ny*nz, 3), dtype=np.int16)
  __Pyx_TraceLine(119,0,__PYX_ERR(0, 119, __pyx_L1_error))
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(((__pyx_v_nx * __pyx_v_ny) * __pyx_v_nz)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_3)) __PYX_ERR(0, 119, __pyx_L1_error);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3)) __PYX_ERR(0, 119, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int16); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 119, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_out = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
 120: 
 121:     #for ix in prange(nx, nogil=True, num_threads=4):
+122:     for ix in range(nx):
  __Pyx_TraceLine(122,0,__PYX_ERR(0, 122, __pyx_L1_error))
  __pyx_t_7 = __pyx_v_nx;
  __pyx_t_8 = __pyx_t_7;
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
    __pyx_v_ix = __pyx_t_9;
+123:         for iy in range(ny):
    __Pyx_TraceLine(123,0,__PYX_ERR(0, 123, __pyx_L1_error))
    __pyx_t_10 = __pyx_v_ny;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_iy = __pyx_t_12;
+124:             for iz in range(nz):
      __Pyx_TraceLine(124,0,__PYX_ERR(0, 124, __pyx_L1_error))
      __pyx_t_13 = __pyx_v_nz;
      __pyx_t_14 = __pyx_t_13;
      for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
        __pyx_v_iz = __pyx_t_15;
+125:                 if mask[ix, iy, iz] == True:
        __Pyx_TraceLine(125,0,__PYX_ERR(0, 125, __pyx_L1_error))
        __pyx_t_16 = __pyx_v_ix;
        __pyx_t_17 = __pyx_v_iy;
        __pyx_t_18 = __pyx_v_iz;
        __pyx_t_19 = ((*((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=2 */ ((char *) (((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_mask.data + __pyx_t_16 * __pyx_v_mask.strides[0]) ) + __pyx_t_17 * __pyx_v_mask.strides[1]) )) + __pyx_t_18)) ))) == 1);
        if (__pyx_t_19) {
/* … */
        }
      }
    }
  }
+126:                     out[ii, 0] = ix
          __Pyx_TraceLine(126,0,__PYX_ERR(0, 126, __pyx_L1_error))
          __pyx_t_18 = __pyx_v_ii;
          __pyx_t_17 = 0;
          *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_18 * __pyx_v_out.strides[0]) )) + __pyx_t_17)) )) = __pyx_v_ix;
+127:                     out[ii, 1] = iy
          __Pyx_TraceLine(127,0,__PYX_ERR(0, 127, __pyx_L1_error))
          __pyx_t_17 = __pyx_v_ii;
          __pyx_t_18 = 1;
          *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_17 * __pyx_v_out.strides[0]) )) + __pyx_t_18)) )) = __pyx_v_iy;
+128:                     out[ii, 2] = iz
          __Pyx_TraceLine(128,0,__PYX_ERR(0, 128, __pyx_L1_error))
          __pyx_t_18 = __pyx_v_ii;
          __pyx_t_17 = 2;
          *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_18 * __pyx_v_out.strides[0]) )) + __pyx_t_17)) )) = __pyx_v_iz;
+129:                     ii = ii + 1
          __Pyx_TraceLine(129,0,__PYX_ERR(0, 129, __pyx_L1_error))
          __pyx_v_ii = (__pyx_v_ii + 1);
 130: 
+131:     return out[:ii, :]
  __Pyx_TraceLine(131,0,__PYX_ERR(0, 131, __pyx_L1_error))
  __pyx_t_6.data = __pyx_v_out.data;
  __pyx_t_6.memview = __pyx_v_out.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_6, 1);
  __pyx_t_7 = -1;
  if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_6,
    __pyx_v_out.shape[0], __pyx_v_out.strides[0], __pyx_v_out.suboffsets[0],
    0,
    0,
    &__pyx_t_7,
    0,
    __pyx_v_ii,
    0,
    0,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 131, __pyx_L1_error)
}

__pyx_t_6.shape[1] = __pyx_v_out.shape[1];
__pyx_t_6.strides[1] = __pyx_v_out.strides[1];
    __pyx_t_6.suboffsets[1] = -1;

__pyx_r = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
  goto __pyx_L0;
 132: 
 133: 
+134: cdef short[:, ::1] nonzeros2d(INT8[:, ::1] mask):
static __Pyx_memviewslice __pyx_f_6libfds_6cutils_nonzeros2d(__Pyx_memviewslice __pyx_v_mask) {
  Py_ssize_t __pyx_v_ix;
  Py_ssize_t __pyx_v_iy;
  Py_ssize_t __pyx_v_ii;
  int __pyx_v_nx;
  int __pyx_v_ny;
  __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("nonzeros2d", __pyx_f[0], 134, 0, __PYX_ERR(0, 134, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_6, 1);
  __pyx_r.data = NULL;
  __pyx_r.memview = NULL;
  __Pyx_AddTraceback("libfds.cutils.nonzeros2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  goto __pyx_L2;
  __pyx_L0:;
  if (unlikely(!__pyx_r.memview)) {
    PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized");
  }
  __pyx_L2:;
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_out, 1);
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __Pyx_TraceLine(134,0,__PYX_ERR(0, 134, __pyx_L1_error))

 135: 
+136:     cdef Py_ssize_t ix, iy, ii = 0
  __Pyx_TraceLine(136,0,__PYX_ERR(0, 136, __pyx_L1_error))
  __pyx_v_ii = 0;
+137:     cdef int nx = mask.shape[0]
  __Pyx_TraceLine(137,0,__PYX_ERR(0, 137, __pyx_L1_error))
  __pyx_v_nx = (__pyx_v_mask.shape[0]);
+138:     cdef int ny = mask.shape[1]
  __Pyx_TraceLine(138,0,__PYX_ERR(0, 138, __pyx_L1_error))
  __pyx_v_ny = (__pyx_v_mask.shape[1]);
 139: 
+140:     cdef short[:, ::1] out = np.empty((nx*ny, 2), dtype=np.int16)
  __Pyx_TraceLine(140,0,__PYX_ERR(0, 140, __pyx_L1_error))
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_nx * __pyx_v_ny)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error);
  __Pyx_INCREF(__pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_2)) __PYX_ERR(0, 140, __pyx_L1_error);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int16); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_out = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
 141: 
 142:     #for ix in prange(nx, nogil=True, num_threads=4):
+143:     for ix in range(nx):
  __Pyx_TraceLine(143,0,__PYX_ERR(0, 143, __pyx_L1_error))
  __pyx_t_7 = __pyx_v_nx;
  __pyx_t_8 = __pyx_t_7;
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
    __pyx_v_ix = __pyx_t_9;
+144:         for iy in range(ny):
    __Pyx_TraceLine(144,0,__PYX_ERR(0, 144, __pyx_L1_error))
    __pyx_t_10 = __pyx_v_ny;
    __pyx_t_11 = __pyx_t_10;
    for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_iy = __pyx_t_12;
+145:             if mask[ix, iy] == True:
      __Pyx_TraceLine(145,0,__PYX_ERR(0, 145, __pyx_L1_error))
      __pyx_t_13 = __pyx_v_ix;
      __pyx_t_14 = __pyx_v_iy;
      __pyx_t_15 = ((*((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=1 */ ((char *) (((__pyx_t_6libfds_6cutils_INT8 *) ( /* dim=0 */ (__pyx_v_mask.data + __pyx_t_13 * __pyx_v_mask.strides[0]) )) + __pyx_t_14)) ))) == 1);
      if (__pyx_t_15) {
/* … */
      }
    }
  }
+146:                     out[ii, 0] = ix
        __Pyx_TraceLine(146,0,__PYX_ERR(0, 146, __pyx_L1_error))
        __pyx_t_14 = __pyx_v_ii;
        __pyx_t_13 = 0;
        *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_14 * __pyx_v_out.strides[0]) )) + __pyx_t_13)) )) = __pyx_v_ix;
+147:                     out[ii, 1] = iy
        __Pyx_TraceLine(147,0,__PYX_ERR(0, 147, __pyx_L1_error))
        __pyx_t_13 = __pyx_v_ii;
        __pyx_t_14 = 1;
        *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_13 * __pyx_v_out.strides[0]) )) + __pyx_t_14)) )) = __pyx_v_iy;
+148:                     ii = ii + 1
        __Pyx_TraceLine(148,0,__PYX_ERR(0, 148, __pyx_L1_error))
        __pyx_v_ii = (__pyx_v_ii + 1);
 149: 
+150:     return out[:ii, :]
  __Pyx_TraceLine(150,0,__PYX_ERR(0, 150, __pyx_L1_error))
  __pyx_t_6.data = __pyx_v_out.data;
  __pyx_t_6.memview = __pyx_v_out.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_6, 1);
  __pyx_t_7 = -1;
  if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_6,
    __pyx_v_out.shape[0], __pyx_v_out.strides[0], __pyx_v_out.suboffsets[0],
    0,
    0,
    &__pyx_t_7,
    0,
    __pyx_v_ii,
    0,
    0,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 150, __pyx_L1_error)
}

__pyx_t_6.shape[1] = __pyx_v_out.shape[1];
__pyx_t_6.strides[1] = __pyx_v_out.strides[1];
    __pyx_t_6.suboffsets[1] = -1;

__pyx_r = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
  goto __pyx_L0;
 151: 
 152: 
+153: cpdef zconsecutives(short[:, ::1] splits, short[:, ::1] coords):
static PyObject *__pyx_pw_6libfds_6cutils_5zconsecutives(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyObject *__pyx_f_6libfds_6cutils_zconsecutives(__Pyx_memviewslice __pyx_v_splits, __Pyx_memviewslice __pyx_v_coords, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_nc;
  int __pyx_v_ns;
  Py_ssize_t __pyx_v_ix;
  CYTHON_UNUSED Py_ssize_t __pyx_v_ii;
  Py_ssize_t __pyx_v_iii;
  Py_ssize_t __pyx_v_jjj;
  short __pyx_v_start_new;
  short __pyx_v_stop_new;
  short __pyx_v_x_new;
  short __pyx_v_y_new;
  short __pyx_v_x_old;
  short __pyx_v_y_old;
  short __pyx_v_start_old;
  short __pyx_v_stop_old;
  __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__14)
  __Pyx_TraceCall("zconsecutives", __pyx_f[0], 153, 0, __PYX_ERR(0, 153, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1);
  __Pyx_AddTraceback("libfds.cutils.zconsecutives", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_out, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6libfds_6cutils_5zconsecutives(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6libfds_6cutils_5zconsecutives = {"zconsecutives", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6libfds_6cutils_5zconsecutives, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6libfds_6cutils_5zconsecutives(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  __Pyx_memviewslice __pyx_v_splits = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_coords = { 0, 0, { 0 }, { 0 }, { 0 } };
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("zconsecutives (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_MACROS
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject **__pyx_pyargnames[] = {&__pyx_n_s_splits,&__pyx_n_s_coords,0};
  PyObject* values[2] = {0,0};
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        case  2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
      switch (__pyx_nargs) {
        case  0:
        if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_splits)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L3_error)
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_coords)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("zconsecutives", 1, 2, 2, 1); __PYX_ERR(0, 153, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t kwd_pos_args = __pyx_nargs;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "zconsecutives") < 0)) __PYX_ERR(0, 153, __pyx_L3_error)
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
      values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
    }
    __pyx_v_splits = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_splits.memview)) __PYX_ERR(0, 153, __pyx_L3_error)
    __pyx_v_coords = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_coords.memview)) __PYX_ERR(0, 153, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("zconsecutives", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 153, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_splits, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_coords, 1);
  __Pyx_AddTraceback("libfds.cutils.zconsecutives", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6libfds_6cutils_4zconsecutives(__pyx_self, __pyx_v_splits, __pyx_v_coords);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_splits, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_coords, 1);
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6libfds_6cutils_4zconsecutives(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_splits, __Pyx_memviewslice __pyx_v_coords) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__14)
  __Pyx_TraceCall("zconsecutives (wrapper)", __pyx_f[0], 153, 0, __PYX_ERR(0, 153, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6libfds_6cutils_zconsecutives(__pyx_v_splits, __pyx_v_coords, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libfds.cutils.zconsecutives", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __Pyx_TraceLine(153,0,__PYX_ERR(0, 153, __pyx_L1_error))
/* … */
  __pyx_tuple__31 = PyTuple_Pack(2, __pyx_n_s_splits, __pyx_n_s_coords); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_6libfds_6cutils_5zconsecutives, 0, __pyx_n_s_zconsecutives, NULL, __pyx_n_s_libfds_cutils, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_zconsecutives, __pyx_t_7) < 0) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_libfds_cutils_pyx, __pyx_n_s_zconsecutives, 153, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 153, __pyx_L1_error)
 154: 
+155:     cdef int nc = coords.shape[0]
  __Pyx_TraceLine(155,0,__PYX_ERR(0, 155, __pyx_L1_error))
  __pyx_v_nc = (__pyx_v_coords.shape[0]);
+156:     cdef int ns = splits.shape[0]
  __Pyx_TraceLine(156,0,__PYX_ERR(0, 156, __pyx_L1_error))
  __pyx_v_ns = (__pyx_v_splits.shape[0]);
 157:     cdef int old_length
+158:     cdef Py_ssize_t ix, ii, iii = 0, jjj = 0
  __Pyx_TraceLine(158,0,__PYX_ERR(0, 158, __pyx_L1_error))
  __pyx_v_iii = 0;
  __pyx_v_jjj = 0;
 159: 
 160:     cdef short start_new, stop_new, x_new, y_new
+161:     cdef short x_old = -1
  __Pyx_TraceLine(161,0,__PYX_ERR(0, 161, __pyx_L1_error))
  __pyx_v_x_old = -1;
+162:     cdef short y_old = -1
  __Pyx_TraceLine(162,0,__PYX_ERR(0, 162, __pyx_L1_error))
  __pyx_v_y_old = -1;
+163:     cdef short start_old = splits[0, 0]
  __Pyx_TraceLine(163,0,__PYX_ERR(0, 163, __pyx_L1_error))
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_start_old = (*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_splits.data + __pyx_t_1 * __pyx_v_splits.strides[0]) )) + __pyx_t_2)) )));
+164:     cdef short stop_old = splits[0, 1]
  __Pyx_TraceLine(164,0,__PYX_ERR(0, 164, __pyx_L1_error))
  __pyx_t_2 = 0;
  __pyx_t_1 = 1;
  __pyx_v_stop_old = (*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_splits.data + __pyx_t_2 * __pyx_v_splits.strides[0]) )) + __pyx_t_1)) )));
+165:     cdef short[:, ::1] out = np.empty((nc, 4), dtype=np.int16)
  __Pyx_TraceLine(165,0,__PYX_ERR(0, 165, __pyx_L1_error))
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_nc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error);
  __Pyx_INCREF(__pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_4)) __PYX_ERR(0, 165, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5)) __PYX_ERR(0, 165, __pyx_L1_error);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int16); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 165, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_out = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
 166: 
+167:     for ix in range(ns):
  __Pyx_TraceLine(167,0,__PYX_ERR(0, 167, __pyx_L1_error))
  __pyx_t_9 = __pyx_v_ns;
  __pyx_t_10 = __pyx_t_9;
  for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
    __pyx_v_ix = __pyx_t_11;
+168:         start_new = splits[ix, 0]
    __Pyx_TraceLine(168,0,__PYX_ERR(0, 168, __pyx_L1_error))
    __pyx_t_1 = __pyx_v_ix;
    __pyx_t_2 = 0;
    __pyx_v_start_new = (*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_splits.data + __pyx_t_1 * __pyx_v_splits.strides[0]) )) + __pyx_t_2)) )));
+169:         stop_new = splits[ix, 1]
    __Pyx_TraceLine(169,0,__PYX_ERR(0, 169, __pyx_L1_error))
    __pyx_t_2 = __pyx_v_ix;
    __pyx_t_1 = 1;
    __pyx_v_stop_new = (*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_splits.data + __pyx_t_2 * __pyx_v_splits.strides[0]) )) + __pyx_t_1)) )));
+170:         for ii in range(stop_new - start_new + 1):
    __Pyx_TraceLine(170,0,__PYX_ERR(0, 170, __pyx_L1_error))
    __pyx_t_12 = ((__pyx_v_stop_new - __pyx_v_start_new) + 1);
    __pyx_t_13 = __pyx_t_12;
    for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
      __pyx_v_ii = __pyx_t_14;
+171:             x_new = coords[iii, 0]
      __Pyx_TraceLine(171,0,__PYX_ERR(0, 171, __pyx_L1_error))
      __pyx_t_1 = __pyx_v_iii;
      __pyx_t_2 = 0;
      __pyx_v_x_new = (*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_coords.data + __pyx_t_1 * __pyx_v_coords.strides[0]) )) + __pyx_t_2)) )));
+172:             y_new = coords[iii, 1]
      __Pyx_TraceLine(172,0,__PYX_ERR(0, 172, __pyx_L1_error))
      __pyx_t_2 = __pyx_v_iii;
      __pyx_t_1 = 1;
      __pyx_v_y_new = (*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_coords.data + __pyx_t_2 * __pyx_v_coords.strides[0]) )) + __pyx_t_1)) )));
+173:             if x_new != x_old or y_new != y_old or start_new != start_old or stop_new != stop_old:
      __Pyx_TraceLine(173,0,__PYX_ERR(0, 173, __pyx_L1_error))
      __pyx_t_16 = (__pyx_v_x_new != __pyx_v_x_old);
      if (!__pyx_t_16) {
      } else {
        __pyx_t_15 = __pyx_t_16;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_16 = (__pyx_v_y_new != __pyx_v_y_old);
      if (!__pyx_t_16) {
      } else {
        __pyx_t_15 = __pyx_t_16;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_16 = (__pyx_v_start_new != __pyx_v_start_old);
      if (!__pyx_t_16) {
      } else {
        __pyx_t_15 = __pyx_t_16;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_16 = (__pyx_v_stop_new != __pyx_v_stop_old);
      __pyx_t_15 = __pyx_t_16;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_15) {
/* … */
      }
+174:                 out[jjj, 0] = start_new
        __Pyx_TraceLine(174,0,__PYX_ERR(0, 174, __pyx_L1_error))
        __pyx_t_1 = __pyx_v_jjj;
        __pyx_t_2 = 0;
        *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_1 * __pyx_v_out.strides[0]) )) + __pyx_t_2)) )) = __pyx_v_start_new;
+175:                 out[jjj, 1] = stop_new
        __Pyx_TraceLine(175,0,__PYX_ERR(0, 175, __pyx_L1_error))
        __pyx_t_2 = __pyx_v_jjj;
        __pyx_t_1 = 1;
        *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_2 * __pyx_v_out.strides[0]) )) + __pyx_t_1)) )) = __pyx_v_stop_new;
+176:                 out[jjj, 2] = x_new
        __Pyx_TraceLine(176,0,__PYX_ERR(0, 176, __pyx_L1_error))
        __pyx_t_1 = __pyx_v_jjj;
        __pyx_t_2 = 2;
        *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_1 * __pyx_v_out.strides[0]) )) + __pyx_t_2)) )) = __pyx_v_x_new;
+177:                 out[jjj, 3] = y_new
        __Pyx_TraceLine(177,0,__PYX_ERR(0, 177, __pyx_L1_error))
        __pyx_t_2 = __pyx_v_jjj;
        __pyx_t_1 = 3;
        *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_2 * __pyx_v_out.strides[0]) )) + __pyx_t_1)) )) = __pyx_v_y_new;
+178:                 jjj += 1
        __Pyx_TraceLine(178,0,__PYX_ERR(0, 178, __pyx_L1_error))
        __pyx_v_jjj = (__pyx_v_jjj + 1);
+179:             iii += 1
      __Pyx_TraceLine(179,0,__PYX_ERR(0, 179, __pyx_L1_error))
      __pyx_v_iii = (__pyx_v_iii + 1);
+180:             x_old = x_new
      __Pyx_TraceLine(180,0,__PYX_ERR(0, 180, __pyx_L1_error))
      __pyx_v_x_old = __pyx_v_x_new;
+181:             y_old = y_new
      __Pyx_TraceLine(181,0,__PYX_ERR(0, 181, __pyx_L1_error))
      __pyx_v_y_old = __pyx_v_y_new;
    }
+182:         start_old = start_new
    __Pyx_TraceLine(182,0,__PYX_ERR(0, 182, __pyx_L1_error))
    __pyx_v_start_old = __pyx_v_start_new;
+183:         stop_old = stop_new
    __Pyx_TraceLine(183,0,__PYX_ERR(0, 183, __pyx_L1_error))
    __pyx_v_stop_old = __pyx_v_stop_new;
  }
 184: 
+185:     return np.asarray(out[:jjj, :])
  __Pyx_TraceLine(185,0,__PYX_ERR(0, 185, __pyx_L1_error))
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8.data = __pyx_v_out.data;
  __pyx_t_8.memview = __pyx_v_out.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_8, 1);
  __pyx_t_9 = -1;
  if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_8,
    __pyx_v_out.shape[0], __pyx_v_out.strides[0], __pyx_v_out.suboffsets[0],
    0,
    0,
    &__pyx_t_9,
    0,
    __pyx_v_jjj,
    0,
    0,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 185, __pyx_L1_error)
}

__pyx_t_8.shape[1] = __pyx_v_out.shape[1];
__pyx_t_8.strides[1] = __pyx_v_out.strides[1];
    __pyx_t_8.suboffsets[1] = -1;

__pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_8, 2, (PyObject *(*)(char *)) __pyx_memview_get_short, (int (*)(char *, PyObject *)) __pyx_memview_set_short, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1);
  __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
  __pyx_t_4 = NULL;
  __pyx_t_9 = 0;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_5};
    __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;
 186: 
 187: 
+188: cpdef yconsecutives(short[:, ::1] splits, short[:, ::1] coords):
static PyObject *__pyx_pw_6libfds_6cutils_7yconsecutives(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyObject *__pyx_f_6libfds_6cutils_yconsecutives(__Pyx_memviewslice __pyx_v_splits, __Pyx_memviewslice __pyx_v_coords, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_nc;
  int __pyx_v_ns;
  Py_ssize_t __pyx_v_ix;
  CYTHON_UNUSED Py_ssize_t __pyx_v_ii;
  Py_ssize_t __pyx_v_iii;
  Py_ssize_t __pyx_v_jjj;
  short __pyx_v_start_new;
  short __pyx_v_stop_new;
  short __pyx_v_x_new;
  short __pyx_v_x_old;
  short __pyx_v_start_old;
  short __pyx_v_stop_old;
  __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__15)
  __Pyx_TraceCall("yconsecutives", __pyx_f[0], 188, 0, __PYX_ERR(0, 188, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1);
  __Pyx_AddTraceback("libfds.cutils.yconsecutives", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_out, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6libfds_6cutils_7yconsecutives(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6libfds_6cutils_7yconsecutives = {"yconsecutives", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6libfds_6cutils_7yconsecutives, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6libfds_6cutils_7yconsecutives(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  __Pyx_memviewslice __pyx_v_splits = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_coords = { 0, 0, { 0 }, { 0 }, { 0 } };
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("yconsecutives (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_MACROS
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject **__pyx_pyargnames[] = {&__pyx_n_s_splits,&__pyx_n_s_coords,0};
  PyObject* values[2] = {0,0};
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        case  2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
      switch (__pyx_nargs) {
        case  0:
        if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_splits)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 188, __pyx_L3_error)
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_coords)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 188, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("yconsecutives", 1, 2, 2, 1); __PYX_ERR(0, 188, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t kwd_pos_args = __pyx_nargs;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "yconsecutives") < 0)) __PYX_ERR(0, 188, __pyx_L3_error)
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
      values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
    }
    __pyx_v_splits = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_splits.memview)) __PYX_ERR(0, 188, __pyx_L3_error)
    __pyx_v_coords = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_coords.memview)) __PYX_ERR(0, 188, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("yconsecutives", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 188, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_splits, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_coords, 1);
  __Pyx_AddTraceback("libfds.cutils.yconsecutives", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6libfds_6cutils_6yconsecutives(__pyx_self, __pyx_v_splits, __pyx_v_coords);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_splits, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_coords, 1);
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6libfds_6cutils_6yconsecutives(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_splits, __Pyx_memviewslice __pyx_v_coords) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__15)
  __Pyx_TraceCall("yconsecutives (wrapper)", __pyx_f[0], 188, 0, __PYX_ERR(0, 188, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_6libfds_6cutils_yconsecutives(__pyx_v_splits, __pyx_v_coords, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libfds.cutils.yconsecutives", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __Pyx_TraceLine(188,0,__PYX_ERR(0, 188, __pyx_L1_error))

  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_6libfds_6cutils_7yconsecutives, 0, __pyx_n_s_yconsecutives, NULL, __pyx_n_s_libfds_cutils, __pyx_d, ((PyObject *)__pyx_codeobj__15)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_yconsecutives, __pyx_t_7) < 0) __PYX_ERR(0, 188, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
/* … */
  __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_libfds_cutils_pyx, __pyx_n_s_yconsecutives, 188, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 188, __pyx_L1_error)
 189: 
+190:     cdef int nc = coords.shape[0]
  __Pyx_TraceLine(190,0,__PYX_ERR(0, 190, __pyx_L1_error))
  __pyx_v_nc = (__pyx_v_coords.shape[0]);
+191:     cdef int ns = splits.shape[0]
  __Pyx_TraceLine(191,0,__PYX_ERR(0, 191, __pyx_L1_error))
  __pyx_v_ns = (__pyx_v_splits.shape[0]);
 192:     cdef int old_length
+193:     cdef Py_ssize_t ix, ii, iii = 0, jjj = 0
  __Pyx_TraceLine(193,0,__PYX_ERR(0, 193, __pyx_L1_error))
  __pyx_v_iii = 0;
  __pyx_v_jjj = 0;
 194: 
+195:     cdef short start_new, stop_new, x_new, x_old = -1
  __Pyx_TraceLine(195,0,__PYX_ERR(0, 195, __pyx_L1_error))
  __pyx_v_x_old = -1;
+196:     cdef short start_old = splits[0, 0]
  __Pyx_TraceLine(196,0,__PYX_ERR(0, 196, __pyx_L1_error))
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_v_start_old = (*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_splits.data + __pyx_t_1 * __pyx_v_splits.strides[0]) )) + __pyx_t_2)) )));
+197:     cdef short stop_old = splits[0, 1]
  __Pyx_TraceLine(197,0,__PYX_ERR(0, 197, __pyx_L1_error))
  __pyx_t_2 = 0;
  __pyx_t_1 = 1;
  __pyx_v_stop_old = (*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_splits.data + __pyx_t_2 * __pyx_v_splits.strides[0]) )) + __pyx_t_1)) )));
+198:     cdef short[:, ::1] out = np.empty((nc, 3), dtype=np.int16)
  __Pyx_TraceLine(198,0,__PYX_ERR(0, 198, __pyx_L1_error))
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_nc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_3)) __PYX_ERR(0, 198, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5)) __PYX_ERR(0, 198, __pyx_L1_error);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_int16); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_7) < 0) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_out = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
 199: 
+200:     for ix in range(ns):
  __Pyx_TraceLine(200,0,__PYX_ERR(0, 200, __pyx_L1_error))
  __pyx_t_9 = __pyx_v_ns;
  __pyx_t_10 = __pyx_t_9;
  for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
    __pyx_v_ix = __pyx_t_11;
+201:         start_new = splits[ix, 0]
    __Pyx_TraceLine(201,0,__PYX_ERR(0, 201, __pyx_L1_error))
    __pyx_t_1 = __pyx_v_ix;
    __pyx_t_2 = 0;
    __pyx_v_start_new = (*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_splits.data + __pyx_t_1 * __pyx_v_splits.strides[0]) )) + __pyx_t_2)) )));
+202:         stop_new = splits[ix, 1]
    __Pyx_TraceLine(202,0,__PYX_ERR(0, 202, __pyx_L1_error))
    __pyx_t_2 = __pyx_v_ix;
    __pyx_t_1 = 1;
    __pyx_v_stop_new = (*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_splits.data + __pyx_t_2 * __pyx_v_splits.strides[0]) )) + __pyx_t_1)) )));
+203:         for ii in range(stop_new - start_new + 1):
    __Pyx_TraceLine(203,0,__PYX_ERR(0, 203, __pyx_L1_error))
    __pyx_t_12 = ((__pyx_v_stop_new - __pyx_v_start_new) + 1);
    __pyx_t_13 = __pyx_t_12;
    for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
      __pyx_v_ii = __pyx_t_14;
+204:             x_new = coords[iii, 0]
      __Pyx_TraceLine(204,0,__PYX_ERR(0, 204, __pyx_L1_error))
      __pyx_t_1 = __pyx_v_iii;
      __pyx_t_2 = 0;
      __pyx_v_x_new = (*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_coords.data + __pyx_t_1 * __pyx_v_coords.strides[0]) )) + __pyx_t_2)) )));
+205:             if x_new != x_old or start_new != start_old or stop_new != stop_old:
      __Pyx_TraceLine(205,0,__PYX_ERR(0, 205, __pyx_L1_error))
      __pyx_t_16 = (__pyx_v_x_new != __pyx_v_x_old);
      if (!__pyx_t_16) {
      } else {
        __pyx_t_15 = __pyx_t_16;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_16 = (__pyx_v_start_new != __pyx_v_start_old);
      if (!__pyx_t_16) {
      } else {
        __pyx_t_15 = __pyx_t_16;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_16 = (__pyx_v_stop_new != __pyx_v_stop_old);
      __pyx_t_15 = __pyx_t_16;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_15) {
/* … */
      }
+206:                 out[jjj, 0] = start_new
        __Pyx_TraceLine(206,0,__PYX_ERR(0, 206, __pyx_L1_error))
        __pyx_t_2 = __pyx_v_jjj;
        __pyx_t_1 = 0;
        *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_2 * __pyx_v_out.strides[0]) )) + __pyx_t_1)) )) = __pyx_v_start_new;
+207:                 out[jjj, 1] = stop_new
        __Pyx_TraceLine(207,0,__PYX_ERR(0, 207, __pyx_L1_error))
        __pyx_t_1 = __pyx_v_jjj;
        __pyx_t_2 = 1;
        *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_1 * __pyx_v_out.strides[0]) )) + __pyx_t_2)) )) = __pyx_v_stop_new;
+208:                 out[jjj, 2] = x_new
        __Pyx_TraceLine(208,0,__PYX_ERR(0, 208, __pyx_L1_error))
        __pyx_t_2 = __pyx_v_jjj;
        __pyx_t_1 = 2;
        *((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_out.data + __pyx_t_2 * __pyx_v_out.strides[0]) )) + __pyx_t_1)) )) = __pyx_v_x_new;
+209:                 jjj += 1
        __Pyx_TraceLine(209,0,__PYX_ERR(0, 209, __pyx_L1_error))
        __pyx_v_jjj = (__pyx_v_jjj + 1);
+210:             iii += 1
      __Pyx_TraceLine(210,0,__PYX_ERR(0, 210, __pyx_L1_error))
      __pyx_v_iii = (__pyx_v_iii + 1);
+211:             x_old = x_new
      __Pyx_TraceLine(211,0,__PYX_ERR(0, 211, __pyx_L1_error))
      __pyx_v_x_old = __pyx_v_x_new;
    }
+212:         start_old = start_new
    __Pyx_TraceLine(212,0,__PYX_ERR(0, 212, __pyx_L1_error))
    __pyx_v_start_old = __pyx_v_start_new;
+213:         stop_old = stop_new
    __Pyx_TraceLine(213,0,__PYX_ERR(0, 213, __pyx_L1_error))
    __pyx_v_stop_old = __pyx_v_stop_new;
  }
 214: 
+215:     return np.asarray(out[:jjj, :])
  __Pyx_TraceLine(215,0,__PYX_ERR(0, 215, __pyx_L1_error))
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8.data = __pyx_v_out.data;
  __pyx_t_8.memview = __pyx_v_out.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_8, 1);
  __pyx_t_9 = -1;
  if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_8,
    __pyx_v_out.shape[0], __pyx_v_out.strides[0], __pyx_v_out.suboffsets[0],
    0,
    0,
    &__pyx_t_9,
    0,
    __pyx_v_jjj,
    0,
    0,
    1,
    0,
    1) < 0))
{
    __PYX_ERR(0, 215, __pyx_L1_error)
}

__pyx_t_8.shape[1] = __pyx_v_out.shape[1];
__pyx_t_8.strides[1] = __pyx_v_out.strides[1];
    __pyx_t_8.suboffsets[1] = -1;

__pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_8, 2, (PyObject *(*)(char *)) __pyx_memview_get_short, (int (*)(char *, PyObject *)) __pyx_memview_set_short, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1);
  __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
  __pyx_t_4 = NULL;
  __pyx_t_9 = 0;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_9 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_5};
    __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 215, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;
 216: 
 217: 
+218: cpdef void test3d(double[:, :, ::1] K, double[:, :, ::1] E, double odx, int cpu) noexcept nogil:
static PyObject *__pyx_pw_6libfds_6cutils_9test3d(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static void __pyx_f_6libfds_6cutils_test3d(__Pyx_memviewslice __pyx_v_K, __Pyx_memviewslice __pyx_v_E, double __pyx_v_odx, int __pyx_v_cpu, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_ix;
  Py_ssize_t __pyx_v_iy;
  Py_ssize_t __pyx_v_iz;
  int __pyx_v_nx;
  int __pyx_v_ny;
  int __pyx_v_nz;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__16)
  __Pyx_TraceCall("test3d", __pyx_f[0], 218, 1, __PYX_ERR(0, 218, __pyx_L1_error));
/* … */
  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  #ifdef WITH_THREAD
  __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_WriteUnraisable("libfds.cutils.test3d", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 1);
  __Pyx_RefNannyFinishContextNogil()
}

/* Python wrapper */
static PyObject *__pyx_pw_6libfds_6cutils_9test3d(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6libfds_6cutils_9test3d = {"test3d", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6libfds_6cutils_9test3d, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6libfds_6cutils_9test3d(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  __Pyx_memviewslice __pyx_v_K = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_E = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_odx;
  int __pyx_v_cpu;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("test3d (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_MACROS
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject **__pyx_pyargnames[] = {&__pyx_n_s_K,&__pyx_n_s_E,&__pyx_n_s_odx,&__pyx_n_s_cpu,0};
  PyObject* values[4] = {0,0,0,0};
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        case  4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
      switch (__pyx_nargs) {
        case  0:
        if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_K)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L3_error)
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_E)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("test3d", 1, 4, 4, 1); __PYX_ERR(0, 218, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_odx)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[2]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("test3d", 1, 4, 4, 2); __PYX_ERR(0, 218, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cpu)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[3]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("test3d", 1, 4, 4, 3); __PYX_ERR(0, 218, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t kwd_pos_args = __pyx_nargs;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "test3d") < 0)) __PYX_ERR(0, 218, __pyx_L3_error)
      }
    } else if (unlikely(__pyx_nargs != 4)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
      values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
      values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
      values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
    }
    __pyx_v_K = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_K.memview)) __PYX_ERR(0, 218, __pyx_L3_error)
    __pyx_v_E = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_E.memview)) __PYX_ERR(0, 218, __pyx_L3_error)
    __pyx_v_odx = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_odx == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L3_error)
    __pyx_v_cpu = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_cpu == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("test3d", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 218, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_K, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_E, 1);
  __Pyx_AddTraceback("libfds.cutils.test3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6libfds_6cutils_8test3d(__pyx_self, __pyx_v_K, __pyx_v_E, __pyx_v_odx, __pyx_v_cpu);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_K, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_E, 1);
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6libfds_6cutils_8test3d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_K, __Pyx_memviewslice __pyx_v_E, double __pyx_v_odx, int __pyx_v_cpu) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__16)
  __Pyx_TraceCall("test3d (wrapper)", __pyx_f[0], 218, 0, __PYX_ERR(0, 218, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6libfds_6cutils_test3d(__pyx_v_K, __pyx_v_E, __pyx_v_odx, __pyx_v_cpu, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libfds.cutils.test3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __Pyx_TraceLine(218,0,__PYX_ERR(0, 218, __pyx_L1_error))
/* … */
  __pyx_tuple__32 = PyTuple_Pack(4, __pyx_n_s_K, __pyx_n_s_E, __pyx_n_s_odx, __pyx_n_s_cpu); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);
  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_6libfds_6cutils_9test3d, 0, __pyx_n_s_test3d, NULL, __pyx_n_s_libfds_cutils, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test3d, __pyx_t_7) < 0) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 4, 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_src_libfds_cutils_pyx, __pyx_n_s_test3d, 218, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 218, __pyx_L1_error)
 219: 
 220:     cdef Py_ssize_t ix, iy, iz
+221:     cdef int nx = K.shape[0]
  __Pyx_TraceLine(221,1,__PYX_ERR(0, 221, __pyx_L1_error))
  __pyx_v_nx = (__pyx_v_K.shape[0]);
+222:     cdef int ny = K.shape[1]
  __Pyx_TraceLine(222,1,__PYX_ERR(0, 222, __pyx_L1_error))
  __pyx_v_ny = (__pyx_v_K.shape[1]);
+223:     cdef int nz = K.shape[2]
  __Pyx_TraceLine(223,1,__PYX_ERR(0, 223, __pyx_L1_error))
  __pyx_v_nz = (__pyx_v_K.shape[2]);
 224: 
+225:     if cpu == 1:
  __Pyx_TraceLine(225,1,__PYX_ERR(0, 225, __pyx_L1_error))
  __pyx_t_1 = (__pyx_v_cpu == 1);
  if (__pyx_t_1) {
/* … */
    goto __pyx_L3;
  }
+226:         for ix in range(5, nx - 5):
    __Pyx_TraceLine(226,1,__PYX_ERR(0, 226, __pyx_L1_error))
    __pyx_t_2 = (__pyx_v_nx - 5);
    __pyx_t_3 = __pyx_t_2;
    for (__pyx_t_4 = 5; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_ix = __pyx_t_4;
+227:             for iy in range(5, ny - 5):
      __Pyx_TraceLine(227,1,__PYX_ERR(0, 227, __pyx_L1_error))
      __pyx_t_5 = (__pyx_v_ny - 5);
      __pyx_t_6 = __pyx_t_5;
      for (__pyx_t_7 = 5; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
        __pyx_v_iy = __pyx_t_7;
+228:                 for iz in range(5, nz - 5):
        __Pyx_TraceLine(228,1,__PYX_ERR(0, 228, __pyx_L1_error))
        __pyx_t_8 = (__pyx_v_nz - 5);
        __pyx_t_9 = __pyx_t_8;
        for (__pyx_t_10 = 5; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
          __pyx_v_iz = __pyx_t_10;
+229:                     K[ix, iy, iz] = (a11c[1]*(E[ix+1, iy+1, iz+1] - E[ix-1, iy-1, iz-1]) +
          __Pyx_TraceLine(229,1,__PYX_ERR(0, 229, __pyx_L1_error))
          __pyx_t_11 = (__pyx_v_ix + 1);
          __pyx_t_12 = (__pyx_v_iy + 1);
          __pyx_t_13 = (__pyx_v_iz + 1);
          __pyx_t_14 = (__pyx_v_ix - 1);
          __pyx_t_15 = (__pyx_v_iy - 1);
          __pyx_t_16 = (__pyx_v_iz - 1);
/* … */
          __Pyx_TraceLine(229,1,__PYX_ERR(0, 229, __pyx_L1_error))
          __pyx_t_41 = __pyx_v_ix;
          __pyx_t_42 = __pyx_v_iy;
          __pyx_t_43 = __pyx_v_iz;
          *((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_K.data + __pyx_t_41 * __pyx_v_K.strides[0]) ) + __pyx_t_42 * __pyx_v_K.strides[1]) )) + __pyx_t_43)) )) = (((((((a11c[1]) * ((*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_11 * __pyx_v_E.strides[0]) ) + __pyx_t_12 * __pyx_v_E.strides[1]) )) + __pyx_t_13)) ))) - (*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_14 * __pyx_v_E.strides[0]) ) + __pyx_t_15 * __pyx_v_E.strides[1]) )) + __pyx_t_16)) ))))) + ((a11c[2]) * ((*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_17 * __pyx_v_E.strides[0]) ) + __pyx_t_18 * __pyx_v_E.strides[1]) )) + __pyx_t_19)) ))) - (*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_20 * __pyx_v_E.strides[0]) ) + __pyx_t_21 * __pyx_v_E.strides[1]) )) + __pyx_t_22)) )))))) + ((a11c[3]) * ((*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_23 * __pyx_v_E.strides[0]) ) + __pyx_t_24 * __pyx_v_E.strides[1]) )) + __pyx_t_25)) ))) - (*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_26 * __pyx_v_E.strides[0]) ) + __pyx_t_27 * __pyx_v_E.strides[1]) )) + __pyx_t_28)) )))))) + ((a11c[4]) * ((*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_29 * __pyx_v_E.strides[0]) ) + __pyx_t_30 * __pyx_v_E.strides[1]) )) + __pyx_t_31)) ))) - (*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_32 * __pyx_v_E.strides[0]) ) + __pyx_t_33 * __pyx_v_E.strides[1]) )) + __pyx_t_34)) )))))) + ((a11c[5]) * ((*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_35 * __pyx_v_E.strides[0]) ) + __pyx_t_36 * __pyx_v_E.strides[1]) )) + __pyx_t_37)) ))) - (*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_38 * __pyx_v_E.strides[0]) ) + __pyx_t_39 * __pyx_v_E.strides[1]) )) + __pyx_t_40)) )))))) * __pyx_v_odx);
        }
      }
    }
+230:                                     a11c[2]*(E[ix+2, iy+2, iz+2] - E[ix-2, iy-2, iz-2]) +
          __Pyx_TraceLine(230,1,__PYX_ERR(0, 230, __pyx_L1_error))
          __pyx_t_17 = (__pyx_v_ix + 2);
          __pyx_t_18 = (__pyx_v_iy + 2);
          __pyx_t_19 = (__pyx_v_iz + 2);
          __pyx_t_20 = (__pyx_v_ix - 2);
          __pyx_t_21 = (__pyx_v_iy - 2);
          __pyx_t_22 = (__pyx_v_iz - 2);
+231:                                     a11c[3]*(E[ix+3, iy+3, iz+3] - E[ix-3, iy-3, iz-3]) +
          __Pyx_TraceLine(231,1,__PYX_ERR(0, 231, __pyx_L1_error))
          __pyx_t_23 = (__pyx_v_ix + 3);
          __pyx_t_24 = (__pyx_v_iy + 3);
          __pyx_t_25 = (__pyx_v_iz + 3);
          __pyx_t_26 = (__pyx_v_ix - 3);
          __pyx_t_27 = (__pyx_v_iy - 3);
          __pyx_t_28 = (__pyx_v_iz - 3);
+232:                                     a11c[4]*(E[ix+4, iy+4, iz+4] - E[ix-4, iy-4, iz-4]) +
          __Pyx_TraceLine(232,1,__PYX_ERR(0, 232, __pyx_L1_error))
          __pyx_t_29 = (__pyx_v_ix + 4);
          __pyx_t_30 = (__pyx_v_iy + 4);
          __pyx_t_31 = (__pyx_v_iz + 4);
          __pyx_t_32 = (__pyx_v_ix - 4);
          __pyx_t_33 = (__pyx_v_iy - 4);
          __pyx_t_34 = (__pyx_v_iz - 4);
+233:                                     a11c[5]*(E[ix+5, iy+5, iz+5] - E[ix-5, iy-5, iz-5]))*odx
          __Pyx_TraceLine(233,1,__PYX_ERR(0, 233, __pyx_L1_error))
          __pyx_t_35 = (__pyx_v_ix + 5);
          __pyx_t_36 = (__pyx_v_iy + 5);
          __pyx_t_37 = (__pyx_v_iz + 5);
          __pyx_t_38 = (__pyx_v_ix - 5);
          __pyx_t_39 = (__pyx_v_iy - 5);
          __pyx_t_40 = (__pyx_v_iz - 5);
 234: 
 235:     else:
+236:         for ix in prange(5, nx - 5, nogil=True, num_threads=cpu):
  __Pyx_TraceLine(236,1,__PYX_ERR(0, 236, __pyx_L1_error))
  /*else*/ {
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        _save = NULL;
        if (PyGILState_Check()) {
          Py_UNBLOCK_THREADS
        }
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {
          __pyx_t_2 = (__pyx_v_nx - 5);
          {
              #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                  #undef likely
                  #undef unlikely
                  #define likely(x)   (x)
                  #define unlikely(x) (x)
              #endif
              __pyx_t_7 = (__pyx_t_2 - 5 + 1 - 1/abs(1)) / 1;
              if (__pyx_t_7 > 0)
              {
                  #ifdef _OPENMP
                  #pragma omp parallel
                  #endif /* _OPENMP */
                  {
                      #ifdef _OPENMP
                      #pragma omp for firstprivate(__pyx_v_ix) lastprivate(__pyx_v_ix) lastprivate(__pyx_v_iy) lastprivate(__pyx_v_iz)          __pyx_t_2 = (__pyx_v_nx - 5);
          {
              #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                  #undef likely
                  #undef unlikely
                  #define likely(x)   (x)
                  #define unlikely(x) (x)
              #endif
              __pyx_t_7 = (__pyx_t_2 - 5 + 1 - 1/abs(1)) / 1;
              if (__pyx_t_7 > 0)
              {
                  #ifdef _OPENMP
                  #pragma omp parallel
                  #endif /* _OPENMP */
                  {
                      #ifdef _OPENMP
                      #pragma omp for firstprivate(__pyx_v_ix) lastprivate(__pyx_v_ix) lastprivate(__pyx_v_iy) lastprivate(__pyx_v_iz) num_threads(__pyx_v_cpu)
                      #endif /* _OPENMP */
                      for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_7; __pyx_t_4++){
                          {
                              __pyx_v_ix = (Py_ssize_t)(5 + 1 * __pyx_t_4);
                              /* Initialize private variables to invalid values */
                              __pyx_v_iy = ((Py_ssize_t)0xbad0bad0);
                              __pyx_v_iz = ((Py_ssize_t)0xbad0bad0);
/* … */
        __Pyx_TraceLine(236,1,__PYX_ERR(0, 236, __pyx_L11_error))
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            if (_save) {
              Py_BLOCK_THREADS
            }
            #endif
            goto __pyx_L12;
          }
          __pyx_L11_error: {
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            if (_save) {
              Py_BLOCK_THREADS
            }
            #endif
            goto __pyx_L1_error;
          }
          __pyx_L12:;
        }
    }
  }
  __pyx_L3:;
+237:             for iy in range(5, ny - 5):
                              __Pyx_TraceLine(237,1,__PYX_ERR(0, 237, __pyx_L15_error))
                              __pyx_t_3 = (__pyx_v_ny - 5);
                              __pyx_t_5 = __pyx_t_3;
                              for (__pyx_t_10 = 5; __pyx_t_10 < __pyx_t_5; __pyx_t_10+=1) {
                                __pyx_v_iy = __pyx_t_10;
+238:                 for iz in range(5, nz - 5):
                                __Pyx_TraceLine(238,1,__PYX_ERR(0, 238, __pyx_L15_error))
                                __pyx_t_6 = (__pyx_v_nz - 5);
                                __pyx_t_8 = __pyx_t_6;
                                for (__pyx_t_44 = 5; __pyx_t_44 < __pyx_t_8; __pyx_t_44+=1) {
                                  __pyx_v_iz = __pyx_t_44;
+239:                     K[ix, iy, iz] = (a11c[1]*(E[ix+1, iy+1, iz+1] - E[ix-1, iy-1, iz-1]) +
                                  __Pyx_TraceLine(239,1,__PYX_ERR(0, 239, __pyx_L15_error))
                                  __pyx_t_40 = (__pyx_v_ix + 1);
                                  __pyx_t_39 = (__pyx_v_iy + 1);
                                  __pyx_t_38 = (__pyx_v_iz + 1);
                                  __pyx_t_37 = (__pyx_v_ix - 1);
                                  __pyx_t_36 = (__pyx_v_iy - 1);
                                  __pyx_t_35 = (__pyx_v_iz - 1);
/* … */
                                  __Pyx_TraceLine(239,1,__PYX_ERR(0, 239, __pyx_L15_error))
                                  __pyx_t_43 = __pyx_v_ix;
                                  __pyx_t_42 = __pyx_v_iy;
                                  __pyx_t_41 = __pyx_v_iz;
                                  *((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_K.data + __pyx_t_43 * __pyx_v_K.strides[0]) ) + __pyx_t_42 * __pyx_v_K.strides[1]) )) + __pyx_t_41)) )) = (((((((a11c[1]) * ((*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_40 * __pyx_v_E.strides[0]) ) + __pyx_t_39 * __pyx_v_E.strides[1]) )) + __pyx_t_38)) ))) - (*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_37 * __pyx_v_E.strides[0]) ) + __pyx_t_36 * __pyx_v_E.strides[1]) )) + __pyx_t_35)) ))))) + ((a11c[2]) * ((*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_34 * __pyx_v_E.strides[0]) ) + __pyx_t_33 * __pyx_v_E.strides[1]) )) + __pyx_t_32)) ))) - (*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_31 * __pyx_v_E.strides[0]) ) + __pyx_t_30 * __pyx_v_E.strides[1]) )) + __pyx_t_29)) )))))) + ((a11c[3]) * ((*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_28 * __pyx_v_E.strides[0]) ) + __pyx_t_27 * __pyx_v_E.strides[1]) )) + __pyx_t_26)) ))) - (*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_25 * __pyx_v_E.strides[0]) ) + __pyx_t_24 * __pyx_v_E.strides[1]) )) + __pyx_t_23)) )))))) + ((a11c[4]) * ((*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_22 * __pyx_v_E.strides[0]) ) + __pyx_t_21 * __pyx_v_E.strides[1]) )) + __pyx_t_20)) ))) - (*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_19 * __pyx_v_E.strides[0]) ) + __pyx_t_18 * __pyx_v_E.strides[1]) )) + __pyx_t_17)) )))))) + ((a11c[5]) * ((*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_16 * __pyx_v_E.strides[0]) ) + __pyx_t_15 * __pyx_v_E.strides[1]) )) + __pyx_t_14)) ))) - (*((double *) ( /* dim=2 */ ((char *) (((double *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_E.data + __pyx_t_13 * __pyx_v_E.strides[0]) ) + __pyx_t_12 * __pyx_v_E.strides[1]) )) + __pyx_t_11)) )))))) * __pyx_v_odx);
                                }
                              }
                              goto __pyx_L22;
                              __pyx_L15_error:;
                              {
                                  #ifdef WITH_THREAD
                                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                                  #endif
                                  #ifdef _OPENMP
                                  #pragma omp flush(__pyx_parallel_exc_type)
                                  #endif /* _OPENMP */
                                  if (!__pyx_parallel_exc_type) {
                                    __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb);
                                    __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno;
                                    __Pyx_GOTREF(__pyx_parallel_exc_type);
                                  }
                                  #ifdef WITH_THREAD
                                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                                  #endif
                              }
                              __pyx_parallel_why = 4;
                              goto __pyx_L21;
                              __pyx_L21:;
                              #ifdef _OPENMP
                              #pragma omp critical(__pyx_parallel_lastprivates6)
                              #endif /* _OPENMP */
                              {
                                  __pyx_parallel_temp0 = __pyx_v_ix;
                                  __pyx_parallel_temp1 = __pyx_v_iy;
                                  __pyx_parallel_temp2 = __pyx_v_iz;
                              }
                              __pyx_L22:;
                              #ifdef _OPENMP
                              #pragma omp flush(__pyx_parallel_why)
                              #endif /* _OPENMP */
                          }
                      }
                      #ifdef _OPENMP
                      Py_END_ALLOW_THREADS
                      #else
{
#ifdef WITH_THREAD
                      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                      #endif
                      #endif /* _OPENMP */
                      /* Clean up any temporaries */
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      #ifndef _OPENMP
}
#endif /* _OPENMP */
                  }
              }
              if (__pyx_parallel_exc_type) {
                /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */
                __pyx_parallel_why = 4;
              }
              if (__pyx_parallel_why) {
                __pyx_v_ix = __pyx_parallel_temp0;
                __pyx_v_iy = __pyx_parallel_temp1;
                __pyx_v_iz = __pyx_parallel_temp2;
                switch (__pyx_parallel_why) {
                      case 4:
                  {
                      #ifdef WITH_THREAD
                      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                      #endif
                      __Pyx_GIVEREF(__pyx_parallel_exc_type);
                      __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb);
                      __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno;
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                  }
                  goto __pyx_L11_error;
                }
              }
          }
          #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
              #undef likely
              #undef unlikely
              #define likely(x)   __builtin_expect(!!(x), 1)
              #define unlikely(x) __builtin_expect(!!(x), 0)
          #endif
        }
+240:                                     a11c[2]*(E[ix+2, iy+2, iz+2] - E[ix-2, iy-2, iz-2]) +
                                  __Pyx_TraceLine(240,1,__PYX_ERR(0, 240, __pyx_L15_error))
                                  __pyx_t_34 = (__pyx_v_ix + 2);
                                  __pyx_t_33 = (__pyx_v_iy + 2);
                                  __pyx_t_32 = (__pyx_v_iz + 2);
                                  __pyx_t_31 = (__pyx_v_ix - 2);
                                  __pyx_t_30 = (__pyx_v_iy - 2);
                                  __pyx_t_29 = (__pyx_v_iz - 2);
+241:                                     a11c[3]*(E[ix+3, iy+3, iz+3] - E[ix-3, iy-3, iz-3]) +
                                  __Pyx_TraceLine(241,1,__PYX_ERR(0, 241, __pyx_L15_error))
                                  __pyx_t_28 = (__pyx_v_ix + 3);
                                  __pyx_t_27 = (__pyx_v_iy + 3);
                                  __pyx_t_26 = (__pyx_v_iz + 3);
                                  __pyx_t_25 = (__pyx_v_ix - 3);
                                  __pyx_t_24 = (__pyx_v_iy - 3);
                                  __pyx_t_23 = (__pyx_v_iz - 3);
+242:                                     a11c[4]*(E[ix+4, iy+4, iz+4] - E[ix-4, iy-4, iz-4]) +
                                  __Pyx_TraceLine(242,1,__PYX_ERR(0, 242, __pyx_L15_error))
                                  __pyx_t_22 = (__pyx_v_ix + 4);
                                  __pyx_t_21 = (__pyx_v_iy + 4);
                                  __pyx_t_20 = (__pyx_v_iz + 4);
                                  __pyx_t_19 = (__pyx_v_ix - 4);
                                  __pyx_t_18 = (__pyx_v_iy - 4);
                                  __pyx_t_17 = (__pyx_v_iz - 4);
+243:                                     a11c[5]*(E[ix+5, iy+5, iz+5] - E[ix-5, iy-5, iz-5]))*odx
                                  __Pyx_TraceLine(243,1,__PYX_ERR(0, 243, __pyx_L15_error))
                                  __pyx_t_16 = (__pyx_v_ix + 5);
                                  __pyx_t_15 = (__pyx_v_iy + 5);
                                  __pyx_t_14 = (__pyx_v_iz + 5);
                                  __pyx_t_13 = (__pyx_v_ix - 5);
                                  __pyx_t_12 = (__pyx_v_iy - 5);
                                  __pyx_t_11 = (__pyx_v_iz - 5);
 244: 
 245: 
+246: cpdef void test2d(double[:, ::1] K, double[:, ::1] E, double odx, int cpu) noexcept nogil:
static PyObject *__pyx_pw_6libfds_6cutils_11test2d(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static void __pyx_f_6libfds_6cutils_test2d(__Pyx_memviewslice __pyx_v_K, __Pyx_memviewslice __pyx_v_E, double __pyx_v_odx, int __pyx_v_cpu, CYTHON_UNUSED int __pyx_skip_dispatch) {
  Py_ssize_t __pyx_v_ix;
  Py_ssize_t __pyx_v_iy;
  int __pyx_v_nx;
  int __pyx_v_ny;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__17)
  __Pyx_TraceCall("test2d", __pyx_f[0], 246, 1, __PYX_ERR(0, 246, __pyx_L1_error));
/* … */
  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  #ifdef WITH_THREAD
  __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
  #endif
  __Pyx_WriteUnraisable("libfds.cutils.test2d", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  #ifdef WITH_THREAD
  __Pyx_PyGILState_Release(__pyx_gilstate_save);
  #endif
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 1);
  __Pyx_RefNannyFinishContextNogil()
}

/* Python wrapper */
static PyObject *__pyx_pw_6libfds_6cutils_11test2d(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6libfds_6cutils_11test2d = {"test2d", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6libfds_6cutils_11test2d, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6libfds_6cutils_11test2d(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  __Pyx_memviewslice __pyx_v_K = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_E = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_odx;
  int __pyx_v_cpu;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("test2d (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_MACROS
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject **__pyx_pyargnames[] = {&__pyx_n_s_K,&__pyx_n_s_E,&__pyx_n_s_odx,&__pyx_n_s_cpu,0};
  PyObject* values[4] = {0,0,0,0};
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        case  4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
      switch (__pyx_nargs) {
        case  0:
        if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_K)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 246, __pyx_L3_error)
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_E)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 246, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("test2d", 1, 4, 4, 1); __PYX_ERR(0, 246, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_odx)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[2]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 246, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("test2d", 1, 4, 4, 2); __PYX_ERR(0, 246, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cpu)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[3]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 246, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("test2d", 1, 4, 4, 3); __PYX_ERR(0, 246, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t kwd_pos_args = __pyx_nargs;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "test2d") < 0)) __PYX_ERR(0, 246, __pyx_L3_error)
      }
    } else if (unlikely(__pyx_nargs != 4)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
      values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
      values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
      values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
    }
    __pyx_v_K = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_K.memview)) __PYX_ERR(0, 246, __pyx_L3_error)
    __pyx_v_E = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_E.memview)) __PYX_ERR(0, 246, __pyx_L3_error)
    __pyx_v_odx = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_odx == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 246, __pyx_L3_error)
    __pyx_v_cpu = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_cpu == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 246, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("test2d", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 246, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_K, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_E, 1);
  __Pyx_AddTraceback("libfds.cutils.test2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6libfds_6cutils_10test2d(__pyx_self, __pyx_v_K, __pyx_v_E, __pyx_v_odx, __pyx_v_cpu);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_K, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_E, 1);
  {
    Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
      __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
    }
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_6libfds_6cutils_10test2d(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_K, __Pyx_memviewslice __pyx_v_E, double __pyx_v_odx, int __pyx_v_cpu) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__17)
  __Pyx_TraceCall("test2d (wrapper)", __pyx_f[0], 246, 0, __PYX_ERR(0, 246, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6libfds_6cutils_test2d(__pyx_v_K, __pyx_v_E, __pyx_v_odx, __pyx_v_cpu, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libfds.cutils.test2d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __Pyx_TraceLine(246,0,__PYX_ERR(0, 246, __pyx_L1_error))

  __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_6libfds_6cutils_11test2d, 0, __pyx_n_s_test2d, NULL, __pyx_n_s_libfds_cutils, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test2d, __pyx_t_7) < 0) __PYX_ERR(0, 246, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 247: 
 248:     cdef Py_ssize_t ix, iy
+249:     cdef int nx = K.shape[0]
  __Pyx_TraceLine(249,1,__PYX_ERR(0, 249, __pyx_L1_error))
  __pyx_v_nx = (__pyx_v_K.shape[0]);
+250:     cdef int ny = K.shape[1]
  __Pyx_TraceLine(250,1,__PYX_ERR(0, 250, __pyx_L1_error))
  __pyx_v_ny = (__pyx_v_K.shape[1]);
 251: 
+252:     if cpu == 1:
  __Pyx_TraceLine(252,1,__PYX_ERR(0, 252, __pyx_L1_error))
  __pyx_t_1 = (__pyx_v_cpu == 1);
  if (__pyx_t_1) {
/* … */
    goto __pyx_L3;
  }
+253:         for ix in range(5, nx - 5):
    __Pyx_TraceLine(253,1,__PYX_ERR(0, 253, __pyx_L1_error))
    __pyx_t_2 = (__pyx_v_nx - 5);
    __pyx_t_3 = __pyx_t_2;
    for (__pyx_t_4 = 5; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_ix = __pyx_t_4;
+254:             for iy in range(5, ny - 5):
      __Pyx_TraceLine(254,1,__PYX_ERR(0, 254, __pyx_L1_error))
      __pyx_t_5 = (__pyx_v_ny - 5);
      __pyx_t_6 = __pyx_t_5;
      for (__pyx_t_7 = 5; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
        __pyx_v_iy = __pyx_t_7;
+255:                 K[ix, iy] = (a11c[1]*(E[ix+1, iy+1] - E[ix-1, iy-1]) +
        __Pyx_TraceLine(255,1,__PYX_ERR(0, 255, __pyx_L1_error))
        __pyx_t_8 = (__pyx_v_ix + 1);
        __pyx_t_9 = (__pyx_v_iy + 1);
        __pyx_t_10 = (__pyx_v_ix - 1);
        __pyx_t_11 = (__pyx_v_iy - 1);
/* … */
        __Pyx_TraceLine(255,1,__PYX_ERR(0, 255, __pyx_L1_error))
        __pyx_t_28 = __pyx_v_ix;
        __pyx_t_29 = __pyx_v_iy;
        *((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_K.data + __pyx_t_28 * __pyx_v_K.strides[0]) )) + __pyx_t_29)) )) = (((((((a11c[1]) * ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_8 * __pyx_v_E.strides[0]) )) + __pyx_t_9)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_10 * __pyx_v_E.strides[0]) )) + __pyx_t_11)) ))))) + ((a11c[2]) * ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_12 * __pyx_v_E.strides[0]) )) + __pyx_t_13)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_14 * __pyx_v_E.strides[0]) )) + __pyx_t_15)) )))))) + ((a11c[3]) * ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_16 * __pyx_v_E.strides[0]) )) + __pyx_t_17)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_18 * __pyx_v_E.strides[0]) )) + __pyx_t_19)) )))))) + ((a11c[4]) * ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_20 * __pyx_v_E.strides[0]) )) + __pyx_t_21)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_22 * __pyx_v_E.strides[0]) )) + __pyx_t_23)) )))))) + ((a11c[5]) * ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_24 * __pyx_v_E.strides[0]) )) + __pyx_t_25)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_26 * __pyx_v_E.strides[0]) )) + __pyx_t_27)) )))))) * __pyx_v_odx);
      }
    }
+256:                             a11c[2]*(E[ix+2, iy+2] - E[ix-2, iy-2]) +
        __Pyx_TraceLine(256,1,__PYX_ERR(0, 256, __pyx_L1_error))
        __pyx_t_12 = (__pyx_v_ix + 2);
        __pyx_t_13 = (__pyx_v_iy + 2);
        __pyx_t_14 = (__pyx_v_ix - 2);
        __pyx_t_15 = (__pyx_v_iy - 2);
+257:                             a11c[3]*(E[ix+3, iy+3] - E[ix-3, iy-3]) +
        __Pyx_TraceLine(257,1,__PYX_ERR(0, 257, __pyx_L1_error))
        __pyx_t_16 = (__pyx_v_ix + 3);
        __pyx_t_17 = (__pyx_v_iy + 3);
        __pyx_t_18 = (__pyx_v_ix - 3);
        __pyx_t_19 = (__pyx_v_iy - 3);
+258:                             a11c[4]*(E[ix+4, iy+4] - E[ix-4, iy-4]) +
        __Pyx_TraceLine(258,1,__PYX_ERR(0, 258, __pyx_L1_error))
        __pyx_t_20 = (__pyx_v_ix + 4);
        __pyx_t_21 = (__pyx_v_iy + 4);
        __pyx_t_22 = (__pyx_v_ix - 4);
        __pyx_t_23 = (__pyx_v_iy - 4);
+259:                             a11c[5]*(E[ix+5, iy+5] - E[ix-5, iy-5]))*odx
        __Pyx_TraceLine(259,1,__PYX_ERR(0, 259, __pyx_L1_error))
        __pyx_t_24 = (__pyx_v_ix + 5);
        __pyx_t_25 = (__pyx_v_iy + 5);
        __pyx_t_26 = (__pyx_v_ix - 5);
        __pyx_t_27 = (__pyx_v_iy - 5);
 260:     else:
+261:         for ix in prange(5, nx - 5, nogil=True, num_threads=cpu):
  __Pyx_TraceLine(261,1,__PYX_ERR(0, 261, __pyx_L1_error))
  /*else*/ {
    {
        #ifdef WITH_THREAD
        PyThreadState *_save;
        _save = NULL;
        if (PyGILState_Check()) {
          Py_UNBLOCK_THREADS
        }
        __Pyx_FastGIL_Remember();
        #endif
        /*try:*/ {
          __pyx_t_2 = (__pyx_v_nx - 5);
          {
              #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                  #undef likely
                  #undef unlikely
                  #define likely(x)   (x)
                  #define unlikely(x) (x)
              #endif
              __pyx_t_7 = (__pyx_t_2 - 5 + 1 - 1/abs(1)) / 1;
              if (__pyx_t_7 > 0)
              {
                  #ifdef _OPENMP
                  #pragma omp parallel
                  #endif /* _OPENMP */
                  {
                      #ifdef _OPENMP
                      #pragma omp for firstprivate(__pyx_v_ix) lastprivate(__pyx_v_ix) lastprivate(__pyx_v_iy)          __pyx_t_2 = (__pyx_v_nx - 5);
          {
              #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                  #undef likely
                  #undef unlikely
                  #define likely(x)   (x)
                  #define unlikely(x) (x)
              #endif
              __pyx_t_7 = (__pyx_t_2 - 5 + 1 - 1/abs(1)) / 1;
              if (__pyx_t_7 > 0)
              {
                  #ifdef _OPENMP
                  #pragma omp parallel
                  #endif /* _OPENMP */
                  {
                      #ifdef _OPENMP
                      #pragma omp for firstprivate(__pyx_v_ix) lastprivate(__pyx_v_ix) lastprivate(__pyx_v_iy) num_threads(__pyx_v_cpu)
                      #endif /* _OPENMP */
                      for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_7; __pyx_t_4++){
                          {
                              __pyx_v_ix = (Py_ssize_t)(5 + 1 * __pyx_t_4);
                              /* Initialize private variables to invalid values */
                              __pyx_v_iy = ((Py_ssize_t)0xbad0bad0);
/* … */
        __Pyx_TraceLine(261,1,__PYX_ERR(0, 261, __pyx_L9_error))
        /*finally:*/ {
          /*normal exit:*/{
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            if (_save) {
              Py_BLOCK_THREADS
            }
            #endif
            goto __pyx_L10;
          }
          __pyx_L9_error: {
            #ifdef WITH_THREAD
            __Pyx_FastGIL_Forget();
            if (_save) {
              Py_BLOCK_THREADS
            }
            #endif
            goto __pyx_L1_error;
          }
          __pyx_L10:;
        }
    }
  }
  __pyx_L3:;
+262:             for iy in range(5, ny - 5):
                              __Pyx_TraceLine(262,1,__PYX_ERR(0, 262, __pyx_L13_error))
                              __pyx_t_3 = (__pyx_v_ny - 5);
                              __pyx_t_5 = __pyx_t_3;
                              for (__pyx_t_30 = 5; __pyx_t_30 < __pyx_t_5; __pyx_t_30+=1) {
                                __pyx_v_iy = __pyx_t_30;
+263:                 K[ix, iy] = (a11c[1]*(E[ix+1, iy+1] - E[ix-1, iy-1]) +
                                __Pyx_TraceLine(263,1,__PYX_ERR(0, 263, __pyx_L13_error))
                                __pyx_t_27 = (__pyx_v_ix + 1);
                                __pyx_t_26 = (__pyx_v_iy + 1);
                                __pyx_t_25 = (__pyx_v_ix - 1);
                                __pyx_t_24 = (__pyx_v_iy - 1);
/* … */
                                __Pyx_TraceLine(263,1,__PYX_ERR(0, 263, __pyx_L13_error))
                                __pyx_t_29 = __pyx_v_ix;
                                __pyx_t_28 = __pyx_v_iy;
                                *((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_K.data + __pyx_t_29 * __pyx_v_K.strides[0]) )) + __pyx_t_28)) )) = (((((((a11c[1]) * ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_27 * __pyx_v_E.strides[0]) )) + __pyx_t_26)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_25 * __pyx_v_E.strides[0]) )) + __pyx_t_24)) ))))) + ((a11c[2]) * ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_23 * __pyx_v_E.strides[0]) )) + __pyx_t_22)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_21 * __pyx_v_E.strides[0]) )) + __pyx_t_20)) )))))) + ((a11c[3]) * ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_19 * __pyx_v_E.strides[0]) )) + __pyx_t_18)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_17 * __pyx_v_E.strides[0]) )) + __pyx_t_16)) )))))) + ((a11c[4]) * ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_15 * __pyx_v_E.strides[0]) )) + __pyx_t_14)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_13 * __pyx_v_E.strides[0]) )) + __pyx_t_12)) )))))) + ((a11c[5]) * ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_11 * __pyx_v_E.strides[0]) )) + __pyx_t_10)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_E.data + __pyx_t_9 * __pyx_v_E.strides[0]) )) + __pyx_t_8)) )))))) * __pyx_v_odx);
                              }
                              goto __pyx_L18;
                              __pyx_L13_error:;
                              {
                                  #ifdef WITH_THREAD
                                  PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                                  #endif
                                  #ifdef _OPENMP
                                  #pragma omp flush(__pyx_parallel_exc_type)
                                  #endif /* _OPENMP */
                                  if (!__pyx_parallel_exc_type) {
                                    __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb);
                                    __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno;
                                    __Pyx_GOTREF(__pyx_parallel_exc_type);
                                  }
                                  #ifdef WITH_THREAD
                                  __Pyx_PyGILState_Release(__pyx_gilstate_save);
                                  #endif
                              }
                              __pyx_parallel_why = 4;
                              goto __pyx_L17;
                              __pyx_L17:;
                              #ifdef _OPENMP
                              #pragma omp critical(__pyx_parallel_lastprivates7)
                              #endif /* _OPENMP */
                              {
                                  __pyx_parallel_temp0 = __pyx_v_ix;
                                  __pyx_parallel_temp1 = __pyx_v_iy;
                              }
                              __pyx_L18:;
                              #ifdef _OPENMP
                              #pragma omp flush(__pyx_parallel_why)
                              #endif /* _OPENMP */
                          }
                      }
                      #ifdef _OPENMP
                      Py_END_ALLOW_THREADS
                      #else
{
#ifdef WITH_THREAD
                      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                      #endif
                      #endif /* _OPENMP */
                      /* Clean up any temporaries */
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                      #ifndef _OPENMP
}
#endif /* _OPENMP */
                  }
              }
              if (__pyx_parallel_exc_type) {
                /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */
                __pyx_parallel_why = 4;
              }
              if (__pyx_parallel_why) {
                __pyx_v_ix = __pyx_parallel_temp0;
                __pyx_v_iy = __pyx_parallel_temp1;
                switch (__pyx_parallel_why) {
                      case 4:
                  {
                      #ifdef WITH_THREAD
                      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
                      #endif
                      __Pyx_GIVEREF(__pyx_parallel_exc_type);
                      __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb);
                      __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno;
                      #ifdef WITH_THREAD
                      __Pyx_PyGILState_Release(__pyx_gilstate_save);
                      #endif
                  }
                  goto __pyx_L9_error;
                }
              }
          }
          #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
              #undef likely
              #undef unlikely
              #define likely(x)   __builtin_expect(!!(x), 1)
              #define unlikely(x) __builtin_expect(!!(x), 0)
          #endif
        }
+264:                             a11c[2]*(E[ix+2, iy+2] - E[ix-2, iy-2]) +
                                __Pyx_TraceLine(264,1,__PYX_ERR(0, 264, __pyx_L13_error))
                                __pyx_t_23 = (__pyx_v_ix + 2);
                                __pyx_t_22 = (__pyx_v_iy + 2);
                                __pyx_t_21 = (__pyx_v_ix - 2);
                                __pyx_t_20 = (__pyx_v_iy - 2);
+265:                             a11c[3]*(E[ix+3, iy+3] - E[ix-3, iy-3]) +
                                __Pyx_TraceLine(265,1,__PYX_ERR(0, 265, __pyx_L13_error))
                                __pyx_t_19 = (__pyx_v_ix + 3);
                                __pyx_t_18 = (__pyx_v_iy + 3);
                                __pyx_t_17 = (__pyx_v_ix - 3);
                                __pyx_t_16 = (__pyx_v_iy - 3);
+266:                             a11c[4]*(E[ix+4, iy+4] - E[ix-4, iy-4]) +
                                __Pyx_TraceLine(266,1,__PYX_ERR(0, 266, __pyx_L13_error))
                                __pyx_t_15 = (__pyx_v_ix + 4);
                                __pyx_t_14 = (__pyx_v_iy + 4);
                                __pyx_t_13 = (__pyx_v_ix - 4);
                                __pyx_t_12 = (__pyx_v_iy - 4);
+267:                             a11c[5]*(E[ix+5, iy+5] - E[ix-5, iy-5]))*odx
                                __Pyx_TraceLine(267,1,__PYX_ERR(0, 267, __pyx_L13_error))
                                __pyx_t_11 = (__pyx_v_ix + 5);
                                __pyx_t_10 = (__pyx_v_iy + 5);
                                __pyx_t_9 = (__pyx_v_ix - 5);
                                __pyx_t_8 = (__pyx_v_iy - 5);