Generated by Cython 3.2.8

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: inner_loops.c

+001: ## ...........................................................................
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_4) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 002: ##
 003: ## PIMMS (Polymer Interactions in Multicomponent Mixtures)
 004: ## Author: Alex Holehouse
 005: ## Developed by the Holehouse and Pappu labs
 006: ## Copyright 2015 - 2026
 007: ##
 008: ## ...........................................................................
 009: 
+010: import numpy as np
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_numpy, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
  __pyx_t_4 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_np, __pyx_t_4) < (0)) __PYX_ERR(0, 10, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 011: cimport numpy as cnp
+012: cnp.import_array()
  __pyx_t_9 = __pyx_f_5numpy_import_array(); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 12, __pyx_L1_error)
 013: cimport cython
 014: 
 015: from cython.view cimport array
 016: 
+017: from pimms.latticeExceptions import InnerLoopException
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_InnerLoopException};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_pimms_latticeExceptions, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_InnerLoopException};
    __pyx_t_10 = 0; {
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_10]); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 17, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_10], __pyx_t_5) < (0)) __PYX_ERR(0, 17, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 018: 
+019: cdef inline int int_max(int a, int b): return a if a >= b else b
static CYTHON_INLINE int __pyx_f_5pimms_11inner_loops_int_max(int __pyx_v_a, int __pyx_v_b) {
  int __pyx_r;
  __pyx_t_2 = (__pyx_v_a >= __pyx_v_b);
  if (__pyx_t_2) {
    __pyx_t_1 = __pyx_v_a;
  } else {
    __pyx_t_1 = __pyx_v_b;
  }
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}
+020: cdef inline int int_min(int a, int b): return a if a <= b else b
static CYTHON_INLINE int __pyx_f_5pimms_11inner_loops_int_min(int __pyx_v_a, int __pyx_v_b) {
  int __pyx_r;
  __pyx_t_2 = (__pyx_v_a <= __pyx_v_b);
  if (__pyx_t_2) {
    __pyx_t_1 = __pyx_v_a;
  } else {
    __pyx_t_1 = __pyx_v_b;
  }
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}
 021: 
 022: from pimms.cython_config cimport NUMPY_INT_TYPE
+023: from pimms.CONFIG import NP_INT_TYPE as NUMPY_INT_TYPE_PYTHON
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_NP_INT_TYPE};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_pimms_CONFIG, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_NP_INT_TYPE};
    __pyx_t_10 = 0; {
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_10]); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 23, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      switch (__pyx_t_10) {
        case 0:
        if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON, __pyx_t_5) < (0)) __PYX_ERR(0, 23, __pyx_L1_error)
        break;
        default:;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 024: 
 025: #from numpy cimport int16_t as NUMPY_INT16_TYPE
 026: #ctypedef NUMPY_INT16_TYPE  NUMPY_INT_TYPE
 027: 
 028: ## inner_loops contains functions for geting positions and bead information in
 029: ## the local 2D or 3D environment
 030: ##
 031: ##
 032: ##
 033: 
 034: 
 035: 
 036: ##
 037: #################################################################################################
 038: ##
 039: 
 040: 
+041: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_11inner_loops_1extract_SR_and_LR_pairs_from_position_3D(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*/
PyDoc_STRVAR(__pyx_doc_5pimms_11inner_loops_extract_SR_and_LR_pairs_from_position_3D, "\n    Function that takes a single position ($position) and the type_grid and determines\n    the set of pairwise interactions between that central position and the positions\n    around it. \n\n    The pairs are inherently numbered (i.e. [A-B] would be A then B). To determine which\n    of the two positions is first in the pair we use the numerical value of the x/y/z \n    positions\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_11inner_loops_1extract_SR_and_LR_pairs_from_position_3D = {"extract_SR_and_LR_pairs_from_position_3D", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_11inner_loops_1extract_SR_and_LR_pairs_from_position_3D, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_11inner_loops_extract_SR_and_LR_pairs_from_position_3D};
static PyObject *__pyx_pw_5pimms_11inner_loops_1extract_SR_and_LR_pairs_from_position_3D(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_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_LR_position;
  __Pyx_memviewslice __pyx_v_type_grid = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_XDIM;
  int __pyx_v_YDIM;
  int __pyx_v_ZDIM;
  #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("extract_SR_and_LR_pairs_from_position_3D (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __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 ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_LR_position,&__pyx_mstate_global->__pyx_n_u_type_grid,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,&__pyx_mstate_global->__pyx_n_u_ZDIM,0};
  PyObject* values[6] = {0,0,0,0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 41, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  6:
        values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 41, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 41, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 41, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 41, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 41, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 41, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_SR_and_LR_pairs_from_position_3D", 0) < (0)) __PYX_ERR(0, 41, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 6; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_SR_and_LR_pairs_from_position_3D", 1, 6, 6, i); __PYX_ERR(0, 41, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 6)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 41, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 41, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 41, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 41, __pyx_L3_error)
      values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 41, __pyx_L3_error)
      values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 41, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 43, __pyx_L3_error)
    __pyx_v_LR_position = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_LR_position == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L3_error)
    __pyx_v_type_grid = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_type_grid.memview)) __PYX_ERR(0, 45, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_XDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_int(values[4]); if (unlikely((__pyx_v_YDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 47, __pyx_L3_error)
    __pyx_v_ZDIM = __Pyx_PyLong_As_int(values[5]); if (unlikely((__pyx_v_ZDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 48, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_SR_and_LR_pairs_from_position_3D", 1, 6, 6, __pyx_nargs); __PYX_ERR(0, 41, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_AddTraceback("pimms.inner_loops.extract_SR_and_LR_pairs_from_position_3D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_11inner_loops_extract_SR_and_LR_pairs_from_position_3D(__pyx_self, __pyx_v_position, __pyx_v_LR_position, __pyx_v_type_grid, __pyx_v_XDIM, __pyx_v_YDIM, __pyx_v_ZDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

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

static PyObject *__pyx_pf_5pimms_11inner_loops_extract_SR_and_LR_pairs_from_position_3D(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, int __pyx_v_LR_position, __Pyx_memviewslice __pyx_v_type_grid, int __pyx_v_XDIM, int __pyx_v_YDIM, int __pyx_v_ZDIM) {
  int __pyx_v_SLR_index;
  int __pyx_v_SR_index;
  int __pyx_v_LR_index;
  int __pyx_v_x_off;
  int __pyx_v_y_off;
  int __pyx_v_z_off;
  int __pyx_v_x_p;
  int __pyx_v_y_p;
  int __pyx_v_z_p;
  PyArrayObject *__pyx_v_SR_pairs = 0;
  PyArrayObject *__pyx_v_LR_pairs = 0;
  PyArrayObject *__pyx_v_SLR_pairs = 0;
  int __pyx_v_x;
  int __pyx_v_y;
  int __pyx_v_z;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_LR_pairs;
  __Pyx_Buffer __pyx_pybuffer_LR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SLR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SLR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_SR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SR_pairs.refcount = 0;
  __pyx_pybuffernd_SR_pairs.data = NULL;
  __pyx_pybuffernd_SR_pairs.rcbuffer = &__pyx_pybuffer_SR_pairs;
  __pyx_pybuffer_LR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_LR_pairs.refcount = 0;
  __pyx_pybuffernd_LR_pairs.data = NULL;
  __pyx_pybuffernd_LR_pairs.rcbuffer = &__pyx_pybuffer_LR_pairs;
  __pyx_pybuffer_SLR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SLR_pairs.refcount = 0;
  __pyx_pybuffernd_SLR_pairs.data = NULL;
  __pyx_pybuffernd_SLR_pairs.rcbuffer = &__pyx_pybuffer_SLR_pairs;
/* … */
  /* 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_6);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops.extract_SR_and_LR_pairs_from_position_3D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_SR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_LR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_SLR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_11inner_loops_1extract_SR_and_LR_pairs_from_position_3D, 0, __pyx_mstate_global->__pyx_n_u_extract_SR_and_LR_pairs_from_pos, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_SR_and_LR_pairs_from_pos, __pyx_t_4) < (0)) __PYX_ERR(0, 41, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 042: @cython.wraparound(False)
 043: def extract_SR_and_LR_pairs_from_position_3D(NUMPY_INT_TYPE[:] position,
 044:                                              int LR_position,
 045:                                              NUMPY_INT_TYPE[:,:,:] type_grid,
 046:                                              int XDIM,
 047:                                              int YDIM,
 048:                                              int ZDIM):
 049:     """
 050:     Function that takes a single position ($position) and the type_grid and determines
 051:     the set of pairwise interactions between that central position and the positions
 052:     around it.
 053: 
 054:     The pairs are inherently numbered (i.e. [A-B] would be A then B). To determine which
 055:     of the two positions is first in the pair we use the numerical value of the x/y/z
 056:     positions
 057: 
 058:     """
 059: 
 060:     # declare some variables
 061:     cdef int SLR_index, SR_index, LR_index, x_off, y_off, z_off
 062:     cdef int x_p, y_p, z_p
 063:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SR_pairs
 064:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] LR_pairs
 065:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SLR_pairs
 066: 
 067: 
 068:     # initialize
 069:     # 3x3x3 neighborhood minus the central self-pair = 26 pairs
+070:     SR_pairs = np.zeros((26,2,3), dtype=NUMPY_INT_TYPE_PYTHON)
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_mstate_global->__pyx_tuple[1]};
    __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 70, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_6, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 70, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 70, __pyx_L1_error)
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_SR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
      __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0;
    }
    __pyx_pybuffernd_SR_pairs.diminfo[0].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SR_pairs.diminfo[0].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SR_pairs.diminfo[1].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SR_pairs.diminfo[1].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SR_pairs.diminfo[2].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SR_pairs.diminfo[2].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[2];
    if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 70, __pyx_L1_error)
  }
  __pyx_v_SR_pairs = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
/* … */
  __pyx_mstate_global->__pyx_tuple[1] = PyTuple_Pack(3, __pyx_mstate_global->__pyx_int_26, __pyx_mstate_global->__pyx_int_2, __pyx_mstate_global->__pyx_int_3); if (unlikely(!__pyx_mstate_global->__pyx_tuple[1])) __PYX_ERR(0, 70, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[1]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[1]);
 071: 
 072: 
 073:     # first set the central x, y and z positions
+074:     cdef int x = position[0]
  __pyx_t_11 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_11 * __pyx_v_position.strides[0]) )));
+075:     cdef int y = position[1]
  __pyx_t_11 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_11 * __pyx_v_position.strides[0]) )));
+076:     cdef int z = position[2]
  __pyx_t_11 = 2;
  __pyx_v_z = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_11 * __pyx_v_position.strides[0]) )));
 077: 
 078:     # short range only
+079:     if LR_position == 0:
  switch (__pyx_v_LR_position) {
    case 0:
/* … */
    break;
    case 1:
 080: 
+081:         SR_index = 0
    __pyx_v_SR_index = 0;
+082:         for x_off in xrange(-1,2):
    for (__pyx_t_7 = -1; __pyx_t_7 < 2; __pyx_t_7+=1) {
      __pyx_v_x_off = __pyx_t_7;
+083:             for y_off in xrange(-1,2):
      for (__pyx_t_12 = -1; __pyx_t_12 < 2; __pyx_t_12+=1) {
        __pyx_v_y_off = __pyx_t_12;
+084:                 for z_off in xrange(-1,2):
        for (__pyx_t_13 = -1; __pyx_t_13 < 2; __pyx_t_13+=1) {
          __pyx_v_z_off = __pyx_t_13;
+085:                     if x_off == 0 and y_off == 0 and z_off == 0:
          __pyx_t_15 = (__pyx_v_x_off == 0);
          if (__pyx_t_15) {
          } else {
            __pyx_t_14 = __pyx_t_15;
            goto __pyx_L10_bool_binop_done;
          }
          __pyx_t_15 = (__pyx_v_y_off == 0);
          if (__pyx_t_15) {
          } else {
            __pyx_t_14 = __pyx_t_15;
            goto __pyx_L10_bool_binop_done;
          }
          __pyx_t_15 = (__pyx_v_z_off == 0);
          __pyx_t_14 = __pyx_t_15;
          __pyx_L10_bool_binop_done:;
          if (__pyx_t_14) {
/* … */
          }
+086:                         continue
            goto __pyx_L7_continue;
 087: 
+088:                     x_p = pbc_correction(x + x_off, XDIM)
          __pyx_t_16 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_16 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L1_error)
          __pyx_v_x_p = __pyx_t_16;
+089:                     y_p = pbc_correction(y + y_off, YDIM)
          __pyx_t_16 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_16 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 89, __pyx_L1_error)
          __pyx_v_y_p = __pyx_t_16;
+090:                     z_p = pbc_correction(z + z_off, ZDIM)
          __pyx_t_16 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_z + __pyx_v_z_off), __pyx_v_ZDIM); if (unlikely(__pyx_t_16 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 90, __pyx_L1_error)
          __pyx_v_z_p = __pyx_t_16;
 091: 
 092:                     # if x_off > 0 then the non-central position must come first in the pair
+093:                     if x_off > 0:
          __pyx_t_14 = (__pyx_v_x_off > 0);
          if (__pyx_t_14) {
/* … */
            goto __pyx_L13;
          }
+094:                         SR_pairs[SR_index, 1, 0] = x
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_18 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+095:                         SR_pairs[SR_index, 1, 1] = y
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_11 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+096:                         SR_pairs[SR_index, 1, 2] = z
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_18 = 2;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 097: 
+098:                         SR_pairs[SR_index, 0, 0] = x_p
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_11 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+099:                         SR_pairs[SR_index, 0, 1] = y_p
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_18 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+100:                         SR_pairs[SR_index, 0, 2] = z_p
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_11 = 2;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 101: 
 102: 
 103:                     # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+104:                     elif x_off == 0 and y_off > 0:
          __pyx_t_15 = (__pyx_v_x_off == 0);
          if (__pyx_t_15) {
          } else {
            __pyx_t_14 = __pyx_t_15;
            goto __pyx_L14_bool_binop_done;
          }
          __pyx_t_15 = (__pyx_v_y_off > 0);
          __pyx_t_14 = __pyx_t_15;
          __pyx_L14_bool_binop_done:;
          if (__pyx_t_14) {
/* … */
            goto __pyx_L13;
          }
+105:                         SR_pairs[SR_index, 1, 0] = x
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_18 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+106:                         SR_pairs[SR_index, 1, 1] = y
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_11 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+107:                         SR_pairs[SR_index, 1, 2] = z
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_18 = 2;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 108: 
+109:                         SR_pairs[SR_index, 0, 0] = x_p
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_11 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+110:                         SR_pairs[SR_index, 0, 1] = y_p
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_18 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+111:                         SR_pairs[SR_index, 0, 2] = z_p
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_11 = 2;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 112: 
 113:                     # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+114:                     elif x_off == 0 and y_off == 0 and z_off > 0:
          __pyx_t_15 = (__pyx_v_x_off == 0);
          if (__pyx_t_15) {
          } else {
            __pyx_t_14 = __pyx_t_15;
            goto __pyx_L16_bool_binop_done;
          }
          __pyx_t_15 = (__pyx_v_y_off == 0);
          if (__pyx_t_15) {
          } else {
            __pyx_t_14 = __pyx_t_15;
            goto __pyx_L16_bool_binop_done;
          }
          __pyx_t_15 = (__pyx_v_z_off > 0);
          __pyx_t_14 = __pyx_t_15;
          __pyx_L16_bool_binop_done:;
          if (__pyx_t_14) {
/* … */
            goto __pyx_L13;
          }
+115:                         SR_pairs[SR_index, 1, 0] = x
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_18 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+116:                         SR_pairs[SR_index, 1, 1] = y
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_11 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+117:                         SR_pairs[SR_index, 1, 2] = z
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_18 = 2;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 118: 
+119:                         SR_pairs[SR_index, 0, 0] = x_p
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_11 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+120:                         SR_pairs[SR_index, 0, 1] = y_p
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_18 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+121:                         SR_pairs[SR_index, 0, 2] = z_p
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_11 = 2;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 122: 
 123:                     else:
+124:                         SR_pairs[SR_index, 0, 0] = x
          /*else*/ {
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_18 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+125:                         SR_pairs[SR_index, 0, 1] = y
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_11 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+126:                         SR_pairs[SR_index, 0, 2] = z
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 0;
            __pyx_t_18 = 2;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 127: 
+128:                         SR_pairs[SR_index, 1, 0] = x_p
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_11 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+129:                         SR_pairs[SR_index, 1, 1] = y_p
            __pyx_t_11 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_18 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+130:                         SR_pairs[SR_index, 1, 2] = z_p
            __pyx_t_18 = __pyx_v_SR_index;
            __pyx_t_17 = 1;
            __pyx_t_11 = 2;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
          }
          __pyx_L13:;
 131: 
+132:                     SR_index = SR_index+1
          __pyx_v_SR_index = (__pyx_v_SR_index + 1);
          __pyx_L7_continue:;
        }
      }
    }
 133: 
 134: 
+135:         return (SR_pairs, np.array([], dtype=NUMPY_INT_TYPE_PYTHON), np.array([], dtype=NUMPY_INT_TYPE_PYTHON))
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_t_6};
      __pyx_t_19 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 135, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_2, __pyx_t_19, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 135, __pyx_L1_error)
      __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_19);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_19 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_6);
      assert(__pyx_t_19);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_19);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_19, __pyx_t_2};
      __pyx_t_20 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 135, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_20);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_4, __pyx_t_20, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 135, __pyx_L1_error)
      __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_20);
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 135, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF((PyObject *)__pyx_v_SR_pairs);
    __Pyx_GIVEREF((PyObject *)__pyx_v_SR_pairs);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_SR_pairs)) != (0)) __PYX_ERR(0, 135, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_1);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1) != (0)) __PYX_ERR(0, 135, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_3);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 135, __pyx_L1_error);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
 136: 
+137:     elif LR_position == 1:
    break;
    default:
+138:         LR_pairs  = np.zeros((98, 2, 3), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_20))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_20);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_mstate_global->__pyx_tuple[2]};
      __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_1, __pyx_t_4, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 138, __pyx_L1_error)
      __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 138, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_6), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_LR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
        }
        __pyx_t_10 = __pyx_t_9 = __pyx_t_8 = 0;
      }
      __pyx_pybuffernd_LR_pairs.diminfo[0].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_LR_pairs.diminfo[0].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_LR_pairs.diminfo[1].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_LR_pairs.diminfo[1].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_LR_pairs.diminfo[2].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_LR_pairs.diminfo[2].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 138, __pyx_L1_error)
    }
    __pyx_v_LR_pairs = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
/* … */
  __pyx_mstate_global->__pyx_tuple[2] = PyTuple_Pack(3, __pyx_mstate_global->__pyx_int_98, __pyx_mstate_global->__pyx_int_2, __pyx_mstate_global->__pyx_int_3); if (unlikely(!__pyx_mstate_global->__pyx_tuple[2])) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[2]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[2]);
+139:         SLR_pairs = np.zeros((218, 2, 3), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_20 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_1);
      assert(__pyx_t_20);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_20);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_20, __pyx_mstate_global->__pyx_tuple[3]};
      __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_4, __pyx_t_3, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 139, __pyx_L1_error)
      __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 139, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 139, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_6), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_SLR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        }
        __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0;
      }
      __pyx_pybuffernd_SLR_pairs.diminfo[0].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SLR_pairs.diminfo[0].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SLR_pairs.diminfo[1].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SLR_pairs.diminfo[1].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SLR_pairs.diminfo[2].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SLR_pairs.diminfo[2].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 139, __pyx_L1_error)
    }
    __pyx_v_SLR_pairs = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
/* … */
  __pyx_mstate_global->__pyx_tuple[3] = PyTuple_Pack(3, __pyx_mstate_global->__pyx_int_218, __pyx_mstate_global->__pyx_int_2, __pyx_mstate_global->__pyx_int_3); if (unlikely(!__pyx_mstate_global->__pyx_tuple[3])) __PYX_ERR(0, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[3]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[3]);
 140: 
+141:         SR_index  = 0
    __pyx_v_SR_index = 0;
+142:         LR_index  = 0
    __pyx_v_LR_index = 0;
+143:         SLR_index = 0
    __pyx_v_SLR_index = 0;
 144: 
 145: 
 146:         # loop over long range cube around site
+147:         for x_off in xrange(-3,4):
    for (__pyx_t_7 = -3; __pyx_t_7 < 4; __pyx_t_7+=1) {
      __pyx_v_x_off = __pyx_t_7;
+148:             for y_off in xrange(-3,4):
      for (__pyx_t_12 = -3; __pyx_t_12 < 4; __pyx_t_12+=1) {
        __pyx_v_y_off = __pyx_t_12;
+149:                 for z_off in xrange(-3,4):
        for (__pyx_t_13 = -3; __pyx_t_13 < 4; __pyx_t_13+=1) {
          __pyx_v_z_off = __pyx_t_13;
+150:                     x_p = pbc_correction(x + x_off, XDIM)
          __pyx_t_16 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_16 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 150, __pyx_L1_error)
          __pyx_v_x_p = __pyx_t_16;
+151:                     y_p = pbc_correction(y + y_off, YDIM)
          __pyx_t_16 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_16 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 151, __pyx_L1_error)
          __pyx_v_y_p = __pyx_t_16;
+152:                     z_p = pbc_correction(z + z_off, ZDIM)
          __pyx_t_16 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_z + __pyx_v_z_off), __pyx_v_ZDIM); if (unlikely(__pyx_t_16 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L1_error)
          __pyx_v_z_p = __pyx_t_16;
 153: 
 154:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 155:                     # if short range_interaction
+156:                     if abs(x_off) < 2 and abs(y_off) < 2 and abs(z_off) <2:
          __pyx_t_16 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 156, __pyx_L1_error)
          __pyx_t_15 = (__pyx_t_16 < 2);
          if (__pyx_t_15) {
          } else {
            __pyx_t_14 = __pyx_t_15;
            goto __pyx_L26_bool_binop_done;
          }
          __pyx_t_16 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 156, __pyx_L1_error)
          __pyx_t_15 = (__pyx_t_16 < 2);
          if (__pyx_t_15) {
          } else {
            __pyx_t_14 = __pyx_t_15;
            goto __pyx_L26_bool_binop_done;
          }
          __pyx_t_16 = abs(__pyx_v_z_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 156, __pyx_L1_error)
          __pyx_t_15 = (__pyx_t_16 < 2);
          __pyx_t_14 = __pyx_t_15;
          __pyx_L26_bool_binop_done:;
          if (__pyx_t_14) {
/* … */
            goto __pyx_L25;
          }
+157:                         if x_off == 0 and y_off == 0 and z_off == 0:
            __pyx_t_15 = (__pyx_v_x_off == 0);
            if (__pyx_t_15) {
            } else {
              __pyx_t_14 = __pyx_t_15;
              goto __pyx_L30_bool_binop_done;
            }
            __pyx_t_15 = (__pyx_v_y_off == 0);
            if (__pyx_t_15) {
            } else {
              __pyx_t_14 = __pyx_t_15;
              goto __pyx_L30_bool_binop_done;
            }
            __pyx_t_15 = (__pyx_v_z_off == 0);
            __pyx_t_14 = __pyx_t_15;
            __pyx_L30_bool_binop_done:;
            if (__pyx_t_14) {
/* … */
            }
+158:                             continue
              goto __pyx_L23_continue;
 159: 
 160:                         # if x_off > 0 then the non-central position must come first in the pair
+161:                         if x_off > 0:
            __pyx_t_14 = (__pyx_v_x_off > 0);
            if (__pyx_t_14) {
/* … */
              goto __pyx_L33;
            }
+162:                             SR_pairs[SR_index, 1, 0] = x
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+163:                             SR_pairs[SR_index, 1, 1] = y
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+164:                             SR_pairs[SR_index, 1, 2] = z
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 165: 
+166:                             SR_pairs[SR_index, 0, 0] = x_p
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+167:                             SR_pairs[SR_index, 0, 1] = y_p
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+168:                             SR_pairs[SR_index, 0, 2] = z_p
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 169: 
 170: 
 171:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+172:                         elif x_off == 0 and y_off > 0:
            __pyx_t_15 = (__pyx_v_x_off == 0);
            if (__pyx_t_15) {
            } else {
              __pyx_t_14 = __pyx_t_15;
              goto __pyx_L34_bool_binop_done;
            }
            __pyx_t_15 = (__pyx_v_y_off > 0);
            __pyx_t_14 = __pyx_t_15;
            __pyx_L34_bool_binop_done:;
            if (__pyx_t_14) {
/* … */
              goto __pyx_L33;
            }
+173:                             SR_pairs[SR_index, 1, 0] = x
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+174:                             SR_pairs[SR_index, 1, 1] = y
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+175:                             SR_pairs[SR_index, 1, 2] = z
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 176: 
+177:                             SR_pairs[SR_index, 0, 0] = x_p
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+178:                             SR_pairs[SR_index, 0, 1] = y_p
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+179:                             SR_pairs[SR_index, 0, 2] = z_p
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 180: 
 181:                         # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+182:                         elif x_off == 0 and y_off == 0 and z_off > 0:
            __pyx_t_15 = (__pyx_v_x_off == 0);
            if (__pyx_t_15) {
            } else {
              __pyx_t_14 = __pyx_t_15;
              goto __pyx_L36_bool_binop_done;
            }
            __pyx_t_15 = (__pyx_v_y_off == 0);
            if (__pyx_t_15) {
            } else {
              __pyx_t_14 = __pyx_t_15;
              goto __pyx_L36_bool_binop_done;
            }
            __pyx_t_15 = (__pyx_v_z_off > 0);
            __pyx_t_14 = __pyx_t_15;
            __pyx_L36_bool_binop_done:;
            if (__pyx_t_14) {
/* … */
              goto __pyx_L33;
            }
+183:                             SR_pairs[SR_index, 1, 0] = x
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+184:                             SR_pairs[SR_index, 1, 1] = y
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+185:                             SR_pairs[SR_index, 1, 2] = z
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 186: 
+187:                             SR_pairs[SR_index, 0, 0] = x_p
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+188:                             SR_pairs[SR_index, 0, 1] = y_p
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+189:                             SR_pairs[SR_index, 0, 2] = z_p
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 190: 
 191:                         else:
+192:                             SR_pairs[SR_index, 0, 0] = x
            /*else*/ {
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+193:                             SR_pairs[SR_index, 0, 1] = y
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+194:                             SR_pairs[SR_index, 0, 2] = z
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 195: 
+196:                             SR_pairs[SR_index, 1, 0] = x_p
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+197:                             SR_pairs[SR_index, 1, 1] = y_p
              __pyx_t_11 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+198:                             SR_pairs[SR_index, 1, 2] = z_p
              __pyx_t_18 = __pyx_v_SR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
            }
            __pyx_L33:;
 199: 
+200:                         SR_index = SR_index+1
            __pyx_v_SR_index = (__pyx_v_SR_index + 1);
 201: 
 202:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 203:                     ## Long range interaction
+204:                     elif abs(x_off) < 3 and abs(y_off) < 3 and abs(z_off) < 3:
          __pyx_t_16 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 204, __pyx_L1_error)
          __pyx_t_15 = (__pyx_t_16 < 3);
          if (__pyx_t_15) {
          } else {
            __pyx_t_14 = __pyx_t_15;
            goto __pyx_L39_bool_binop_done;
          }
          __pyx_t_16 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 204, __pyx_L1_error)
          __pyx_t_15 = (__pyx_t_16 < 3);
          if (__pyx_t_15) {
          } else {
            __pyx_t_14 = __pyx_t_15;
            goto __pyx_L39_bool_binop_done;
          }
          __pyx_t_16 = abs(__pyx_v_z_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 204, __pyx_L1_error)
          __pyx_t_15 = (__pyx_t_16 < 3);
          __pyx_t_14 = __pyx_t_15;
          __pyx_L39_bool_binop_done:;
          if (__pyx_t_14) {
/* … */
            goto __pyx_L25;
          }
+205:                         if type_grid[x_p, y_p, z_p] == 0:
            __pyx_t_11 = __pyx_v_x_p;
            __pyx_t_17 = __pyx_v_y_p;
            __pyx_t_18 = __pyx_v_z_p;
            __pyx_t_14 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_11 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_17 * __pyx_v_type_grid.strides[1]) ) + __pyx_t_18 * __pyx_v_type_grid.strides[2]) ))) == 0);
            if (__pyx_t_14) {
/* … */
            }
+206:                             continue
              goto __pyx_L23_continue;
 207: 
 208:                         # if x_off < 0 then the non-central position must come first in the pair
+209:                         if x_off > 0:
            __pyx_t_14 = (__pyx_v_x_off > 0);
            if (__pyx_t_14) {
/* … */
              goto __pyx_L43;
            }
+210:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+211:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+212:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 213: 
+214:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+215:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+216:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 217: 
 218:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+219:                         elif x_off == 0 and y_off > 0:
            __pyx_t_15 = (__pyx_v_x_off == 0);
            if (__pyx_t_15) {
            } else {
              __pyx_t_14 = __pyx_t_15;
              goto __pyx_L44_bool_binop_done;
            }
            __pyx_t_15 = (__pyx_v_y_off > 0);
            __pyx_t_14 = __pyx_t_15;
            __pyx_L44_bool_binop_done:;
            if (__pyx_t_14) {
/* … */
              goto __pyx_L43;
            }
+220:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+221:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+222:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 223: 
+224:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+225:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+226:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 227: 
 228:                         # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+229:                         elif x_off == 0 and y_off == 0 and z_off > 0:
            __pyx_t_15 = (__pyx_v_x_off == 0);
            if (__pyx_t_15) {
            } else {
              __pyx_t_14 = __pyx_t_15;
              goto __pyx_L46_bool_binop_done;
            }
            __pyx_t_15 = (__pyx_v_y_off == 0);
            if (__pyx_t_15) {
            } else {
              __pyx_t_14 = __pyx_t_15;
              goto __pyx_L46_bool_binop_done;
            }
            __pyx_t_15 = (__pyx_v_z_off > 0);
            __pyx_t_14 = __pyx_t_15;
            __pyx_L46_bool_binop_done:;
            if (__pyx_t_14) {
/* … */
              goto __pyx_L43;
            }
+230:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+231:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+232:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 233: 
+234:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+235:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+236:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 237: 
 238:                         else:
+239:                             LR_pairs[LR_index, 0, 0] = x
            /*else*/ {
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+240:                             LR_pairs[LR_index, 0, 1] = y
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+241:                             LR_pairs[LR_index, 0, 2] = z
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 242: 
+243:                             LR_pairs[LR_index, 1, 0] = x_p
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+244:                             LR_pairs[LR_index, 1, 1] = y_p
              __pyx_t_18 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+245:                             LR_pairs[LR_index, 1, 2] = z_p
              __pyx_t_11 = __pyx_v_LR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
            }
            __pyx_L43:;
 246: 
+247:                         LR_index = LR_index+1
            __pyx_v_LR_index = (__pyx_v_LR_index + 1);
 248: 
 249:                     # SUPER LONG RANGE INTERACTIONS...
 250:                     else:
+251:                         if type_grid[x_p, y_p, z_p] == 0:
          /*else*/ {
            __pyx_t_18 = __pyx_v_x_p;
            __pyx_t_17 = __pyx_v_y_p;
            __pyx_t_11 = __pyx_v_z_p;
            __pyx_t_14 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_18 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_17 * __pyx_v_type_grid.strides[1]) ) + __pyx_t_11 * __pyx_v_type_grid.strides[2]) ))) == 0);
            if (__pyx_t_14) {
/* … */
            }
+252:                             continue
              goto __pyx_L23_continue;
 253: 
 254:                         # if x_off < 0 then the non-central position must come first in the pair
+255:                         if x_off > 0:
            __pyx_t_14 = (__pyx_v_x_off > 0);
            if (__pyx_t_14) {
/* … */
              goto __pyx_L50;
            }
+256:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+257:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+258:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 259: 
+260:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+261:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+262:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 263: 
 264:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+265:                         elif x_off == 0 and y_off > 0:
            __pyx_t_15 = (__pyx_v_x_off == 0);
            if (__pyx_t_15) {
            } else {
              __pyx_t_14 = __pyx_t_15;
              goto __pyx_L51_bool_binop_done;
            }
            __pyx_t_15 = (__pyx_v_y_off > 0);
            __pyx_t_14 = __pyx_t_15;
            __pyx_L51_bool_binop_done:;
            if (__pyx_t_14) {
/* … */
              goto __pyx_L50;
            }
+266:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+267:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+268:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 269: 
+270:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+271:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+272:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 273: 
 274:                         # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+275:                         elif x_off == 0 and y_off == 0 and z_off > 0:
            __pyx_t_15 = (__pyx_v_x_off == 0);
            if (__pyx_t_15) {
            } else {
              __pyx_t_14 = __pyx_t_15;
              goto __pyx_L53_bool_binop_done;
            }
            __pyx_t_15 = (__pyx_v_y_off == 0);
            if (__pyx_t_15) {
            } else {
              __pyx_t_14 = __pyx_t_15;
              goto __pyx_L53_bool_binop_done;
            }
            __pyx_t_15 = (__pyx_v_z_off > 0);
            __pyx_t_14 = __pyx_t_15;
            __pyx_L53_bool_binop_done:;
            if (__pyx_t_14) {
/* … */
              goto __pyx_L50;
            }
+276:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+277:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+278:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 279: 
+280:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+281:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+282:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 283: 
 284:                         else:
+285:                             SLR_pairs[SLR_index, 0, 0] = x
            /*else*/ {
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+286:                             SLR_pairs[SLR_index, 0, 1] = y
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_11 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+287:                             SLR_pairs[SLR_index, 0, 2] = z
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 0;
              __pyx_t_18 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 288: 
+289:                             SLR_pairs[SLR_index, 1, 0] = x_p
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+290:                             SLR_pairs[SLR_index, 1, 1] = y_p
              __pyx_t_11 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_18 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+291:                             SLR_pairs[SLR_index, 1, 2] = z_p
              __pyx_t_18 = __pyx_v_SLR_index;
              __pyx_t_17 = 1;
              __pyx_t_11 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_11, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
            }
            __pyx_L50:;
 292: 
+293:                         SLR_index = SLR_index+1
            __pyx_v_SLR_index = (__pyx_v_SLR_index + 1);
          }
          __pyx_L25:;
          __pyx_L23_continue:;
        }
      }
    }
 294: 
 295: 
+296:         return (SR_pairs[0:SR_index], LR_pairs[0:LR_index], SLR_pairs[0:SLR_index])
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_SR_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_6, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SR_pairs), __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_LR_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_LR_pairs), __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_SLR_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SLR_pairs), __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6) != (0)) __PYX_ERR(0, 296, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_1);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1) != (0)) __PYX_ERR(0, 296, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_3);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 296, __pyx_L1_error);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
 297: 
 298: 
 299: 
 300: 
 301:     else:
+302:         raise InnerLoopException('Invalid LR option passed')
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_InnerLoopException); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Invalid_LR_option_passed};
      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 302, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 302, __pyx_L1_error)
    break;
  }
 303: 
 304: 
+305: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_11inner_loops_3extract_SR_and_LR_pairs_from_position_2D(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*/
PyDoc_STRVAR(__pyx_doc_5pimms_11inner_loops_2extract_SR_and_LR_pairs_from_position_2D, "\n\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_11inner_loops_3extract_SR_and_LR_pairs_from_position_2D = {"extract_SR_and_LR_pairs_from_position_2D", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_11inner_loops_3extract_SR_and_LR_pairs_from_position_2D, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_11inner_loops_2extract_SR_and_LR_pairs_from_position_2D};
static PyObject *__pyx_pw_5pimms_11inner_loops_3extract_SR_and_LR_pairs_from_position_2D(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_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_LR_position;
  __Pyx_memviewslice __pyx_v_type_grid = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_XDIM;
  int __pyx_v_YDIM;
  #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("extract_SR_and_LR_pairs_from_position_2D (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __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 ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_LR_position,&__pyx_mstate_global->__pyx_n_u_type_grid,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,0};
  PyObject* values[5] = {0,0,0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 305, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 305, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 305, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 305, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 305, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 305, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_SR_and_LR_pairs_from_position_2D", 0) < (0)) __PYX_ERR(0, 305, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 5; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_SR_and_LR_pairs_from_position_2D", 1, 5, 5, i); __PYX_ERR(0, 305, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 5)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 305, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 305, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 305, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 305, __pyx_L3_error)
      values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 305, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 307, __pyx_L3_error)
    __pyx_v_LR_position = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_LR_position == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error)
    __pyx_v_type_grid = __Pyx_PyObject_to_MemoryviewSlice_dsds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_type_grid.memview)) __PYX_ERR(0, 309, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_XDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 310, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_int(values[4]); if (unlikely((__pyx_v_YDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 311, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_SR_and_LR_pairs_from_position_2D", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 305, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_AddTraceback("pimms.inner_loops.extract_SR_and_LR_pairs_from_position_2D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_11inner_loops_2extract_SR_and_LR_pairs_from_position_2D(__pyx_self, __pyx_v_position, __pyx_v_LR_position, __pyx_v_type_grid, __pyx_v_XDIM, __pyx_v_YDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

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

static PyObject *__pyx_pf_5pimms_11inner_loops_2extract_SR_and_LR_pairs_from_position_2D(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, int __pyx_v_LR_position, __Pyx_memviewslice __pyx_v_type_grid, int __pyx_v_XDIM, int __pyx_v_YDIM) {
  int __pyx_v_SR_index;
  int __pyx_v_LR_index;
  int __pyx_v_SLR_index;
  int __pyx_v_x_off;
  int __pyx_v_y_off;
  int __pyx_v_x_p;
  int __pyx_v_y_p;
  PyArrayObject *__pyx_v_SR_pairs = 0;
  PyArrayObject *__pyx_v_LR_pairs = 0;
  PyArrayObject *__pyx_v_SLR_pairs = 0;
  int __pyx_v_x;
  int __pyx_v_y;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_LR_pairs;
  __Pyx_Buffer __pyx_pybuffer_LR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SLR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SLR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_SR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SR_pairs.refcount = 0;
  __pyx_pybuffernd_SR_pairs.data = NULL;
  __pyx_pybuffernd_SR_pairs.rcbuffer = &__pyx_pybuffer_SR_pairs;
  __pyx_pybuffer_LR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_LR_pairs.refcount = 0;
  __pyx_pybuffernd_LR_pairs.data = NULL;
  __pyx_pybuffernd_LR_pairs.rcbuffer = &__pyx_pybuffer_LR_pairs;
  __pyx_pybuffer_SLR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SLR_pairs.refcount = 0;
  __pyx_pybuffernd_SLR_pairs.data = NULL;
  __pyx_pybuffernd_SLR_pairs.rcbuffer = &__pyx_pybuffer_SLR_pairs;
/* … */
  /* 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_6);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops.extract_SR_and_LR_pairs_from_position_2D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_SR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_LR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_SLR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_11inner_loops_3extract_SR_and_LR_pairs_from_position_2D, 0, __pyx_mstate_global->__pyx_n_u_extract_SR_and_LR_pairs_from_pos_2, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_SR_and_LR_pairs_from_pos_2, __pyx_t_4) < (0)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 306: @cython.wraparound(False)
 307: def extract_SR_and_LR_pairs_from_position_2D(NUMPY_INT_TYPE[:] position,
 308:                                              int LR_position,
 309:                                              NUMPY_INT_TYPE[:,:] type_grid,
 310:                                              int XDIM,
 311:                                              int YDIM):
 312:     """
 313: 
 314: 
 315:     """
 316: 
 317:     # declare some variables
 318:     cdef int SR_index, LR_index, SLR_index, x_off, y_off
 319:     cdef int x_p, y_p
+320:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SR_pairs = np.zeros((8,2,2), dtype=NUMPY_INT_TYPE_PYTHON)
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_mstate_global->__pyx_tuple[4]};
    __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 320, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_6, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 320, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 320, __pyx_L1_error)
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_SR_pairs = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 320, __pyx_L1_error)
    } else {__pyx_pybuffernd_SR_pairs.diminfo[0].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SR_pairs.diminfo[0].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SR_pairs.diminfo[1].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SR_pairs.diminfo[1].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SR_pairs.diminfo[2].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SR_pairs.diminfo[2].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_v_SR_pairs = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
/* … */
  __pyx_mstate_global->__pyx_tuple[4] = PyTuple_Pack(3, __pyx_mstate_global->__pyx_int_8, __pyx_mstate_global->__pyx_int_2, __pyx_mstate_global->__pyx_int_2); if (unlikely(!__pyx_mstate_global->__pyx_tuple[4])) __PYX_ERR(0, 320, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[4]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[4]);
 321:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] LR_pairs
 322:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SLR_pairs
 323: 
 324:     # first set the central x, y and z positions
+325:     cdef int x = position[0]
  __pyx_t_7 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
+326:     cdef int y = position[1]
  __pyx_t_7 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
 327: 
+328:     SR_index = 0
  __pyx_v_SR_index = 0;
 329:     # short range only
+330:     if LR_position == 0:
  switch (__pyx_v_LR_position) {
    case 0:
/* … */
    break;
    case 1:
 331: 
 332: 
+333:         for x_off in xrange(-1,2):
    for (__pyx_t_8 = -1; __pyx_t_8 < 2; __pyx_t_8+=1) {
      __pyx_v_x_off = __pyx_t_8;
+334:             for y_off in xrange(-1,2):
      for (__pyx_t_9 = -1; __pyx_t_9 < 2; __pyx_t_9+=1) {
        __pyx_v_y_off = __pyx_t_9;
+335:                     if x_off == 0 and y_off == 0:
        __pyx_t_11 = (__pyx_v_x_off == 0);
        if (__pyx_t_11) {
        } else {
          __pyx_t_10 = __pyx_t_11;
          goto __pyx_L8_bool_binop_done;
        }
        __pyx_t_11 = (__pyx_v_y_off == 0);
        __pyx_t_10 = __pyx_t_11;
        __pyx_L8_bool_binop_done:;
        if (__pyx_t_10) {
/* … */
        }
+336:                         continue
          goto __pyx_L5_continue;
 337: 
+338:                     x_p = pbc_correction(x + x_off, XDIM)
        __pyx_t_12 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_12 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 338, __pyx_L1_error)
        __pyx_v_x_p = __pyx_t_12;
+339:                     y_p = pbc_correction(y + y_off, YDIM)
        __pyx_t_12 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_12 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 339, __pyx_L1_error)
        __pyx_v_y_p = __pyx_t_12;
 340: 
 341:                     # if x_off < 0 then the non-central position must come first in the pair
+342:                     if x_off > 0:
        __pyx_t_10 = (__pyx_v_x_off > 0);
        if (__pyx_t_10) {
/* … */
          goto __pyx_L10;
        }
+343:                         SR_pairs[SR_index, 1, 0] = x
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_13 = 1;
          __pyx_t_14 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+344:                         SR_pairs[SR_index, 1, 1] = y
          __pyx_t_14 = __pyx_v_SR_index;
          __pyx_t_13 = 1;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 345: 
+346:                         SR_pairs[SR_index, 0, 0] = x_p
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_13 = 0;
          __pyx_t_14 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+347:                         SR_pairs[SR_index, 0, 1] = y_p
          __pyx_t_14 = __pyx_v_SR_index;
          __pyx_t_13 = 0;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 348: 
 349: 
 350:                     # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+351:                     elif x_off == 0 and y_off > 0:
        __pyx_t_11 = (__pyx_v_x_off == 0);
        if (__pyx_t_11) {
        } else {
          __pyx_t_10 = __pyx_t_11;
          goto __pyx_L11_bool_binop_done;
        }
        __pyx_t_11 = (__pyx_v_y_off > 0);
        __pyx_t_10 = __pyx_t_11;
        __pyx_L11_bool_binop_done:;
        if (__pyx_t_10) {
/* … */
          goto __pyx_L10;
        }
+352:                         SR_pairs[SR_index, 1, 0] = x
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_13 = 1;
          __pyx_t_14 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+353:                         SR_pairs[SR_index, 1, 1] = y
          __pyx_t_14 = __pyx_v_SR_index;
          __pyx_t_13 = 1;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 354: 
+355:                         SR_pairs[SR_index, 0, 0] = x_p
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_13 = 0;
          __pyx_t_14 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+356:                         SR_pairs[SR_index, 0, 1] = y_p
          __pyx_t_14 = __pyx_v_SR_index;
          __pyx_t_13 = 0;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 357: 
 358:                     else:
+359:                         SR_pairs[SR_index, 0, 0] = x
        /*else*/ {
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_13 = 0;
          __pyx_t_14 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+360:                         SR_pairs[SR_index, 0, 1] = y
          __pyx_t_14 = __pyx_v_SR_index;
          __pyx_t_13 = 0;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 361: 
+362:                         SR_pairs[SR_index, 1, 0] = x_p
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_13 = 1;
          __pyx_t_14 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+363:                         SR_pairs[SR_index, 1, 1] = y_p
          __pyx_t_14 = __pyx_v_SR_index;
          __pyx_t_13 = 1;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
        }
        __pyx_L10:;
 364: 
+365:                     SR_index = SR_index+1
        __pyx_v_SR_index = (__pyx_v_SR_index + 1);
        __pyx_L5_continue:;
      }
    }
 366: 
 367:         # return is SR, LR, SLR
+368:         return (SR_pairs, np.array([], dtype=NUMPY_INT_TYPE_PYTHON), np.array([], dtype=NUMPY_INT_TYPE_PYTHON))
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_t_6};
      __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 368, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_2, __pyx_t_15, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 368, __pyx_L1_error)
      __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_15 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
      assert(__pyx_t_15);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_15, __pyx_t_2};
      __pyx_t_16 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 368, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_4, __pyx_t_16, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 368, __pyx_L1_error)
      __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_16);
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 368, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 368, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF((PyObject *)__pyx_v_SR_pairs);
    __Pyx_GIVEREF((PyObject *)__pyx_v_SR_pairs);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_SR_pairs)) != (0)) __PYX_ERR(0, 368, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_1);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1) != (0)) __PYX_ERR(0, 368, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_3);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 368, __pyx_L1_error);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
 369: 
+370:     elif LR_position == 1:
    break;
    default:
 371: 
+372:         LR_pairs = np.zeros((16, 2, 2), dtype=NUMPY_INT_TYPE_PYTHON)  # 5 x 5 -  3 x 3
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 372, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_16))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_16);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_mstate_global->__pyx_tuple[5]};
      __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 372, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_1, __pyx_t_4, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 372, __pyx_L1_error)
      __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 372, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 372, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
      __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_6), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_8 < 0)) {
        PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_LR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
        }
        __pyx_t_17 = __pyx_t_18 = __pyx_t_19 = 0;
      }
      __pyx_pybuffernd_LR_pairs.diminfo[0].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_LR_pairs.diminfo[0].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_LR_pairs.diminfo[1].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_LR_pairs.diminfo[1].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_LR_pairs.diminfo[2].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_LR_pairs.diminfo[2].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 372, __pyx_L1_error)
    }
    __pyx_v_LR_pairs = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
/* … */
  __pyx_mstate_global->__pyx_tuple[5] = PyTuple_Pack(3, __pyx_mstate_global->__pyx_int_16, __pyx_mstate_global->__pyx_int_2, __pyx_mstate_global->__pyx_int_2); if (unlikely(!__pyx_mstate_global->__pyx_tuple[5])) __PYX_ERR(0, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[5]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[5]);
+373:         SLR_pairs = np.zeros((24, 2, 2), dtype=NUMPY_INT_TYPE_PYTHON) # 7 x 7 -  5 x 5
    __pyx_t_16 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 373, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_1);
      assert(__pyx_t_16);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_16, __pyx_mstate_global->__pyx_tuple[6]};
      __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_4, __pyx_t_3, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 373, __pyx_L1_error)
      __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 373, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 373, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
      __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_6), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_8 < 0)) {
        PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_SLR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
        }
        __pyx_t_19 = __pyx_t_18 = __pyx_t_17 = 0;
      }
      __pyx_pybuffernd_SLR_pairs.diminfo[0].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SLR_pairs.diminfo[0].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SLR_pairs.diminfo[1].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SLR_pairs.diminfo[1].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SLR_pairs.diminfo[2].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SLR_pairs.diminfo[2].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 373, __pyx_L1_error)
    }
    __pyx_v_SLR_pairs = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
 374: 
+375:         LR_index = 0
    __pyx_v_LR_index = 0;
+376:         SLR_index = 0
    __pyx_v_SLR_index = 0;
 377: 
 378:         # loop over long range cube around site
+379:         for x_off in xrange(-3,4):
    for (__pyx_t_8 = -3; __pyx_t_8 < 4; __pyx_t_8+=1) {
      __pyx_v_x_off = __pyx_t_8;
+380:             for y_off in xrange(-3,4):
      for (__pyx_t_9 = -3; __pyx_t_9 < 4; __pyx_t_9+=1) {
        __pyx_v_y_off = __pyx_t_9;
+381:                     x_p = pbc_correction(x + x_off, XDIM)
        __pyx_t_12 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_12 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 381, __pyx_L1_error)
        __pyx_v_x_p = __pyx_t_12;
+382:                     y_p = pbc_correction(y + y_off, YDIM)
        __pyx_t_12 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_12 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 382, __pyx_L1_error)
        __pyx_v_y_p = __pyx_t_12;
 383: 
 384:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 385:                     # if short range_interaction
+386:                     if abs(x_off) < 2 and abs(y_off) < 2:
        __pyx_t_12 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 386, __pyx_L1_error)
        __pyx_t_11 = (__pyx_t_12 < 2);
        if (__pyx_t_11) {
        } else {
          __pyx_t_10 = __pyx_t_11;
          goto __pyx_L18_bool_binop_done;
        }
        __pyx_t_12 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 386, __pyx_L1_error)
        __pyx_t_11 = (__pyx_t_12 < 2);
        __pyx_t_10 = __pyx_t_11;
        __pyx_L18_bool_binop_done:;
        if (__pyx_t_10) {
/* … */
          goto __pyx_L17;
        }
+387:                         if x_off == 0 and y_off == 0:
          __pyx_t_11 = (__pyx_v_x_off == 0);
          if (__pyx_t_11) {
          } else {
            __pyx_t_10 = __pyx_t_11;
            goto __pyx_L21_bool_binop_done;
          }
          __pyx_t_11 = (__pyx_v_y_off == 0);
          __pyx_t_10 = __pyx_t_11;
          __pyx_L21_bool_binop_done:;
          if (__pyx_t_10) {
/* … */
          }
+388:                             continue
            goto __pyx_L15_continue;
 389: 
 390:                         # if x_off < 0 then the non-central position must come first in the pair
+391:                         if x_off > 0:
          __pyx_t_10 = (__pyx_v_x_off > 0);
          if (__pyx_t_10) {
/* … */
            goto __pyx_L23;
          }
+392:                             SR_pairs[SR_index, 1, 0] = x
            __pyx_t_7 = __pyx_v_SR_index;
            __pyx_t_13 = 1;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+393:                             SR_pairs[SR_index, 1, 1] = y
            __pyx_t_14 = __pyx_v_SR_index;
            __pyx_t_13 = 1;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 394: 
+395:                             SR_pairs[SR_index, 0, 0] = x_p
            __pyx_t_7 = __pyx_v_SR_index;
            __pyx_t_13 = 0;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+396:                             SR_pairs[SR_index, 0, 1] = y_p
            __pyx_t_14 = __pyx_v_SR_index;
            __pyx_t_13 = 0;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 397: 
 398:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+399:                         elif x_off == 0 and y_off > 0:
          __pyx_t_11 = (__pyx_v_x_off == 0);
          if (__pyx_t_11) {
          } else {
            __pyx_t_10 = __pyx_t_11;
            goto __pyx_L24_bool_binop_done;
          }
          __pyx_t_11 = (__pyx_v_y_off > 0);
          __pyx_t_10 = __pyx_t_11;
          __pyx_L24_bool_binop_done:;
          if (__pyx_t_10) {
/* … */
            goto __pyx_L23;
          }
+400:                             SR_pairs[SR_index, 1, 0] = x
            __pyx_t_7 = __pyx_v_SR_index;
            __pyx_t_13 = 1;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+401:                             SR_pairs[SR_index, 1, 1] = y
            __pyx_t_14 = __pyx_v_SR_index;
            __pyx_t_13 = 1;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 402: 
+403:                             SR_pairs[SR_index, 0, 0] = x_p
            __pyx_t_7 = __pyx_v_SR_index;
            __pyx_t_13 = 0;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+404:                             SR_pairs[SR_index, 0, 1] = y_p
            __pyx_t_14 = __pyx_v_SR_index;
            __pyx_t_13 = 0;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 405: 
 406: 
 407:                         else:
+408:                             SR_pairs[SR_index, 0, 0] = x
          /*else*/ {
            __pyx_t_7 = __pyx_v_SR_index;
            __pyx_t_13 = 0;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+409:                             SR_pairs[SR_index, 0, 1] = y
            __pyx_t_14 = __pyx_v_SR_index;
            __pyx_t_13 = 0;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 410: 
+411:                             SR_pairs[SR_index, 1, 0] = x_p
            __pyx_t_7 = __pyx_v_SR_index;
            __pyx_t_13 = 1;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+412:                             SR_pairs[SR_index, 1, 1] = y_p
            __pyx_t_14 = __pyx_v_SR_index;
            __pyx_t_13 = 1;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
          }
          __pyx_L23:;
 413: 
+414:                         SR_index = SR_index+1
          __pyx_v_SR_index = (__pyx_v_SR_index + 1);
 415: 
 416:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 417:                     ## Long range interaction
+418:                     elif abs(x_off) < 3 and abs(y_off) < 3:
        __pyx_t_12 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 418, __pyx_L1_error)
        __pyx_t_11 = (__pyx_t_12 < 3);
        if (__pyx_t_11) {
        } else {
          __pyx_t_10 = __pyx_t_11;
          goto __pyx_L26_bool_binop_done;
        }
        __pyx_t_12 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 418, __pyx_L1_error)
        __pyx_t_11 = (__pyx_t_12 < 3);
        __pyx_t_10 = __pyx_t_11;
        __pyx_L26_bool_binop_done:;
        if (__pyx_t_10) {
/* … */
          goto __pyx_L17;
        }
+419:                         if type_grid[x_p, y_p] == 0:
          __pyx_t_7 = __pyx_v_x_p;
          __pyx_t_13 = __pyx_v_y_p;
          __pyx_t_10 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_7 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_13 * __pyx_v_type_grid.strides[1]) ))) == 0);
          if (__pyx_t_10) {
/* … */
          }
+420:                             continue
            goto __pyx_L15_continue;
 421: 
 422:                         # if x_off < 0 then the non-central position must come first in the pair
+423:                         if x_off > 0:
          __pyx_t_10 = (__pyx_v_x_off > 0);
          if (__pyx_t_10) {
/* … */
            goto __pyx_L29;
          }
+424:                             LR_pairs[LR_index, 1, 0] = x
            __pyx_t_13 = __pyx_v_LR_index;
            __pyx_t_7 = 1;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+425:                             LR_pairs[LR_index, 1, 1] = y
            __pyx_t_14 = __pyx_v_LR_index;
            __pyx_t_7 = 1;
            __pyx_t_13 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 426: 
+427:                             LR_pairs[LR_index, 0, 0] = x_p
            __pyx_t_13 = __pyx_v_LR_index;
            __pyx_t_7 = 0;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+428:                             LR_pairs[LR_index, 0, 1] = y_p
            __pyx_t_14 = __pyx_v_LR_index;
            __pyx_t_7 = 0;
            __pyx_t_13 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 429: 
 430: 
 431:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+432:                         elif x_off == 0 and y_off > 0:
          __pyx_t_11 = (__pyx_v_x_off == 0);
          if (__pyx_t_11) {
          } else {
            __pyx_t_10 = __pyx_t_11;
            goto __pyx_L30_bool_binop_done;
          }
          __pyx_t_11 = (__pyx_v_y_off > 0);
          __pyx_t_10 = __pyx_t_11;
          __pyx_L30_bool_binop_done:;
          if (__pyx_t_10) {
/* … */
            goto __pyx_L29;
          }
+433:                             LR_pairs[LR_index, 1, 0] = x
            __pyx_t_13 = __pyx_v_LR_index;
            __pyx_t_7 = 1;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+434:                             LR_pairs[LR_index, 1, 1] = y
            __pyx_t_14 = __pyx_v_LR_index;
            __pyx_t_7 = 1;
            __pyx_t_13 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 435: 
+436:                             LR_pairs[LR_index, 0, 0] = x_p
            __pyx_t_13 = __pyx_v_LR_index;
            __pyx_t_7 = 0;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+437:                             LR_pairs[LR_index, 0, 1] = y_p
            __pyx_t_14 = __pyx_v_LR_index;
            __pyx_t_7 = 0;
            __pyx_t_13 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 438: 
 439:                         else:
+440:                             LR_pairs[LR_index, 0, 0] = x
          /*else*/ {
            __pyx_t_13 = __pyx_v_LR_index;
            __pyx_t_7 = 0;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+441:                             LR_pairs[LR_index, 0, 1] = y
            __pyx_t_14 = __pyx_v_LR_index;
            __pyx_t_7 = 0;
            __pyx_t_13 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 442: 
+443:                             LR_pairs[LR_index, 1, 0] = x_p
            __pyx_t_13 = __pyx_v_LR_index;
            __pyx_t_7 = 1;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+444:                             LR_pairs[LR_index, 1, 1] = y_p
            __pyx_t_14 = __pyx_v_LR_index;
            __pyx_t_7 = 1;
            __pyx_t_13 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_7, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_13, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
          }
          __pyx_L29:;
 445: 
+446:                         LR_index = LR_index+1
          __pyx_v_LR_index = (__pyx_v_LR_index + 1);
 447: 
 448:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 449:                     # SUPER LONG RANGE INTERACTIONS...
 450:                     else:
+451:                         if type_grid[x_p, y_p] == 0:
        /*else*/ {
          __pyx_t_13 = __pyx_v_x_p;
          __pyx_t_7 = __pyx_v_y_p;
          __pyx_t_10 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_13 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_7 * __pyx_v_type_grid.strides[1]) ))) == 0);
          if (__pyx_t_10) {
/* … */
          }
+452:                             continue
            goto __pyx_L15_continue;
 453: 
 454:                         # if x_off < 0 then the non-central position must come first in the pair
+455:                         if x_off > 0:
          __pyx_t_10 = (__pyx_v_x_off > 0);
          if (__pyx_t_10) {
/* … */
            goto __pyx_L33;
          }
+456:                             SLR_pairs[SLR_index, 1, 0] = x
            __pyx_t_7 = __pyx_v_SLR_index;
            __pyx_t_13 = 1;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+457:                             SLR_pairs[SLR_index, 1, 1] = y
            __pyx_t_14 = __pyx_v_SLR_index;
            __pyx_t_13 = 1;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 458: 
+459:                             SLR_pairs[SLR_index, 0, 0] = x_p
            __pyx_t_7 = __pyx_v_SLR_index;
            __pyx_t_13 = 0;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+460:                             SLR_pairs[SLR_index, 0, 1] = y_p
            __pyx_t_14 = __pyx_v_SLR_index;
            __pyx_t_13 = 0;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 461: 
 462:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+463:                         elif x_off == 0 and y_off > 0:
          __pyx_t_11 = (__pyx_v_x_off == 0);
          if (__pyx_t_11) {
          } else {
            __pyx_t_10 = __pyx_t_11;
            goto __pyx_L34_bool_binop_done;
          }
          __pyx_t_11 = (__pyx_v_y_off > 0);
          __pyx_t_10 = __pyx_t_11;
          __pyx_L34_bool_binop_done:;
          if (__pyx_t_10) {
/* … */
            goto __pyx_L33;
          }
+464:                             SLR_pairs[SLR_index, 1, 0] = x
            __pyx_t_7 = __pyx_v_SLR_index;
            __pyx_t_13 = 1;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+465:                             SLR_pairs[SLR_index, 1, 1] = y
            __pyx_t_14 = __pyx_v_SLR_index;
            __pyx_t_13 = 1;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 466: 
+467:                             SLR_pairs[SLR_index, 0, 0] = x_p
            __pyx_t_7 = __pyx_v_SLR_index;
            __pyx_t_13 = 0;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+468:                             SLR_pairs[SLR_index, 0, 1] = y_p
            __pyx_t_14 = __pyx_v_SLR_index;
            __pyx_t_13 = 0;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 469: 
 470:                         else:
+471:                             SLR_pairs[SLR_index, 0, 0] = x
          /*else*/ {
            __pyx_t_7 = __pyx_v_SLR_index;
            __pyx_t_13 = 0;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+472:                             SLR_pairs[SLR_index, 0, 1] = y
            __pyx_t_14 = __pyx_v_SLR_index;
            __pyx_t_13 = 0;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 473: 
+474:                             SLR_pairs[SLR_index, 1, 0] = x_p
            __pyx_t_7 = __pyx_v_SLR_index;
            __pyx_t_13 = 1;
            __pyx_t_14 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+475:                             SLR_pairs[SLR_index, 1, 1] = y_p
            __pyx_t_14 = __pyx_v_SLR_index;
            __pyx_t_13 = 1;
            __pyx_t_7 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
          }
          __pyx_L33:;
 476: 
 477: 
+478:                         SLR_index = SLR_index+1
          __pyx_v_SLR_index = (__pyx_v_SLR_index + 1);
        }
        __pyx_L17:;
        __pyx_L15_continue:;
      }
    }
 479: 
+480:         return (SR_pairs[0:SR_index], LR_pairs[0:LR_index], SLR_pairs[0:SLR_index])
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_SR_index); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_6, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SR_pairs), __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_LR_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_LR_pairs), __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_SLR_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SLR_pairs), __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6) != (0)) __PYX_ERR(0, 480, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_1);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1) != (0)) __PYX_ERR(0, 480, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_3);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 480, __pyx_L1_error);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
 481: 
 482:     else:
+483:         raise InnerLoopException('Invalid LR option passed')
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_InnerLoopException); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Invalid_LR_option_passed};
      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 483, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 483, __pyx_L1_error)
    break;
  }
 484: 
 485: 
+486: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_11inner_loops_5extract_LR_pairs_from_position_3D(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*/
PyDoc_STRVAR(__pyx_doc_5pimms_11inner_loops_4extract_LR_pairs_from_position_3D, "\n    Same as extract_all except ONLY returns LR and SLR pairs\n\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_11inner_loops_5extract_LR_pairs_from_position_3D = {"extract_LR_pairs_from_position_3D", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_11inner_loops_5extract_LR_pairs_from_position_3D, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_11inner_loops_4extract_LR_pairs_from_position_3D};
static PyObject *__pyx_pw_5pimms_11inner_loops_5extract_LR_pairs_from_position_3D(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_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_LR_position;
  __Pyx_memviewslice __pyx_v_type_grid = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_XDIM;
  int __pyx_v_YDIM;
  int __pyx_v_ZDIM;
  #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("extract_LR_pairs_from_position_3D (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __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 ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_LR_position,&__pyx_mstate_global->__pyx_n_u_type_grid,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,&__pyx_mstate_global->__pyx_n_u_ZDIM,0};
  PyObject* values[6] = {0,0,0,0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 486, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  6:
        values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 486, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 486, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 486, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 486, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 486, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 486, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_LR_pairs_from_position_3D", 0) < (0)) __PYX_ERR(0, 486, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 6; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_LR_pairs_from_position_3D", 1, 6, 6, i); __PYX_ERR(0, 486, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 6)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 486, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 486, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 486, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 486, __pyx_L3_error)
      values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 486, __pyx_L3_error)
      values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 486, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 488, __pyx_L3_error)
    __pyx_v_LR_position = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_LR_position == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 489, __pyx_L3_error)
    __pyx_v_type_grid = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_type_grid.memview)) __PYX_ERR(0, 490, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_XDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 491, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_int(values[4]); if (unlikely((__pyx_v_YDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 492, __pyx_L3_error)
    __pyx_v_ZDIM = __Pyx_PyLong_As_int(values[5]); if (unlikely((__pyx_v_ZDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 493, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_LR_pairs_from_position_3D", 1, 6, 6, __pyx_nargs); __PYX_ERR(0, 486, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_AddTraceback("pimms.inner_loops.extract_LR_pairs_from_position_3D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_11inner_loops_4extract_LR_pairs_from_position_3D(__pyx_self, __pyx_v_position, __pyx_v_LR_position, __pyx_v_type_grid, __pyx_v_XDIM, __pyx_v_YDIM, __pyx_v_ZDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

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

static PyObject *__pyx_pf_5pimms_11inner_loops_4extract_LR_pairs_from_position_3D(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, int __pyx_v_LR_position, __Pyx_memviewslice __pyx_v_type_grid, int __pyx_v_XDIM, int __pyx_v_YDIM, int __pyx_v_ZDIM) {
  int __pyx_v_LR_index;
  int __pyx_v_SLR_index;
  int __pyx_v_x_off;
  int __pyx_v_y_off;
  int __pyx_v_z_off;
  int __pyx_v_x_p;
  int __pyx_v_y_p;
  int __pyx_v_z_p;
  PyArrayObject *__pyx_v_LR_pairs = 0;
  PyArrayObject *__pyx_v_SLR_pairs = 0;
  int __pyx_v_x;
  int __pyx_v_y;
  int __pyx_v_z;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_LR_pairs;
  __Pyx_Buffer __pyx_pybuffer_LR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SLR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SLR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_LR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_LR_pairs.refcount = 0;
  __pyx_pybuffernd_LR_pairs.data = NULL;
  __pyx_pybuffernd_LR_pairs.rcbuffer = &__pyx_pybuffer_LR_pairs;
  __pyx_pybuffer_SLR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SLR_pairs.refcount = 0;
  __pyx_pybuffernd_SLR_pairs.data = NULL;
  __pyx_pybuffernd_SLR_pairs.rcbuffer = &__pyx_pybuffer_SLR_pairs;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops.extract_LR_pairs_from_position_3D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_LR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_SLR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_11inner_loops_5extract_LR_pairs_from_position_3D, 0, __pyx_mstate_global->__pyx_n_u_extract_LR_pairs_from_position_3, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 486, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_LR_pairs_from_position_3, __pyx_t_4) < (0)) __PYX_ERR(0, 486, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 487: @cython.wraparound(False)
 488: def extract_LR_pairs_from_position_3D(NUMPY_INT_TYPE[:] position,
 489:                                       int LR_position,
 490:                                       NUMPY_INT_TYPE[:,:,:] type_grid,
 491:                                       int XDIM,
 492:                                       int YDIM,
 493:                                       int ZDIM):
 494:     """
 495:     Same as extract_all except ONLY returns LR and SLR pairs
 496: 
 497: 
 498:     """
 499: 
 500:     # declare some variables
 501:     cdef int LR_index, SLR_index, x_off, y_off, z_off
 502:     cdef int x_p, y_p, z_p
 503:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] LR_pairs
 504:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SLR_pairs
 505: 
 506:     # first set the central x, y and z positions
+507:     cdef int x = position[0]
  __pyx_t_1 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
+508:     cdef int y = position[1]
  __pyx_t_1 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
+509:     cdef int z = position[2]
  __pyx_t_1 = 2;
  __pyx_v_z = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
 510: 
 511:     # if no long-range interactions required the return empy
 512:     # arrays
+513:     if LR_position == 0:
  switch (__pyx_v_LR_position) {
    case 0:
/* … */
    break;
    case 1:
+514:         return (np.array([], dtype=NUMPY_INT_TYPE_PYTHON), np.array([], dtype=NUMPY_INT_TYPE_PYTHON))
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_t_4};
      __pyx_t_8 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 514, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_6, __pyx_t_8, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 514, __pyx_L1_error)
      __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_8);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 514, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_8 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_8);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_8, __pyx_t_6};
      __pyx_t_9 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 514, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_9, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 514, __pyx_L1_error)
      __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_9);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 514, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 514, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2) != (0)) __PYX_ERR(0, 514, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_5);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 514, __pyx_L1_error);
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
 515: 
+516:     elif LR_position == 1:
    break;
    default:
+517:         LR_pairs = np.zeros((98, 2, 3), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_5 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
      assert(__pyx_t_5);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, __pyx_mstate_global->__pyx_tuple[2]};
      __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 517, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_2, __pyx_t_3, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 517, __pyx_L1_error)
      __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 517, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 517, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
      __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_4), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_10 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_LR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        }
        __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
      }
      __pyx_pybuffernd_LR_pairs.diminfo[0].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_LR_pairs.diminfo[0].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_LR_pairs.diminfo[1].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_LR_pairs.diminfo[1].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_LR_pairs.diminfo[2].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_LR_pairs.diminfo[2].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 517, __pyx_L1_error)
    }
    __pyx_v_LR_pairs = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
+518:         SLR_pairs = np.zeros((218, 2, 3), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_9 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_9);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_9, __pyx_mstate_global->__pyx_tuple[3]};
      __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_5, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 518, __pyx_L1_error)
      __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 518, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
      __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_4), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_10 < 0)) {
        PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_SLR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
        }
        __pyx_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
      }
      __pyx_pybuffernd_SLR_pairs.diminfo[0].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SLR_pairs.diminfo[0].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SLR_pairs.diminfo[1].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SLR_pairs.diminfo[1].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SLR_pairs.diminfo[2].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SLR_pairs.diminfo[2].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 518, __pyx_L1_error)
    }
    __pyx_v_SLR_pairs = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
 519: 
+520:         LR_index = 0
    __pyx_v_LR_index = 0;
+521:         SLR_index = 0
    __pyx_v_SLR_index = 0;
 522: 
 523:         # loop over long range cube around site
+524:         for x_off in xrange(-3,4):
    for (__pyx_t_10 = -3; __pyx_t_10 < 4; __pyx_t_10+=1) {
      __pyx_v_x_off = __pyx_t_10;
+525:             for y_off in xrange(-3,4):
      for (__pyx_t_14 = -3; __pyx_t_14 < 4; __pyx_t_14+=1) {
        __pyx_v_y_off = __pyx_t_14;
+526:                 for z_off in xrange(-3,4):
        for (__pyx_t_15 = -3; __pyx_t_15 < 4; __pyx_t_15+=1) {
          __pyx_v_z_off = __pyx_t_15;
+527:                     x_p = pbc_correction(x + x_off, XDIM)
          __pyx_t_16 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_16 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 527, __pyx_L1_error)
          __pyx_v_x_p = __pyx_t_16;
+528:                     y_p = pbc_correction(y + y_off, YDIM)
          __pyx_t_16 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_16 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 528, __pyx_L1_error)
          __pyx_v_y_p = __pyx_t_16;
+529:                     z_p = pbc_correction(z + z_off, ZDIM)
          __pyx_t_16 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_z + __pyx_v_z_off), __pyx_v_ZDIM); if (unlikely(__pyx_t_16 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 529, __pyx_L1_error)
          __pyx_v_z_p = __pyx_t_16;
 530: 
 531:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 532:                     # if short range_interaction
+533:                     if abs(x_off) < 2 and abs(y_off) < 2 and abs(z_off) <2:
          __pyx_t_16 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 533, __pyx_L1_error)
          __pyx_t_18 = (__pyx_t_16 < 2);
          if (__pyx_t_18) {
          } else {
            __pyx_t_17 = __pyx_t_18;
            goto __pyx_L10_bool_binop_done;
          }
          __pyx_t_16 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 533, __pyx_L1_error)
          __pyx_t_18 = (__pyx_t_16 < 2);
          if (__pyx_t_18) {
          } else {
            __pyx_t_17 = __pyx_t_18;
            goto __pyx_L10_bool_binop_done;
          }
          __pyx_t_16 = abs(__pyx_v_z_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 533, __pyx_L1_error)
          __pyx_t_18 = (__pyx_t_16 < 2);
          __pyx_t_17 = __pyx_t_18;
          __pyx_L10_bool_binop_done:;
          if (__pyx_t_17) {
/* … */
          }
+534:                         continue
            goto __pyx_L7_continue;
 535: 
 536:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 537:                     ## Long range interaction
+538:                     elif abs(x_off) < 3 and abs(y_off) < 3 and abs(z_off) < 3:
          __pyx_t_16 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 538, __pyx_L1_error)
          __pyx_t_18 = (__pyx_t_16 < 3);
          if (__pyx_t_18) {
          } else {
            __pyx_t_17 = __pyx_t_18;
            goto __pyx_L13_bool_binop_done;
          }
          __pyx_t_16 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 538, __pyx_L1_error)
          __pyx_t_18 = (__pyx_t_16 < 3);
          if (__pyx_t_18) {
          } else {
            __pyx_t_17 = __pyx_t_18;
            goto __pyx_L13_bool_binop_done;
          }
          __pyx_t_16 = abs(__pyx_v_z_off); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 538, __pyx_L1_error)
          __pyx_t_18 = (__pyx_t_16 < 3);
          __pyx_t_17 = __pyx_t_18;
          __pyx_L13_bool_binop_done:;
          if (__pyx_t_17) {
/* … */
            goto __pyx_L9;
          }
+539:                         if type_grid[x_p, y_p, z_p] == 0:
            __pyx_t_1 = __pyx_v_x_p;
            __pyx_t_19 = __pyx_v_y_p;
            __pyx_t_20 = __pyx_v_z_p;
            __pyx_t_17 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_1 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_19 * __pyx_v_type_grid.strides[1]) ) + __pyx_t_20 * __pyx_v_type_grid.strides[2]) ))) == 0);
            if (__pyx_t_17) {
/* … */
            }
+540:                             continue
              goto __pyx_L7_continue;
 541: 
 542:                         # if x_off < 0 then the non-central position must come first in the pair
+543:                         if x_off > 0:
            __pyx_t_17 = (__pyx_v_x_off > 0);
            if (__pyx_t_17) {
/* … */
              goto __pyx_L17;
            }
+544:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+545:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+546:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 547: 
+548:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+549:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+550:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 551: 
 552:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+553:                         elif x_off == 0 and y_off > 0:
            __pyx_t_18 = (__pyx_v_x_off == 0);
            if (__pyx_t_18) {
            } else {
              __pyx_t_17 = __pyx_t_18;
              goto __pyx_L18_bool_binop_done;
            }
            __pyx_t_18 = (__pyx_v_y_off > 0);
            __pyx_t_17 = __pyx_t_18;
            __pyx_L18_bool_binop_done:;
            if (__pyx_t_17) {
/* … */
              goto __pyx_L17;
            }
+554:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+555:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+556:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 557: 
+558:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+559:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+560:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 561: 
 562:                         # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+563:                         elif x_off == 0 and y_off == 0 and z_off > 0:
            __pyx_t_18 = (__pyx_v_x_off == 0);
            if (__pyx_t_18) {
            } else {
              __pyx_t_17 = __pyx_t_18;
              goto __pyx_L20_bool_binop_done;
            }
            __pyx_t_18 = (__pyx_v_y_off == 0);
            if (__pyx_t_18) {
            } else {
              __pyx_t_17 = __pyx_t_18;
              goto __pyx_L20_bool_binop_done;
            }
            __pyx_t_18 = (__pyx_v_z_off > 0);
            __pyx_t_17 = __pyx_t_18;
            __pyx_L20_bool_binop_done:;
            if (__pyx_t_17) {
/* … */
              goto __pyx_L17;
            }
+564:                             LR_pairs[LR_index, 1, 0] = x
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+565:                             LR_pairs[LR_index, 1, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+566:                             LR_pairs[LR_index, 1, 2] = z
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 567: 
+568:                             LR_pairs[LR_index, 0, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+569:                             LR_pairs[LR_index, 0, 1] = y_p
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+570:                             LR_pairs[LR_index, 0, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 571: 
 572:                         else:
+573:                             LR_pairs[LR_index, 0, 0] = x
            /*else*/ {
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+574:                             LR_pairs[LR_index, 0, 1] = y
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
+575:                             LR_pairs[LR_index, 0, 2] = z
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z;
 576: 
+577:                             LR_pairs[LR_index, 1, 0] = x_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+578:                             LR_pairs[LR_index, 1, 1] = y_p
              __pyx_t_20 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+579:                             LR_pairs[LR_index, 1, 2] = z_p
              __pyx_t_1 = __pyx_v_LR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_z_p;
            }
            __pyx_L17:;
 580: 
+581:                         LR_index = LR_index+1
            __pyx_v_LR_index = (__pyx_v_LR_index + 1);
 582: 
 583:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 584:                     ## Super long range interaction
 585:                     else:
+586:                         if type_grid[x_p, y_p, z_p] == 0:
          /*else*/ {
            __pyx_t_20 = __pyx_v_x_p;
            __pyx_t_19 = __pyx_v_y_p;
            __pyx_t_1 = __pyx_v_z_p;
            __pyx_t_17 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_20 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_19 * __pyx_v_type_grid.strides[1]) ) + __pyx_t_1 * __pyx_v_type_grid.strides[2]) ))) == 0);
            if (__pyx_t_17) {
/* … */
            }
+587:                             continue
              goto __pyx_L7_continue;
 588: 
 589:                         # if x_off < 0 then the non-central position must come first in the pair
+590:                         if x_off > 0:
            __pyx_t_17 = (__pyx_v_x_off > 0);
            if (__pyx_t_17) {
/* … */
              goto __pyx_L24;
            }
+591:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+592:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+593:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 594: 
+595:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+596:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+597:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 598: 
 599:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+600:                         elif x_off == 0 and y_off > 0:
            __pyx_t_18 = (__pyx_v_x_off == 0);
            if (__pyx_t_18) {
            } else {
              __pyx_t_17 = __pyx_t_18;
              goto __pyx_L25_bool_binop_done;
            }
            __pyx_t_18 = (__pyx_v_y_off > 0);
            __pyx_t_17 = __pyx_t_18;
            __pyx_L25_bool_binop_done:;
            if (__pyx_t_17) {
/* … */
              goto __pyx_L24;
            }
+601:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+602:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+603:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 604: 
+605:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+606:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+607:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 608: 
 609:                         # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+610:                         elif x_off == 0 and y_off == 0 and z_off > 0:
            __pyx_t_18 = (__pyx_v_x_off == 0);
            if (__pyx_t_18) {
            } else {
              __pyx_t_17 = __pyx_t_18;
              goto __pyx_L27_bool_binop_done;
            }
            __pyx_t_18 = (__pyx_v_y_off == 0);
            if (__pyx_t_18) {
            } else {
              __pyx_t_17 = __pyx_t_18;
              goto __pyx_L27_bool_binop_done;
            }
            __pyx_t_18 = (__pyx_v_z_off > 0);
            __pyx_t_17 = __pyx_t_18;
            __pyx_L27_bool_binop_done:;
            if (__pyx_t_17) {
/* … */
              goto __pyx_L24;
            }
+611:                             SLR_pairs[SLR_index, 1, 0] = x
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+612:                             SLR_pairs[SLR_index, 1, 1] = y
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+613:                             SLR_pairs[SLR_index, 1, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 614: 
+615:                             SLR_pairs[SLR_index, 0, 0] = x_p
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+616:                             SLR_pairs[SLR_index, 0, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+617:                             SLR_pairs[SLR_index, 0, 2] = z_p
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 618: 
 619:                         else:
+620:                             SLR_pairs[SLR_index, 0, 0] = x
            /*else*/ {
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+621:                             SLR_pairs[SLR_index, 0, 1] = y
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_1 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
+622:                             SLR_pairs[SLR_index, 0, 2] = z
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 0;
              __pyx_t_20 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z;
 623: 
+624:                             SLR_pairs[SLR_index, 1, 0] = x_p
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 0;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+625:                             SLR_pairs[SLR_index, 1, 1] = y_p
              __pyx_t_1 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_20 = 1;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+626:                             SLR_pairs[SLR_index, 1, 2] = z_p
              __pyx_t_20 = __pyx_v_SLR_index;
              __pyx_t_19 = 1;
              __pyx_t_1 = 2;
              *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_z_p;
            }
            __pyx_L24:;
 627: 
+628:                         SLR_index = SLR_index+1
            __pyx_v_SLR_index = (__pyx_v_SLR_index + 1);
          }
          __pyx_L9:;
          __pyx_L7_continue:;
        }
      }
    }
 629: 
 630: 
+631:         return (LR_pairs[0:LR_index], SLR_pairs[0:SLR_index])
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_LR_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_LR_pairs), __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_SLR_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SLR_pairs), __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4) != (0)) __PYX_ERR(0, 631, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 631, __pyx_L1_error);
    __pyx_t_4 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;
 632: 
 633:     else:
+634:         raise InnerLoopException('Invalid LR option passed')
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_InnerLoopException); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Invalid_LR_option_passed};
      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 634, __pyx_L1_error)
    break;
  }
 635: 
 636: 
 637: ##
 638: #################################################################################################
 639: ##
+640: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_11inner_loops_7extract_SR_pairs_from_position_3D(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*/
PyDoc_STRVAR(__pyx_doc_5pimms_11inner_loops_6extract_SR_pairs_from_position_3D, "\n\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_11inner_loops_7extract_SR_pairs_from_position_3D = {"extract_SR_pairs_from_position_3D", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_11inner_loops_7extract_SR_pairs_from_position_3D, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_11inner_loops_6extract_SR_pairs_from_position_3D};
static PyObject *__pyx_pw_5pimms_11inner_loops_7extract_SR_pairs_from_position_3D(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_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_XDIM;
  int __pyx_v_YDIM;
  int __pyx_v_ZDIM;
  #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("extract_SR_pairs_from_position_3D (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __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 ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,&__pyx_mstate_global->__pyx_n_u_ZDIM,0};
  PyObject* values[4] = {0,0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 640, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 640, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 640, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 640, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 640, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_SR_pairs_from_position_3D", 0) < (0)) __PYX_ERR(0, 640, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 4; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_SR_pairs_from_position_3D", 1, 4, 4, i); __PYX_ERR(0, 640, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 4)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 640, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 640, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 640, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 640, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 642, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_XDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 643, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_int(values[2]); if (unlikely((__pyx_v_YDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 644, __pyx_L3_error)
    __pyx_v_ZDIM = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_ZDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 645, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_SR_pairs_from_position_3D", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 640, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __Pyx_AddTraceback("pimms.inner_loops.extract_SR_pairs_from_position_3D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_11inner_loops_6extract_SR_pairs_from_position_3D(__pyx_self, __pyx_v_position, __pyx_v_XDIM, __pyx_v_YDIM, __pyx_v_ZDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

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

static PyObject *__pyx_pf_5pimms_11inner_loops_6extract_SR_pairs_from_position_3D(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, int __pyx_v_XDIM, int __pyx_v_YDIM, int __pyx_v_ZDIM) {
  int __pyx_v_SR_index;
  int __pyx_v_x_off;
  int __pyx_v_y_off;
  int __pyx_v_z_off;
  int __pyx_v_x_p;
  int __pyx_v_y_p;
  int __pyx_v_z_p;
  PyArrayObject *__pyx_v_SR_pairs = 0;
  int __pyx_v_x;
  int __pyx_v_y;
  int __pyx_v_z;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_SR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SR_pairs.refcount = 0;
  __pyx_pybuffernd_SR_pairs.data = NULL;
  __pyx_pybuffernd_SR_pairs.rcbuffer = &__pyx_pybuffer_SR_pairs;
/* … */
  /* 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_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops.extract_SR_pairs_from_position_3D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_SR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_11inner_loops_7extract_SR_pairs_from_position_3D, 0, __pyx_mstate_global->__pyx_n_u_extract_SR_pairs_from_position_3, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 640, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_SR_pairs_from_position_3, __pyx_t_4) < (0)) __PYX_ERR(0, 640, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 641: @cython.wraparound(False)
 642: def extract_SR_pairs_from_position_3D(NUMPY_INT_TYPE[:] position,
 643:                                           int XDIM,
 644:                                           int YDIM,
 645:                                           int ZDIM):
 646:     """
 647: 
 648: 
 649:     """
 650: 
 651:     # declare some variables
 652:     cdef int SR_index, x_off, y_off, z_off
 653:     cdef int x_p, y_p, z_p
+654:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SR_pairs = np.zeros((26,2,3), dtype=NUMPY_INT_TYPE_PYTHON)
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_mstate_global->__pyx_tuple[1]};
    __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 654, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_6, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 654, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 654, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 654, __pyx_L1_error)
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_SR_pairs = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 654, __pyx_L1_error)
    } else {__pyx_pybuffernd_SR_pairs.diminfo[0].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SR_pairs.diminfo[0].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SR_pairs.diminfo[1].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SR_pairs.diminfo[1].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SR_pairs.diminfo[2].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SR_pairs.diminfo[2].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_v_SR_pairs = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 655: 
 656:     # first set the central x, y and z positions
+657:     cdef int x = position[0]
  __pyx_t_7 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
+658:     cdef int y = position[1]
  __pyx_t_7 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
+659:     cdef int z = position[2]
  __pyx_t_7 = 2;
  __pyx_v_z = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
 660: 
+661:     SR_index = 0
  __pyx_v_SR_index = 0;
+662:     for x_off in xrange(-1,2):
  for (__pyx_t_8 = -1; __pyx_t_8 < 2; __pyx_t_8+=1) {
    __pyx_v_x_off = __pyx_t_8;
+663:         for y_off in xrange(-1,2):
    for (__pyx_t_9 = -1; __pyx_t_9 < 2; __pyx_t_9+=1) {
      __pyx_v_y_off = __pyx_t_9;
+664:             for z_off in xrange(-1,2):
      for (__pyx_t_10 = -1; __pyx_t_10 < 2; __pyx_t_10+=1) {
        __pyx_v_z_off = __pyx_t_10;
+665:                 if x_off == 0 and y_off == 0 and z_off == 0:
        __pyx_t_12 = (__pyx_v_x_off == 0);
        if (__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L10_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_y_off == 0);
        if (__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L10_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_z_off == 0);
        __pyx_t_11 = __pyx_t_12;
        __pyx_L10_bool_binop_done:;
        if (__pyx_t_11) {
/* … */
        }
+666:                     continue
          goto __pyx_L7_continue;
 667: 
+668:                 x_p = pbc_correction(x + x_off, XDIM)
        __pyx_t_13 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_13 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 668, __pyx_L1_error)
        __pyx_v_x_p = __pyx_t_13;
+669:                 y_p = pbc_correction(y + y_off, YDIM)
        __pyx_t_13 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_13 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 669, __pyx_L1_error)
        __pyx_v_y_p = __pyx_t_13;
+670:                 z_p = pbc_correction(z + z_off, ZDIM)
        __pyx_t_13 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_z + __pyx_v_z_off), __pyx_v_ZDIM); if (unlikely(__pyx_t_13 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 670, __pyx_L1_error)
        __pyx_v_z_p = __pyx_t_13;
 671: 
 672:                 # if x_off < 0 then the non-central position must come first in the pair
+673:                 if x_off > 0:
        __pyx_t_11 = (__pyx_v_x_off > 0);
        if (__pyx_t_11) {
/* … */
          goto __pyx_L13;
        }
+674:                     SR_pairs[SR_index, 1, 0] = x
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+675:                     SR_pairs[SR_index, 1, 1] = y
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+676:                     SR_pairs[SR_index, 1, 2] = z
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 677: 
+678:                     SR_pairs[SR_index, 0, 0] = x_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+679:                     SR_pairs[SR_index, 0, 1] = y_p
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_15 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+680:                     SR_pairs[SR_index, 0, 2] = z_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 681: 
 682: 
 683:                 # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+684:                 elif x_off == 0 and y_off > 0:
        __pyx_t_12 = (__pyx_v_x_off == 0);
        if (__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L14_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_y_off > 0);
        __pyx_t_11 = __pyx_t_12;
        __pyx_L14_bool_binop_done:;
        if (__pyx_t_11) {
/* … */
          goto __pyx_L13;
        }
+685:                     SR_pairs[SR_index, 1, 0] = x
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+686:                     SR_pairs[SR_index, 1, 1] = y
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+687:                     SR_pairs[SR_index, 1, 2] = z
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 688: 
+689:                     SR_pairs[SR_index, 0, 0] = x_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+690:                     SR_pairs[SR_index, 0, 1] = y_p
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_15 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+691:                     SR_pairs[SR_index, 0, 2] = z_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 692: 
 693:                 # if x_off == 0  and y_off is == 0 and z_off < 1 then the non-central position must come first in the pair
+694:                 elif x_off == 0 and y_off == 0 and z_off > 0:
        __pyx_t_12 = (__pyx_v_x_off == 0);
        if (__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L16_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_y_off == 0);
        if (__pyx_t_12) {
        } else {
          __pyx_t_11 = __pyx_t_12;
          goto __pyx_L16_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_v_z_off > 0);
        __pyx_t_11 = __pyx_t_12;
        __pyx_L16_bool_binop_done:;
        if (__pyx_t_11) {
/* … */
          goto __pyx_L13;
        }
+695:                     SR_pairs[SR_index, 1, 0] = x
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+696:                     SR_pairs[SR_index, 1, 1] = y
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+697:                     SR_pairs[SR_index, 1, 2] = z
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 698: 
+699:                     SR_pairs[SR_index, 0, 0] = x_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+700:                     SR_pairs[SR_index, 0, 1] = y_p
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_15 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+701:                     SR_pairs[SR_index, 0, 2] = z_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
 702: 
 703:                 else:
+704:                     SR_pairs[SR_index, 0, 0] = x
        /*else*/ {
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_15 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+705:                     SR_pairs[SR_index, 0, 1] = y
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_7 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
+706:                     SR_pairs[SR_index, 0, 2] = z
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 0;
          __pyx_t_15 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z;
 707: 
+708:                     SR_pairs[SR_index, 1, 0] = x_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_7 = 0;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+709:                     SR_pairs[SR_index, 1, 1] = y_p
          __pyx_t_7 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_15 = 1;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
+710:                     SR_pairs[SR_index, 1, 2] = z_p
          __pyx_t_15 = __pyx_v_SR_index;
          __pyx_t_14 = 1;
          __pyx_t_7 = 2;
          *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_z_p;
        }
        __pyx_L13:;
 711: 
+712:                 SR_index = SR_index+1
        __pyx_v_SR_index = (__pyx_v_SR_index + 1);
        __pyx_L7_continue:;
      }
    }
  }
 713: 
+714:     return (SR_pairs)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF((PyObject *)__pyx_v_SR_pairs);
  __pyx_r = ((PyObject *)__pyx_v_SR_pairs);
  goto __pyx_L0;
 715: 
 716: 
 717: ##
 718: #################################################################################################
 719: ##
+720: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_11inner_loops_9extract_LR_pairs_from_position_2D(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*/
PyDoc_STRVAR(__pyx_doc_5pimms_11inner_loops_8extract_LR_pairs_from_position_2D, "\n\n\n    ");
static PyMethodDef __pyx_mdef_5pimms_11inner_loops_9extract_LR_pairs_from_position_2D = {"extract_LR_pairs_from_position_2D", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_11inner_loops_9extract_LR_pairs_from_position_2D, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_11inner_loops_8extract_LR_pairs_from_position_2D};
static PyObject *__pyx_pw_5pimms_11inner_loops_9extract_LR_pairs_from_position_2D(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_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_LR_position;
  __Pyx_memviewslice __pyx_v_type_grid = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_XDIM;
  int __pyx_v_YDIM;
  #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("extract_LR_pairs_from_position_2D (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __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 ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_LR_position,&__pyx_mstate_global->__pyx_n_u_type_grid,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,0};
  PyObject* values[5] = {0,0,0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 720, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 720, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 720, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 720, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 720, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 720, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_LR_pairs_from_position_2D", 0) < (0)) __PYX_ERR(0, 720, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 5; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_LR_pairs_from_position_2D", 1, 5, 5, i); __PYX_ERR(0, 720, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 5)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 720, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 720, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 720, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 720, __pyx_L3_error)
      values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 720, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 722, __pyx_L3_error)
    __pyx_v_LR_position = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_LR_position == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 723, __pyx_L3_error)
    __pyx_v_type_grid = __Pyx_PyObject_to_MemoryviewSlice_dsds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_type_grid.memview)) __PYX_ERR(0, 724, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_XDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 725, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_int(values[4]); if (unlikely((__pyx_v_YDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 726, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_LR_pairs_from_position_2D", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 720, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_type_grid, 1);
  __Pyx_AddTraceback("pimms.inner_loops.extract_LR_pairs_from_position_2D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_11inner_loops_8extract_LR_pairs_from_position_2D(__pyx_self, __pyx_v_position, __pyx_v_LR_position, __pyx_v_type_grid, __pyx_v_XDIM, __pyx_v_YDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

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

static PyObject *__pyx_pf_5pimms_11inner_loops_8extract_LR_pairs_from_position_2D(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, int __pyx_v_LR_position, __Pyx_memviewslice __pyx_v_type_grid, int __pyx_v_XDIM, int __pyx_v_YDIM) {
  int __pyx_v_LR_index;
  int __pyx_v_SLR_index;
  int __pyx_v_x_off;
  int __pyx_v_y_off;
  int __pyx_v_x_p;
  int __pyx_v_y_p;
  PyArrayObject *__pyx_v_LR_pairs = 0;
  PyArrayObject *__pyx_v_SLR_pairs = 0;
  int __pyx_v_x;
  int __pyx_v_y;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_LR_pairs;
  __Pyx_Buffer __pyx_pybuffer_LR_pairs;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SLR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SLR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_LR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_LR_pairs.refcount = 0;
  __pyx_pybuffernd_LR_pairs.data = NULL;
  __pyx_pybuffernd_LR_pairs.rcbuffer = &__pyx_pybuffer_LR_pairs;
  __pyx_pybuffer_SLR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SLR_pairs.refcount = 0;
  __pyx_pybuffernd_SLR_pairs.data = NULL;
  __pyx_pybuffernd_SLR_pairs.rcbuffer = &__pyx_pybuffer_SLR_pairs;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops.extract_LR_pairs_from_position_2D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_LR_pairs);
  __Pyx_XDECREF((PyObject *)__pyx_v_SLR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_11inner_loops_9extract_LR_pairs_from_position_2D, 0, __pyx_mstate_global->__pyx_n_u_extract_LR_pairs_from_position_2, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_LR_pairs_from_position_2, __pyx_t_4) < (0)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 721: @cython.wraparound(False)
 722: def extract_LR_pairs_from_position_2D(NUMPY_INT_TYPE[:] position,
 723:                                       int LR_position,
 724:                                       NUMPY_INT_TYPE[:,:] type_grid,
 725:                                       int XDIM,
 726:                                       int YDIM):
 727: 
 728:     """
 729: 
 730: 
 731:     """
 732: 
 733:     # declare some variables
 734:     cdef int LR_index, SLR_index, x_off, y_off
 735:     cdef int x_p, y_p
 736:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] LR_pairs
 737:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SLR_pairs
 738: 
 739:     # first set the central x, y and z positions
+740:     cdef int x = position[0]
  __pyx_t_1 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
+741:     cdef int y = position[1]
  __pyx_t_1 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_1 * __pyx_v_position.strides[0]) )));
 742: 
 743:     # if no long-range interactions required the return empy
 744:     # array
+745:     if LR_position == 0:
  switch (__pyx_v_LR_position) {
    case 0:
/* … */
    break;
    case 1:
+746:         return (np.array([]),np.array([]))
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_4 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_array); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_3};
      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 746, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2) != (0)) __PYX_ERR(0, 746, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_5);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 746, __pyx_L1_error);
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_r = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L0;
 747: 
+748:     elif LR_position == 1:
    break;
    default:
+749:         LR_pairs = np.zeros((16, 2, 2), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_5 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 749, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      assert(__pyx_t_5);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, __pyx_mstate_global->__pyx_tuple[5]};
      __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 749, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_2, __pyx_t_4, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 749, __pyx_L1_error)
      __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 749, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
    }
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 749, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer);
      __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_7), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_8 < 0)) {
        PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_LR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
        }
        __pyx_t_9 = __pyx_t_10 = __pyx_t_11 = 0;
      }
      __pyx_pybuffernd_LR_pairs.diminfo[0].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_LR_pairs.diminfo[0].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_LR_pairs.diminfo[1].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_LR_pairs.diminfo[1].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_LR_pairs.diminfo[2].strides = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_LR_pairs.diminfo[2].shape = __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 749, __pyx_L1_error)
    }
    __pyx_v_LR_pairs = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;
+750:         SLR_pairs = np.zeros((24, 2, 2), dtype=NUMPY_INT_TYPE_PYTHON)
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_mstate_global->__pyx_tuple[6]};
      __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 750, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_4, __pyx_t_5, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 750, __pyx_L1_error)
      __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 750, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
    }
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 750, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer);
      __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_7), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_8 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer, (PyObject*)__pyx_v_SLR_pairs, &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_11, __pyx_t_10, __pyx_t_9);
        }
        __pyx_t_11 = __pyx_t_10 = __pyx_t_9 = 0;
      }
      __pyx_pybuffernd_SLR_pairs.diminfo[0].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SLR_pairs.diminfo[0].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SLR_pairs.diminfo[1].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SLR_pairs.diminfo[1].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SLR_pairs.diminfo[2].strides = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SLR_pairs.diminfo[2].shape = __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.shape[2];
      if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 750, __pyx_L1_error)
    }
    __pyx_v_SLR_pairs = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;
 751: 
+752:         LR_index = 0
    __pyx_v_LR_index = 0;
+753:         SLR_index = 0
    __pyx_v_SLR_index = 0;
 754: 
 755:         # loop over long range cube around site
+756:         for x_off in xrange(-3,4):
    for (__pyx_t_8 = -3; __pyx_t_8 < 4; __pyx_t_8+=1) {
      __pyx_v_x_off = __pyx_t_8;
+757:             for y_off in xrange(-3,4):
      for (__pyx_t_12 = -3; __pyx_t_12 < 4; __pyx_t_12+=1) {
        __pyx_v_y_off = __pyx_t_12;
+758:                     x_p = pbc_correction(x + x_off, XDIM)
        __pyx_t_13 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_13 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 758, __pyx_L1_error)
        __pyx_v_x_p = __pyx_t_13;
+759:                     y_p = pbc_correction(y + y_off, YDIM)
        __pyx_t_13 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_13 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 759, __pyx_L1_error)
        __pyx_v_y_p = __pyx_t_13;
 760: 
 761:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 762:                     # if short range_interaction
+763:                     if abs(x_off) < 2 and abs(y_off) < 2:
        __pyx_t_13 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 763, __pyx_L1_error)
        __pyx_t_15 = (__pyx_t_13 < 2);
        if (__pyx_t_15) {
        } else {
          __pyx_t_14 = __pyx_t_15;
          goto __pyx_L8_bool_binop_done;
        }
        __pyx_t_13 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 763, __pyx_L1_error)
        __pyx_t_15 = (__pyx_t_13 < 2);
        __pyx_t_14 = __pyx_t_15;
        __pyx_L8_bool_binop_done:;
        if (__pyx_t_14) {
/* … */
        }
+764:                         continue
          goto __pyx_L5_continue;
 765: 
 766:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 767:                     ## Long range interaction
+768:                     elif abs(x_off) < 3 and abs(y_off) < 3:
        __pyx_t_13 = abs(__pyx_v_x_off); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 768, __pyx_L1_error)
        __pyx_t_15 = (__pyx_t_13 < 3);
        if (__pyx_t_15) {
        } else {
          __pyx_t_14 = __pyx_t_15;
          goto __pyx_L10_bool_binop_done;
        }
        __pyx_t_13 = abs(__pyx_v_y_off); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 768, __pyx_L1_error)
        __pyx_t_15 = (__pyx_t_13 < 3);
        __pyx_t_14 = __pyx_t_15;
        __pyx_L10_bool_binop_done:;
        if (__pyx_t_14) {
/* … */
          goto __pyx_L7;
        }
+769:                         if type_grid[x_p, y_p] == 0:
          __pyx_t_1 = __pyx_v_x_p;
          __pyx_t_16 = __pyx_v_y_p;
          __pyx_t_14 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_1 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_16 * __pyx_v_type_grid.strides[1]) ))) == 0);
          if (__pyx_t_14) {
/* … */
          }
+770:                             continue
            goto __pyx_L5_continue;
 771: 
 772:                         # if x_off < 0 then the non-central position must come first in the pair
+773:                         if x_off > 0:
          __pyx_t_14 = (__pyx_v_x_off > 0);
          if (__pyx_t_14) {
/* … */
            goto __pyx_L13;
          }
+774:                             LR_pairs[LR_index, 1, 0] = x
            __pyx_t_16 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+775:                             LR_pairs[LR_index, 1, 1] = y
            __pyx_t_17 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_16 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 776: 
+777:                             LR_pairs[LR_index, 0, 0] = x_p
            __pyx_t_16 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+778:                             LR_pairs[LR_index, 0, 1] = y_p
            __pyx_t_17 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_16 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 779: 
 780:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+781:                         elif x_off == 0 and y_off > 0:
          __pyx_t_15 = (__pyx_v_x_off == 0);
          if (__pyx_t_15) {
          } else {
            __pyx_t_14 = __pyx_t_15;
            goto __pyx_L14_bool_binop_done;
          }
          __pyx_t_15 = (__pyx_v_y_off > 0);
          __pyx_t_14 = __pyx_t_15;
          __pyx_L14_bool_binop_done:;
          if (__pyx_t_14) {
/* … */
            goto __pyx_L13;
          }
+782:                             LR_pairs[LR_index, 1, 0] = x
            __pyx_t_16 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+783:                             LR_pairs[LR_index, 1, 1] = y
            __pyx_t_17 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_16 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 784: 
+785:                             LR_pairs[LR_index, 0, 0] = x_p
            __pyx_t_16 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+786:                             LR_pairs[LR_index, 0, 1] = y_p
            __pyx_t_17 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_16 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 787: 
 788: 
 789:                         else:
+790:                             LR_pairs[LR_index, 0, 0] = x
          /*else*/ {
            __pyx_t_16 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x;
+791:                             LR_pairs[LR_index, 0, 1] = y
            __pyx_t_17 = __pyx_v_LR_index;
            __pyx_t_1 = 0;
            __pyx_t_16 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y;
 792: 
+793:                             LR_pairs[LR_index, 1, 0] = x_p
            __pyx_t_16 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+794:                             LR_pairs[LR_index, 1, 1] = y_p
            __pyx_t_17 = __pyx_v_LR_index;
            __pyx_t_1 = 1;
            __pyx_t_16 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_LR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_LR_pairs.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_LR_pairs.diminfo[1].strides, __pyx_t_16, __pyx_pybuffernd_LR_pairs.diminfo[2].strides) = __pyx_v_y_p;
          }
          __pyx_L13:;
 795: 
+796:                         LR_index = LR_index+1
          __pyx_v_LR_index = (__pyx_v_LR_index + 1);
 797: 
 798:                     ## >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 799:                     ## Super long range interaction
 800:                     else:
+801:                         if type_grid[x_p, y_p] == 0:
        /*else*/ {
          __pyx_t_16 = __pyx_v_x_p;
          __pyx_t_1 = __pyx_v_y_p;
          __pyx_t_14 = ((*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_type_grid.data + __pyx_t_16 * __pyx_v_type_grid.strides[0]) ) + __pyx_t_1 * __pyx_v_type_grid.strides[1]) ))) == 0);
          if (__pyx_t_14) {
/* … */
          }
+802:                             continue
            goto __pyx_L5_continue;
 803: 
 804:                         # if x_off < 0 then the non-central position must come first in the pair
+805:                         if x_off > 0:
          __pyx_t_14 = (__pyx_v_x_off > 0);
          if (__pyx_t_14) {
/* … */
            goto __pyx_L17;
          }
+806:                             SLR_pairs[SLR_index, 1, 0] = x
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_16 = 1;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+807:                             SLR_pairs[SLR_index, 1, 1] = y
            __pyx_t_17 = __pyx_v_SLR_index;
            __pyx_t_16 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 808: 
+809:                             SLR_pairs[SLR_index, 0, 0] = x_p
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_16 = 0;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+810:                             SLR_pairs[SLR_index, 0, 1] = y_p
            __pyx_t_17 = __pyx_v_SLR_index;
            __pyx_t_16 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 811: 
 812:                         # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+813:                         elif x_off == 0 and y_off > 0:
          __pyx_t_15 = (__pyx_v_x_off == 0);
          if (__pyx_t_15) {
          } else {
            __pyx_t_14 = __pyx_t_15;
            goto __pyx_L18_bool_binop_done;
          }
          __pyx_t_15 = (__pyx_v_y_off > 0);
          __pyx_t_14 = __pyx_t_15;
          __pyx_L18_bool_binop_done:;
          if (__pyx_t_14) {
/* … */
            goto __pyx_L17;
          }
+814:                             SLR_pairs[SLR_index, 1, 0] = x
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_16 = 1;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+815:                             SLR_pairs[SLR_index, 1, 1] = y
            __pyx_t_17 = __pyx_v_SLR_index;
            __pyx_t_16 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 816: 
+817:                             SLR_pairs[SLR_index, 0, 0] = x_p
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_16 = 0;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+818:                             SLR_pairs[SLR_index, 0, 1] = y_p
            __pyx_t_17 = __pyx_v_SLR_index;
            __pyx_t_16 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 819: 
 820: 
 821:                         else:
+822:                             SLR_pairs[SLR_index, 0, 0] = x
          /*else*/ {
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_16 = 0;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x;
+823:                             SLR_pairs[SLR_index, 0, 1] = y
            __pyx_t_17 = __pyx_v_SLR_index;
            __pyx_t_16 = 0;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y;
 824: 
+825:                             SLR_pairs[SLR_index, 1, 0] = x_p
            __pyx_t_1 = __pyx_v_SLR_index;
            __pyx_t_16 = 1;
            __pyx_t_17 = 0;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+826:                             SLR_pairs[SLR_index, 1, 1] = y_p
            __pyx_t_17 = __pyx_v_SLR_index;
            __pyx_t_16 = 1;
            __pyx_t_1 = 1;
            *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SLR_pairs.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_SLR_pairs.diminfo[0].strides, __pyx_t_16, __pyx_pybuffernd_SLR_pairs.diminfo[1].strides, __pyx_t_1, __pyx_pybuffernd_SLR_pairs.diminfo[2].strides) = __pyx_v_y_p;
          }
          __pyx_L17:;
 827: 
+828:                         SLR_index = SLR_index+1
          __pyx_v_SLR_index = (__pyx_v_SLR_index + 1);
        }
        __pyx_L7:;
        __pyx_L5_continue:;
      }
    }
 829: 
+830:         return (LR_pairs[0:LR_index], SLR_pairs[0:SLR_index])
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = __Pyx_PyLong_From_int(__pyx_v_LR_index); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_7, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_LR_pairs), __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_SLR_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PySlice_New(__pyx_mstate_global->__pyx_int_0, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_SLR_pairs), __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_7);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7) != (0)) __PYX_ERR(0, 830, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_2);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 830, __pyx_L1_error);
    __pyx_t_7 = 0;
    __pyx_t_2 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;
 831: 
 832:     else:
+833:         raise InnerLoopException('Invalid LR option passed')
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_InnerLoopException); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 833, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Invalid_LR_option_passed};
      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 833, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __PYX_ERR(0, 833, __pyx_L1_error)
    break;
  }
 834: 
 835: ##
 836: #################################################################################################
 837: ##
+838: @cython.boundscheck(False)
/* Python wrapper */
static PyObject *__pyx_pw_5pimms_11inner_loops_11extract_SR_pairs_from_position_2D(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*/
PyDoc_STRVAR(__pyx_doc_5pimms_11inner_loops_10extract_SR_pairs_from_position_2D, "\n    Returns the non-redundant set of pairs associated with the 2D position defined\n    by the position array and all possible short-range interaction sites. Returned\n    positions are sorted with the largest chain location first, where 'largest'\n    is defined as comparing x and x and then y and y. \n    \n    ");
static PyMethodDef __pyx_mdef_5pimms_11inner_loops_11extract_SR_pairs_from_position_2D = {"extract_SR_pairs_from_position_2D", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_5pimms_11inner_loops_11extract_SR_pairs_from_position_2D, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_5pimms_11inner_loops_10extract_SR_pairs_from_position_2D};
static PyObject *__pyx_pw_5pimms_11inner_loops_11extract_SR_pairs_from_position_2D(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_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_XDIM;
  int __pyx_v_YDIM;
  #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("extract_SR_pairs_from_position_2D (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __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 ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_position,&__pyx_mstate_global->__pyx_n_u_XDIM,&__pyx_mstate_global->__pyx_n_u_YDIM,0};
  PyObject* values[3] = {0,0,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 838, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 838, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 838, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 838, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "extract_SR_pairs_from_position_2D", 0) < (0)) __PYX_ERR(0, 838, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("extract_SR_pairs_from_position_2D", 1, 3, 3, i); __PYX_ERR(0, 838, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 838, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 838, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 838, __pyx_L3_error)
    }
    __pyx_v_position = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_position.memview)) __PYX_ERR(0, 840, __pyx_L3_error)
    __pyx_v_XDIM = __Pyx_PyLong_As_int(values[1]); if (unlikely((__pyx_v_XDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 841, __pyx_L3_error)
    __pyx_v_YDIM = __Pyx_PyLong_As_int(values[2]); if (unlikely((__pyx_v_YDIM == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 842, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_SR_pairs_from_position_2D", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 838, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_position, 1);
  __Pyx_AddTraceback("pimms.inner_loops.extract_SR_pairs_from_position_2D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_5pimms_11inner_loops_10extract_SR_pairs_from_position_2D(__pyx_self, __pyx_v_position, __pyx_v_XDIM, __pyx_v_YDIM);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

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

static PyObject *__pyx_pf_5pimms_11inner_loops_10extract_SR_pairs_from_position_2D(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_position, int __pyx_v_XDIM, int __pyx_v_YDIM) {
  int __pyx_v_SR_index;
  int __pyx_v_x_off;
  int __pyx_v_y_off;
  int __pyx_v_x_p;
  int __pyx_v_y_p;
  PyArrayObject *__pyx_v_SR_pairs = 0;
  int __pyx_v_x;
  int __pyx_v_y;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_SR_pairs;
  __Pyx_Buffer __pyx_pybuffer_SR_pairs;
  PyObject *__pyx_r = NULL;
  __pyx_pybuffer_SR_pairs.pybuffer.buf = NULL;
  __pyx_pybuffer_SR_pairs.refcount = 0;
  __pyx_pybuffernd_SR_pairs.data = NULL;
  __pyx_pybuffernd_SR_pairs.rcbuffer = &__pyx_pybuffer_SR_pairs;
/* … */
  /* 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_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("pimms.inner_loops.extract_SR_pairs_from_position_2D", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_SR_pairs);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_5pimms_11inner_loops_11extract_SR_pairs_from_position_2D, 0, __pyx_mstate_global->__pyx_n_u_extract_SR_pairs_from_position_2, NULL, __pyx_mstate_global->__pyx_n_u_pimms_inner_loops, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_extract_SR_pairs_from_position_2, __pyx_t_4) < (0)) __PYX_ERR(0, 838, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 839: @cython.wraparound(False)
 840: def extract_SR_pairs_from_position_2D(NUMPY_INT_TYPE[:] position,
 841:                                       int XDIM,
 842:                                       int YDIM):
 843:     """
 844:     Returns the non-redundant set of pairs associated with the 2D position defined
 845:     by the position array and all possible short-range interaction sites. Returned
 846:     positions are sorted with the largest chain location first, where 'largest'
 847:     is defined as comparing x and x and then y and y.
 848: 
 849:     """
 850: 
 851:     # declare some variables
 852:     cdef int SR_index, x_off, y_off
 853:     cdef int x_p, y_p
+854:     cdef cnp.ndarray[NUMPY_INT_TYPE, ndim=3] SR_pairs = np.zeros((8,2,2), dtype=NUMPY_INT_TYPE_PYTHON)
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NUMPY_INT_TYPE_PYTHON); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_mstate_global->__pyx_tuple[4]};
    __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 854, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_dtype, __pyx_t_3, __pyx_t_6, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 854, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 854, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 854, __pyx_L1_error)
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_SR_pairs = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 854, __pyx_L1_error)
    } else {__pyx_pybuffernd_SR_pairs.diminfo[0].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_SR_pairs.diminfo[0].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_SR_pairs.diminfo[1].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_SR_pairs.diminfo[1].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_SR_pairs.diminfo[2].strides = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_SR_pairs.diminfo[2].shape = __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_v_SR_pairs = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 855: 
 856:     # first set the central x, y and z positions
+857:     cdef int x = position[0]
  __pyx_t_7 = 0;
  __pyx_v_x = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
+858:     cdef int y = position[1]
  __pyx_t_7 = 1;
  __pyx_v_y = (*((__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *) ( /* dim=0 */ (__pyx_v_position.data + __pyx_t_7 * __pyx_v_position.strides[0]) )));
 859: 
+860:     SR_index = 0
  __pyx_v_SR_index = 0;
+861:     for x_off in xrange(-1,2):
  for (__pyx_t_8 = -1; __pyx_t_8 < 2; __pyx_t_8+=1) {
    __pyx_v_x_off = __pyx_t_8;
+862:         for y_off in xrange(-1,2):
    for (__pyx_t_9 = -1; __pyx_t_9 < 2; __pyx_t_9+=1) {
      __pyx_v_y_off = __pyx_t_9;
+863:             if x_off == 0 and y_off == 0:
      __pyx_t_11 = (__pyx_v_x_off == 0);
      if (__pyx_t_11) {
      } else {
        __pyx_t_10 = __pyx_t_11;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_11 = (__pyx_v_y_off == 0);
      __pyx_t_10 = __pyx_t_11;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_10) {
/* … */
      }
+864:                 continue
        goto __pyx_L5_continue;
 865: 
+866:             x_p = pbc_correction(x + x_off, XDIM)
      __pyx_t_12 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_x + __pyx_v_x_off), __pyx_v_XDIM); if (unlikely(__pyx_t_12 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 866, __pyx_L1_error)
      __pyx_v_x_p = __pyx_t_12;
+867:             y_p = pbc_correction(y + y_off, YDIM)
      __pyx_t_12 = __pyx_f_5pimms_11inner_loops_pbc_correction((__pyx_v_y + __pyx_v_y_off), __pyx_v_YDIM); if (unlikely(__pyx_t_12 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 867, __pyx_L1_error)
      __pyx_v_y_p = __pyx_t_12;
 868: 
 869:             # if x_off < 0 then the non-central position must come first in the pair
+870:             if x_off > 0:
      __pyx_t_10 = (__pyx_v_x_off > 0);
      if (__pyx_t_10) {
/* … */
        goto __pyx_L10;
      }
+871:                 SR_pairs[SR_index, 1, 0] = x
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+872:                 SR_pairs[SR_index, 1, 1] = y
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 873: 
+874:                 SR_pairs[SR_index, 0, 0] = x_p
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+875:                 SR_pairs[SR_index, 0, 1] = y_p
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 876: 
 877: 
 878:             # if x_off == 0  and y_off is <0 then the non-central position must come first in the pair
+879:             elif x_off == 0 and y_off > 0:
      __pyx_t_11 = (__pyx_v_x_off == 0);
      if (__pyx_t_11) {
      } else {
        __pyx_t_10 = __pyx_t_11;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_11 = (__pyx_v_y_off > 0);
      __pyx_t_10 = __pyx_t_11;
      __pyx_L11_bool_binop_done:;
      if (__pyx_t_10) {
/* … */
        goto __pyx_L10;
      }
+880:                 SR_pairs[SR_index, 1, 0] = x
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+881:                 SR_pairs[SR_index, 1, 1] = y
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 882: 
+883:                 SR_pairs[SR_index, 0, 0] = x_p
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+884:                 SR_pairs[SR_index, 0, 1] = y_p
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
 885: 
 886:             else:
+887:                 SR_pairs[SR_index, 0, 0] = x
      /*else*/ {
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x;
+888:                 SR_pairs[SR_index, 0, 1] = y
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 0;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y;
 889: 
+890:                 SR_pairs[SR_index, 1, 0] = x_p
        __pyx_t_7 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_14 = 0;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_x_p;
+891:                 SR_pairs[SR_index, 1, 1] = y_p
        __pyx_t_14 = __pyx_v_SR_index;
        __pyx_t_13 = 1;
        __pyx_t_7 = 1;
        *__Pyx_BufPtrStrided3d(__pyx_t_5pimms_13cython_config_NUMPY_INT_TYPE *, __pyx_pybuffernd_SR_pairs.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_SR_pairs.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_SR_pairs.diminfo[1].strides, __pyx_t_7, __pyx_pybuffernd_SR_pairs.diminfo[2].strides) = __pyx_v_y_p;
      }
      __pyx_L10:;
 892: 
+893:             SR_index = SR_index+1
      __pyx_v_SR_index = (__pyx_v_SR_index + 1);
      __pyx_L5_continue:;
    }
  }
 894: 
+895:     return (SR_pairs)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF((PyObject *)__pyx_v_SR_pairs);
  __pyx_r = ((PyObject *)__pyx_v_SR_pairs);
  goto __pyx_L0;
 896: 
 897: 
 898: 
 899: 
+900: @cython.cdivision(True)
static int __pyx_f_5pimms_11inner_loops_pbc_correction(int __pyx_v_value, int __pyx_v_DIM) {
  int __pyx_r;
 901: cdef int pbc_correction(int value, int DIM):
 902:     """
 903:     Performs intelligent periodic boundary correction
 904:     which FIRST checks to see if we have a negative
 905:     value and IF NOT uses the % operator - this means
 906:     we can use % without checking the sign giving
 907:     a 35% speedup per call
 908:     """
 909: 
+910:     if value < 0:
  __pyx_t_1 = (__pyx_v_value < 0);
  if (__pyx_t_1) {
/* … */
  }
+911:         return DIM+value
    __pyx_r = (__pyx_v_DIM + __pyx_v_value);
    goto __pyx_L0;
 912:     else:
+913:         return (value % DIM)
  /*else*/ {
    __pyx_r = (__pyx_v_value % __pyx_v_DIM);
    goto __pyx_L0;
  }