/* Generated by Pyrex 0.9.9 on Thu Dec 16 15:34:50 2010 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#include "arrayobject.h"
#include "stdlib.h"
#include "math.h"
#include "stdio.h"


typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/

static PyObject *__pyx_m;
static PyObject *__pyx_b;
static int __pyx_lineno;
static char *__pyx_filename;
static char **__pyx_f;

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/

static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size);  /*proto*/

static PyObject *__Pyx_ImportModule(char *name); /*proto*/

static void __Pyx_AddTraceback(char *funcname); /*proto*/

/* Declarations from hbond_detection_pyrex */


/* Declarations from implementation of hbond_detection_pyrex */

typedef int __pyx_t_21hbond_detection_pyrex_size_t;

static PyTypeObject *__pyx_ptype_21hbond_detection_pyrex_array_type = 0;




static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {0, 0, 0, 0}
};



/* Implementation of hbond_detection_pyrex */

static PyObject *__pyx_f_21hbond_detection_pyrex_hbond_detection_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_21hbond_detection_pyrex_hbond_detection_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_configuration = 0;
  PyArrayObject *__pyx_v_directCell = 0;
  PyArrayObject *__pyx_v_reverseCell = 0;
  PyArrayObject *__pyx_v_acc_indexes = 0;
  PyArrayObject *__pyx_v_don_indexes = 0;
  PyArrayObject *__pyx_v_h_indexes = 0;
  PyArrayObject *__pyx_v_hbond_matrix = 0;
  double __pyx_v_dis_min;
  double __pyx_v_dis_max;
  double __pyx_v_ang_min;
  double __pyx_v_ang_max;
  int *__pyx_v_acc_idx;
  int *__pyx_v_don_idx;
  int *__pyx_v_h_idx;
  double *__pyx_v_config;
  double *__pyx_v_cell;
  double *__pyx_v_rcell;
  double *__pyx_v_scfg_acc;
  double *__pyx_v_scfg_don;
  double *__pyx_v_scfg_h;
  float *__pyx_v_hbond_mat;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_ind;
  double __pyx_v_rx;
  double __pyx_v_ry;
  double __pyx_v_rz;
  double __pyx_v_r1;
  double __pyx_v_cosa;
  double __pyx_v_angle;
  double __pyx_v_x_acc;
  double __pyx_v_y_acc;
  double __pyx_v_z_acc;
  double __pyx_v_s_x_acc;
  double __pyx_v_s_y_acc;
  double __pyx_v_s_z_acc;
  double __pyx_v_x_don;
  double __pyx_v_y_don;
  double __pyx_v_z_don;
  double __pyx_v_s_x_don;
  double __pyx_v_s_y_don;
  double __pyx_v_s_z_don;
  double __pyx_v_x_h;
  double __pyx_v_y_h;
  double __pyx_v_z_h;
  double __pyx_v_s_x_h;
  double __pyx_v_s_y_h;
  double __pyx_v_s_z_h;
  double __pyx_v_dx;
  double __pyx_v_dy;
  double __pyx_v_dz;
  double __pyx_v_dx1;
  double __pyx_v_dy1;
  double __pyx_v_dz1;
  PyObject *__pyx_v_r;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  double __pyx_6;
  static char *__pyx_argnames[] = {"configuration","directCell","reverseCell","acc_indexes","don_indexes","h_indexes","hbond_matrix","dis_min","dis_max","ang_min","ang_max",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOOOdddd", __pyx_argnames, &__pyx_v_configuration, &__pyx_v_directCell, &__pyx_v_reverseCell, &__pyx_v_acc_indexes, &__pyx_v_don_indexes, &__pyx_v_h_indexes, &__pyx_v_hbond_matrix, &__pyx_v_dis_min, &__pyx_v_dis_max, &__pyx_v_ang_min, &__pyx_v_ang_max)) return 0;
  Py_INCREF(__pyx_v_configuration);
  Py_INCREF(__pyx_v_directCell);
  Py_INCREF(__pyx_v_reverseCell);
  Py_INCREF(__pyx_v_acc_indexes);
  Py_INCREF(__pyx_v_don_indexes);
  Py_INCREF(__pyx_v_h_indexes);
  Py_INCREF(__pyx_v_hbond_matrix);
  __pyx_v_r = Py_None; Py_INCREF(Py_None);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_configuration), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "configuration")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_directCell), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "directCell")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reverseCell), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "reverseCell")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_acc_indexes), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "acc_indexes")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_don_indexes), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "don_indexes")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_h_indexes), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "h_indexes")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hbond_matrix), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "hbond_matrix")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;}

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":52 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_configuration->nd == 2)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":53 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_directCell->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":54 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_reverseCell->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":55 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_acc_indexes->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":56 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_don_indexes->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":57 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_h_indexes->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":58 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!((__pyx_v_don_indexes->dimensions[0]) == (__pyx_v_h_indexes->dimensions[0]))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":59 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_hbond_matrix->nd == 2)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":62 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_configuration->descr->type_num == PyArray_DOUBLE)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":63 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_directCell->descr->type_num == PyArray_DOUBLE)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":64 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_reverseCell->descr->type_num == PyArray_DOUBLE)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":65 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (__pyx_v_acc_indexes->descr->type_num == PyArray_INT);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_acc_indexes->descr->type_num == PyArray_LONG);
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_acc_indexes->descr->elsize == (sizeof(int)));
  }
  if (!__pyx_1) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":67 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (__pyx_v_don_indexes->descr->type_num == PyArray_INT);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_don_indexes->descr->type_num == PyArray_LONG);
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_don_indexes->descr->elsize == (sizeof(int)));
  }
  if (!__pyx_1) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":69 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (__pyx_v_h_indexes->descr->type_num == PyArray_INT);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_h_indexes->descr->type_num == PyArray_LONG);
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_h_indexes->descr->elsize == (sizeof(int)));
  }
  if (!__pyx_1) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":71 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_hbond_matrix->descr->type_num == PyArray_FLOAT)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":74 */
  __pyx_v_config = ((double *)__pyx_v_configuration->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":75 */
  __pyx_v_cell = ((double *)__pyx_v_directCell->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":76 */
  __pyx_v_rcell = ((double *)__pyx_v_reverseCell->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":77 */
  __pyx_v_acc_idx = ((int *)__pyx_v_acc_indexes->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":78 */
  __pyx_v_don_idx = ((int *)__pyx_v_don_indexes->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":79 */
  __pyx_v_h_idx = ((int *)__pyx_v_h_indexes->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":80 */
  __pyx_v_hbond_mat = ((float *)__pyx_v_hbond_matrix->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":83 */
  __pyx_v_scfg_acc = ((double *)malloc(((3 * (__pyx_v_acc_indexes->dimensions[0])) * (sizeof(double)))));

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":86 */
  __pyx_v_scfg_don = ((double *)malloc(((3 * (__pyx_v_don_indexes->dimensions[0])) * (sizeof(double)))));

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":89 */
  __pyx_v_scfg_h = ((double *)malloc(((3 * (__pyx_v_h_indexes->dimensions[0])) * (sizeof(double)))));

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":92 */
  __pyx_1 = (__pyx_v_acc_indexes->dimensions[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":94 */
    __pyx_v_ind = (3 * (__pyx_v_acc_idx[__pyx_v_i]));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":97 */
    __pyx_v_x_acc = (__pyx_v_config[__pyx_v_ind]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":98 */
    __pyx_v_y_acc = (__pyx_v_config[(__pyx_v_ind + 1)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":99 */
    __pyx_v_z_acc = (__pyx_v_config[(__pyx_v_ind + 2)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":101 */
    __pyx_v_ind = (3 * __pyx_v_i);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":104 */
    (__pyx_v_scfg_acc[__pyx_v_ind]) = (((__pyx_v_x_acc * (__pyx_v_rcell[0])) + (__pyx_v_y_acc * (__pyx_v_rcell[3]))) + (__pyx_v_z_acc * (__pyx_v_rcell[6])));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":105 */
    (__pyx_v_scfg_acc[(__pyx_v_ind + 1)]) = (((__pyx_v_x_acc * (__pyx_v_rcell[1])) + (__pyx_v_y_acc * (__pyx_v_rcell[4]))) + (__pyx_v_z_acc * (__pyx_v_rcell[7])));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":106 */
    (__pyx_v_scfg_acc[(__pyx_v_ind + 2)]) = (((__pyx_v_x_acc * (__pyx_v_rcell[2])) + (__pyx_v_y_acc * (__pyx_v_rcell[5]))) + (__pyx_v_z_acc * (__pyx_v_rcell[8])));
  }

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":109 */
  __pyx_1 = (__pyx_v_don_indexes->dimensions[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":111 */
    __pyx_v_ind = (3 * (__pyx_v_don_idx[__pyx_v_i]));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":114 */
    __pyx_v_x_don = (__pyx_v_config[__pyx_v_ind]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":115 */
    __pyx_v_y_don = (__pyx_v_config[(__pyx_v_ind + 1)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":116 */
    __pyx_v_z_don = (__pyx_v_config[(__pyx_v_ind + 2)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":118 */
    __pyx_v_ind = (3 * __pyx_v_i);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":121 */
    (__pyx_v_scfg_don[__pyx_v_ind]) = (((__pyx_v_x_don * (__pyx_v_rcell[0])) + (__pyx_v_y_don * (__pyx_v_rcell[3]))) + (__pyx_v_z_don * (__pyx_v_rcell[6])));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":122 */
    (__pyx_v_scfg_don[(__pyx_v_ind + 1)]) = (((__pyx_v_x_don * (__pyx_v_rcell[1])) + (__pyx_v_y_don * (__pyx_v_rcell[4]))) + (__pyx_v_z_don * (__pyx_v_rcell[7])));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":123 */
    (__pyx_v_scfg_don[(__pyx_v_ind + 2)]) = (((__pyx_v_x_don * (__pyx_v_rcell[2])) + (__pyx_v_y_don * (__pyx_v_rcell[5]))) + (__pyx_v_z_don * (__pyx_v_rcell[8])));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":125 */
    __pyx_v_ind = (3 * (__pyx_v_h_idx[__pyx_v_i]));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":128 */
    __pyx_v_x_h = (__pyx_v_config[__pyx_v_ind]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":129 */
    __pyx_v_y_h = (__pyx_v_config[(__pyx_v_ind + 1)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":130 */
    __pyx_v_z_h = (__pyx_v_config[(__pyx_v_ind + 2)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":132 */
    __pyx_v_ind = (3 * __pyx_v_i);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":135 */
    (__pyx_v_scfg_h[__pyx_v_ind]) = (((__pyx_v_x_h * (__pyx_v_rcell[0])) + (__pyx_v_y_h * (__pyx_v_rcell[3]))) + (__pyx_v_z_h * (__pyx_v_rcell[6])));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":136 */
    (__pyx_v_scfg_h[(__pyx_v_ind + 1)]) = (((__pyx_v_x_h * (__pyx_v_rcell[1])) + (__pyx_v_y_h * (__pyx_v_rcell[4]))) + (__pyx_v_z_h * (__pyx_v_rcell[7])));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":137 */
    (__pyx_v_scfg_h[(__pyx_v_ind + 2)]) = (((__pyx_v_x_h * (__pyx_v_rcell[2])) + (__pyx_v_y_h * (__pyx_v_rcell[5]))) + (__pyx_v_z_h * (__pyx_v_rcell[8])));
  }

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":140 */
  __pyx_1 = (__pyx_v_acc_indexes->dimensions[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":142 */
    __pyx_v_ind = (3 * (__pyx_v_acc_idx[__pyx_v_i]));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":145 */
    __pyx_v_x_acc = (__pyx_v_config[__pyx_v_ind]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":146 */
    __pyx_v_y_acc = (__pyx_v_config[(__pyx_v_ind + 1)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":147 */
    __pyx_v_z_acc = (__pyx_v_config[(__pyx_v_ind + 2)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":149 */
    __pyx_v_ind = (3 * __pyx_v_i);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":152 */
    __pyx_v_s_x_acc = (__pyx_v_scfg_acc[__pyx_v_ind]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":153 */
    __pyx_v_s_y_acc = (__pyx_v_scfg_acc[(__pyx_v_ind + 1)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":154 */
    __pyx_v_s_z_acc = (__pyx_v_scfg_acc[(__pyx_v_ind + 2)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":156 */
    __pyx_2 = (__pyx_v_don_indexes->dimensions[0]);
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_2; ++__pyx_v_j) {

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":158 */
      __pyx_v_ind = (3 * __pyx_v_j);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":161 */
      __pyx_v_s_x_don = (__pyx_v_scfg_don[__pyx_v_ind]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":162 */
      __pyx_v_s_y_don = (__pyx_v_scfg_don[(__pyx_v_ind + 1)]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":163 */
      __pyx_v_s_z_don = (__pyx_v_scfg_don[(__pyx_v_ind + 2)]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":166 */
      __pyx_v_dx = (__pyx_v_s_x_don - __pyx_v_s_x_acc);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":167 */
      __pyx_v_dy = (__pyx_v_s_y_don - __pyx_v_s_y_acc);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":168 */
      __pyx_v_dz = (__pyx_v_s_z_don - __pyx_v_s_z_acc);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":171 */
      __pyx_v_dx -= round(__pyx_v_dx);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":172 */
      __pyx_v_dy -= round(__pyx_v_dy);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":173 */
      __pyx_v_dz -= round(__pyx_v_dz);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":176 */
      __pyx_v_rx = (((__pyx_v_dx * (__pyx_v_cell[0])) + (__pyx_v_dy * (__pyx_v_cell[3]))) + (__pyx_v_dz * (__pyx_v_cell[6])));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":177 */
      __pyx_v_ry = (((__pyx_v_dx * (__pyx_v_cell[1])) + (__pyx_v_dy * (__pyx_v_cell[4]))) + (__pyx_v_dz * (__pyx_v_cell[7])));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":178 */
      __pyx_v_rz = (((__pyx_v_dx * (__pyx_v_cell[2])) + (__pyx_v_dy * (__pyx_v_cell[5]))) + (__pyx_v_dz * (__pyx_v_cell[8])));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":179 */
      __pyx_3 = PyFloat_FromDouble(sqrt((((__pyx_v_rx * __pyx_v_rx) + (__pyx_v_ry * __pyx_v_ry)) + (__pyx_v_rz * __pyx_v_rz)))); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;}
      Py_DECREF(__pyx_v_r);
      __pyx_v_r = __pyx_3;
      __pyx_3 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":182 */
      __pyx_3 = PyFloat_FromDouble(__pyx_v_dis_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
      if (PyObject_Cmp(__pyx_v_r, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
      __pyx_4 = __pyx_4 < 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      if (!__pyx_4) {
        __pyx_3 = PyFloat_FromDouble(__pyx_v_dis_max); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
        if (PyObject_Cmp(__pyx_v_r, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
        __pyx_4 = __pyx_4 > 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
      }
      if (__pyx_4) {
        goto __pyx_L8;
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":185 */
      __pyx_v_s_x_don = (__pyx_v_s_x_acc + __pyx_v_dx);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":186 */
      __pyx_v_s_y_don = (__pyx_v_s_y_acc + __pyx_v_dy);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":187 */
      __pyx_v_s_z_don = (__pyx_v_s_z_acc + __pyx_v_dz);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":190 */
      __pyx_v_x_don = (((__pyx_v_s_x_don * (__pyx_v_cell[0])) + (__pyx_v_s_y_don * (__pyx_v_cell[3]))) + (__pyx_v_s_z_don * (__pyx_v_cell[6])));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":191 */
      __pyx_v_y_don = (((__pyx_v_s_x_don * (__pyx_v_cell[1])) + (__pyx_v_s_y_don * (__pyx_v_cell[4]))) + (__pyx_v_s_z_don * (__pyx_v_cell[7])));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":192 */
      __pyx_v_z_don = (((__pyx_v_s_x_don * (__pyx_v_cell[2])) + (__pyx_v_s_y_don * (__pyx_v_cell[5]))) + (__pyx_v_s_z_don * (__pyx_v_cell[8])));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":195 */
      __pyx_v_s_x_h = (__pyx_v_scfg_h[__pyx_v_ind]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":196 */
      __pyx_v_s_y_h = (__pyx_v_scfg_h[(__pyx_v_ind + 1)]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":197 */
      __pyx_v_s_z_h = (__pyx_v_scfg_h[(__pyx_v_ind + 2)]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":200 */
      __pyx_v_dx = (__pyx_v_s_x_h - __pyx_v_s_x_acc);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":201 */
      __pyx_v_dy = (__pyx_v_s_y_h - __pyx_v_s_y_acc);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":202 */
      __pyx_v_dz = (__pyx_v_s_z_h - __pyx_v_s_z_acc);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":205 */
      __pyx_v_s_x_h -= round(__pyx_v_dx);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":206 */
      __pyx_v_s_y_h -= round(__pyx_v_dy);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":207 */
      __pyx_v_s_z_h -= round(__pyx_v_dz);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":210 */
      __pyx_v_x_h = (((__pyx_v_s_x_h * (__pyx_v_cell[0])) + (__pyx_v_s_y_h * (__pyx_v_cell[3]))) + (__pyx_v_s_z_h * (__pyx_v_cell[6])));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":211 */
      __pyx_v_y_h = (((__pyx_v_s_x_h * (__pyx_v_cell[1])) + (__pyx_v_s_y_h * (__pyx_v_cell[4]))) + (__pyx_v_s_z_h * (__pyx_v_cell[7])));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":212 */
      __pyx_v_z_h = (((__pyx_v_s_x_h * (__pyx_v_cell[2])) + (__pyx_v_s_y_h * (__pyx_v_cell[5]))) + (__pyx_v_s_z_h * (__pyx_v_cell[8])));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":215 */
      __pyx_v_dx = (__pyx_v_x_acc - __pyx_v_x_h);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":216 */
      __pyx_v_dy = (__pyx_v_y_acc - __pyx_v_y_h);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":217 */
      __pyx_v_dz = (__pyx_v_z_acc - __pyx_v_z_h);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":220 */
      __pyx_3 = PyFloat_FromDouble((((__pyx_v_dx * __pyx_v_dx) + (__pyx_v_dy * __pyx_v_dy)) + (__pyx_v_dz * __pyx_v_dz))); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; goto __pyx_L1;}
      Py_DECREF(__pyx_v_r);
      __pyx_v_r = __pyx_3;
      __pyx_3 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":223 */
      __pyx_v_dx1 = (__pyx_v_x_don - __pyx_v_x_h);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":224 */
      __pyx_v_dy1 = (__pyx_v_y_don - __pyx_v_y_h);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":225 */
      __pyx_v_dz1 = (__pyx_v_z_don - __pyx_v_z_h);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":228 */
      __pyx_v_r1 = (((__pyx_v_dx1 * __pyx_v_dx1) + (__pyx_v_dy1 * __pyx_v_dy1)) + (__pyx_v_dz1 * __pyx_v_dz1));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":231 */
      __pyx_v_cosa = (((__pyx_v_dx * __pyx_v_dx1) + (__pyx_v_dy * __pyx_v_dy1)) + (__pyx_v_dz * __pyx_v_dz1));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":232 */
      __pyx_3 = PyFloat_FromDouble(__pyx_v_r1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}
      __pyx_5 = PyNumber_Multiply(__pyx_v_r, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_v_cosa /= sqrt(__pyx_6);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":233 */
      __pyx_v_cosa = fmax((-1.0),fmin(1.,__pyx_v_cosa));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":236 */
      __pyx_v_angle = acos(__pyx_v_cosa);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":239 */
      __pyx_4 = (__pyx_v_angle < __pyx_v_ang_min);
      if (!__pyx_4) {
        __pyx_4 = (__pyx_v_angle > __pyx_v_ang_max);
      }
      if (__pyx_4) {
        goto __pyx_L8;
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":241 */
      __pyx_v_ind = (__pyx_v_j + (__pyx_v_i * (__pyx_v_hbond_matrix->dimensions[1])));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":244 */
      (__pyx_v_hbond_mat[__pyx_v_ind]) = 1.0;
      __pyx_L8:;
    }
  }

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":246 */
  free(__pyx_v_scfg_don);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":247 */
  free(__pyx_v_scfg_acc);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":248 */
  free(__pyx_v_scfg_h);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("hbond_detection_pyrex.hbond_detection_c");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_r);
  Py_DECREF(__pyx_v_configuration);
  Py_DECREF(__pyx_v_directCell);
  Py_DECREF(__pyx_v_reverseCell);
  Py_DECREF(__pyx_v_acc_indexes);
  Py_DECREF(__pyx_v_don_indexes);
  Py_DECREF(__pyx_v_h_indexes);
  Py_DECREF(__pyx_v_hbond_matrix);
  return __pyx_r;
}

static PyObject *__pyx_f_21hbond_detection_pyrex_hbond_detection_no_PBC(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_21hbond_detection_pyrex_hbond_detection_no_PBC(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_configuration = 0;
  PyArrayObject *__pyx_v_acc_indexes = 0;
  PyArrayObject *__pyx_v_don_indexes = 0;
  PyArrayObject *__pyx_v_h_indexes = 0;
  PyArrayObject *__pyx_v_hbond_matrix = 0;
  double __pyx_v_dis_min;
  double __pyx_v_dis_max;
  double __pyx_v_ang_min;
  double __pyx_v_ang_max;
  int *__pyx_v_acc_idx;
  int *__pyx_v_don_idx;
  int *__pyx_v_h_idx;
  double *__pyx_v_config;
  float *__pyx_v_hbond_mat;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_ind;
  double __pyx_v_r1;
  double __pyx_v_cosa;
  double __pyx_v_angle;
  double __pyx_v_x_acc;
  double __pyx_v_y_acc;
  double __pyx_v_z_acc;
  double __pyx_v_x_don;
  double __pyx_v_y_don;
  double __pyx_v_z_don;
  double __pyx_v_x_h;
  double __pyx_v_y_h;
  double __pyx_v_z_h;
  PyObject *__pyx_v_dx;
  PyObject *__pyx_v_dy;
  PyObject *__pyx_v_dz;
  PyObject *__pyx_v_r;
  PyObject *__pyx_v_dx1;
  PyObject *__pyx_v_dy1;
  PyObject *__pyx_v_dz1;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  double __pyx_6;
  int __pyx_7;
  static char *__pyx_argnames[] = {"configuration","acc_indexes","don_indexes","h_indexes","hbond_matrix","dis_min","dis_max","ang_min","ang_max",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOdddd", __pyx_argnames, &__pyx_v_configuration, &__pyx_v_acc_indexes, &__pyx_v_don_indexes, &__pyx_v_h_indexes, &__pyx_v_hbond_matrix, &__pyx_v_dis_min, &__pyx_v_dis_max, &__pyx_v_ang_min, &__pyx_v_ang_max)) return 0;
  Py_INCREF(__pyx_v_configuration);
  Py_INCREF(__pyx_v_acc_indexes);
  Py_INCREF(__pyx_v_don_indexes);
  Py_INCREF(__pyx_v_h_indexes);
  Py_INCREF(__pyx_v_hbond_matrix);
  __pyx_v_dx = Py_None; Py_INCREF(Py_None);
  __pyx_v_dy = Py_None; Py_INCREF(Py_None);
  __pyx_v_dz = Py_None; Py_INCREF(Py_None);
  __pyx_v_r = Py_None; Py_INCREF(Py_None);
  __pyx_v_dx1 = Py_None; Py_INCREF(Py_None);
  __pyx_v_dy1 = Py_None; Py_INCREF(Py_None);
  __pyx_v_dz1 = Py_None; Py_INCREF(Py_None);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_configuration), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "configuration")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_acc_indexes), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "acc_indexes")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_don_indexes), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "don_indexes")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_h_indexes), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "h_indexes")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hbond_matrix), __pyx_ptype_21hbond_detection_pyrex_array_type, 1, "hbond_matrix")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":272 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_configuration->nd == 2)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":273 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_acc_indexes->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":274 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_don_indexes->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":275 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_h_indexes->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":276 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_hbond_matrix->nd == 2)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":279 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_configuration->descr->type_num == PyArray_DOUBLE)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":280 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (__pyx_v_acc_indexes->descr->type_num == PyArray_INT);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_acc_indexes->descr->type_num == PyArray_LONG);
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_acc_indexes->descr->elsize == (sizeof(int)));
  }
  if (!__pyx_1) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":282 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (__pyx_v_don_indexes->descr->type_num == PyArray_INT);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_don_indexes->descr->type_num == PyArray_LONG);
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_don_indexes->descr->elsize == (sizeof(int)));
  }
  if (!__pyx_1) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":284 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (__pyx_v_h_indexes->descr->type_num == PyArray_INT);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_h_indexes->descr->type_num == PyArray_LONG);
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_h_indexes->descr->elsize == (sizeof(int)));
  }
  if (!__pyx_1) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":286 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_hbond_matrix->descr->type_num == PyArray_FLOAT)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":289 */
  __pyx_v_config = ((double *)__pyx_v_configuration->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":290 */
  __pyx_v_acc_idx = ((int *)__pyx_v_acc_indexes->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":291 */
  __pyx_v_don_idx = ((int *)__pyx_v_don_indexes->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":292 */
  __pyx_v_h_idx = ((int *)__pyx_v_h_indexes->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":293 */
  __pyx_v_hbond_mat = ((float *)__pyx_v_hbond_matrix->data);

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":296 */
  __pyx_1 = (__pyx_v_acc_indexes->dimensions[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":298 */
    __pyx_v_ind = (3 * (__pyx_v_acc_idx[__pyx_v_i]));

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":301 */
    __pyx_v_x_acc = (__pyx_v_config[__pyx_v_ind]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":302 */
    __pyx_v_y_acc = (__pyx_v_config[(__pyx_v_ind + 1)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":303 */
    __pyx_v_z_acc = (__pyx_v_config[(__pyx_v_ind + 2)]);

    /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":306 */
    __pyx_2 = (__pyx_v_don_indexes->dimensions[0]);
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_2; ++__pyx_v_j) {

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":308 */
      __pyx_v_ind = (3 * (__pyx_v_don_idx[__pyx_v_j]));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":311 */
      __pyx_v_x_don = (__pyx_v_config[__pyx_v_ind]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":312 */
      __pyx_v_y_don = (__pyx_v_config[(__pyx_v_ind + 1)]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":313 */
      __pyx_v_z_don = (__pyx_v_config[(__pyx_v_ind + 2)]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":316 */
      __pyx_3 = PyFloat_FromDouble((__pyx_v_x_don - __pyx_v_x_acc)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}
      Py_DECREF(__pyx_v_dx);
      __pyx_v_dx = __pyx_3;
      __pyx_3 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":317 */
      __pyx_3 = PyFloat_FromDouble((__pyx_v_y_don - __pyx_v_y_acc)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}
      Py_DECREF(__pyx_v_dy);
      __pyx_v_dy = __pyx_3;
      __pyx_3 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":318 */
      __pyx_3 = PyFloat_FromDouble((__pyx_v_z_don - __pyx_v_z_acc)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
      Py_DECREF(__pyx_v_dz);
      __pyx_v_dz = __pyx_3;
      __pyx_3 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":321 */
      __pyx_3 = PyNumber_Multiply(__pyx_v_dx, __pyx_v_dx); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;}
      __pyx_4 = PyNumber_Multiply(__pyx_v_dy, __pyx_v_dy); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;}
      __pyx_5 = PyNumber_Add(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_3 = PyNumber_Multiply(__pyx_v_dz, __pyx_v_dz); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;}
      __pyx_4 = PyNumber_Add(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_5 = PyFloat_FromDouble(sqrt(__pyx_6)); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;}
      Py_DECREF(__pyx_v_r);
      __pyx_v_r = __pyx_5;
      __pyx_5 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":324 */
      __pyx_3 = PyFloat_FromDouble(__pyx_v_dis_min); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
      if (PyObject_Cmp(__pyx_v_r, __pyx_3, &__pyx_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
      __pyx_7 = __pyx_7 < 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      if (!__pyx_7) {
        __pyx_4 = PyFloat_FromDouble(__pyx_v_dis_max); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
        if (PyObject_Cmp(__pyx_v_r, __pyx_4, &__pyx_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
        __pyx_7 = __pyx_7 > 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
      }
      if (__pyx_7) {
        goto __pyx_L4;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":326 */
      __pyx_v_ind = (3 * (__pyx_v_h_idx[__pyx_v_j]));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":329 */
      __pyx_v_x_h = (__pyx_v_config[__pyx_v_ind]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":330 */
      __pyx_v_y_h = (__pyx_v_config[(__pyx_v_ind + 1)]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":331 */
      __pyx_v_z_h = (__pyx_v_config[(__pyx_v_ind + 2)]);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":334 */
      __pyx_5 = PyFloat_FromDouble((__pyx_v_x_acc - __pyx_v_x_h)); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; goto __pyx_L1;}
      Py_DECREF(__pyx_v_dx);
      __pyx_v_dx = __pyx_5;
      __pyx_5 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":335 */
      __pyx_3 = PyFloat_FromDouble((__pyx_v_y_acc - __pyx_v_y_h)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
      Py_DECREF(__pyx_v_dy);
      __pyx_v_dy = __pyx_3;
      __pyx_3 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":336 */
      __pyx_4 = PyFloat_FromDouble((__pyx_v_z_acc - __pyx_v_z_h)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}
      Py_DECREF(__pyx_v_dz);
      __pyx_v_dz = __pyx_4;
      __pyx_4 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":339 */
      __pyx_5 = PyNumber_Multiply(__pyx_v_dx, __pyx_v_dx); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;}
      __pyx_3 = PyNumber_Multiply(__pyx_v_dy, __pyx_v_dy); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;}
      __pyx_4 = PyNumber_Add(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_5 = PyNumber_Multiply(__pyx_v_dz, __pyx_v_dz); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;}
      __pyx_3 = PyNumber_Add(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_v_r);
      __pyx_v_r = __pyx_3;
      __pyx_3 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":342 */
      __pyx_4 = PyFloat_FromDouble((__pyx_v_x_don - __pyx_v_x_h)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; goto __pyx_L1;}
      Py_DECREF(__pyx_v_dx1);
      __pyx_v_dx1 = __pyx_4;
      __pyx_4 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":343 */
      __pyx_5 = PyFloat_FromDouble((__pyx_v_y_don - __pyx_v_y_h)); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
      Py_DECREF(__pyx_v_dy1);
      __pyx_v_dy1 = __pyx_5;
      __pyx_5 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":344 */
      __pyx_3 = PyFloat_FromDouble((__pyx_v_z_don - __pyx_v_z_h)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;}
      Py_DECREF(__pyx_v_dz1);
      __pyx_v_dz1 = __pyx_3;
      __pyx_3 = 0;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":347 */
      __pyx_4 = PyNumber_Multiply(__pyx_v_dx1, __pyx_v_dx1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}
      __pyx_5 = PyNumber_Multiply(__pyx_v_dy1, __pyx_v_dy1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}
      __pyx_3 = PyNumber_Add(__pyx_4, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_4 = PyNumber_Multiply(__pyx_v_dz1, __pyx_v_dz1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}
      __pyx_5 = PyNumber_Add(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_v_r1 = __pyx_6;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":350 */
      __pyx_3 = PyNumber_Multiply(__pyx_v_dx, __pyx_v_dx1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
      __pyx_4 = PyNumber_Multiply(__pyx_v_dy, __pyx_v_dy1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
      __pyx_5 = PyNumber_Add(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_3 = PyNumber_Multiply(__pyx_v_dz, __pyx_v_dz1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
      __pyx_4 = PyNumber_Add(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_v_cosa = __pyx_6;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":351 */
      __pyx_5 = PyFloat_FromDouble(__pyx_v_r1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
      __pyx_3 = PyNumber_Multiply(__pyx_v_r, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_v_cosa /= sqrt(__pyx_6);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":352 */
      __pyx_v_cosa = fmax((-1.0),fmin(1.,__pyx_v_cosa));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":355 */
      __pyx_v_angle = acos(__pyx_v_cosa);

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":358 */
      __pyx_7 = (__pyx_v_angle < __pyx_v_ang_min);
      if (!__pyx_7) {
        __pyx_7 = (__pyx_v_angle > __pyx_v_ang_max);
      }
      if (__pyx_7) {
        goto __pyx_L4;
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":360 */
      __pyx_v_ind = (__pyx_v_j + (__pyx_v_i * (__pyx_v_hbond_matrix->dimensions[1])));

      /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":363 */
      (__pyx_v_hbond_mat[__pyx_v_ind]) = 1.0;
      __pyx_L4:;
    }
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("hbond_detection_pyrex.hbond_detection_no_PBC");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_dx);
  Py_DECREF(__pyx_v_dy);
  Py_DECREF(__pyx_v_dz);
  Py_DECREF(__pyx_v_r);
  Py_DECREF(__pyx_v_dx1);
  Py_DECREF(__pyx_v_dy1);
  Py_DECREF(__pyx_v_dz1);
  Py_DECREF(__pyx_v_configuration);
  Py_DECREF(__pyx_v_acc_indexes);
  Py_DECREF(__pyx_v_don_indexes);
  Py_DECREF(__pyx_v_h_indexes);
  Py_DECREF(__pyx_v_hbond_matrix);
  return __pyx_r;
}

static struct PyMethodDef __pyx_methods[] = {
  {"hbond_detection_c", (PyCFunction)__pyx_f_21hbond_detection_pyrex_hbond_detection_c, METH_VARARGS|METH_KEYWORDS, 0},
  {"hbond_detection_no_PBC", (PyCFunction)__pyx_f_21hbond_detection_pyrex_hbond_detection_no_PBC, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC inithbond_detection_pyrex(void); /*proto*/
PyMODINIT_FUNC inithbond_detection_pyrex(void) {
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("hbond_detection_pyrex", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  __pyx_ptype_21hbond_detection_pyrex_array_type = __Pyx_ImportType("Scientific.N", "array_type", sizeof(PyArrayObject)); if (!__pyx_ptype_21hbond_detection_pyrex_array_type) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; goto __pyx_L1;}

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\numeric.pxi":36 */
  import_array();

  /* "C:\Datas\Collaboration\ILL\Daniela_Russo\hbond_detection_pyrex.pyx":251 */
  return;
  __pyx_L1:;
  __Pyx_AddTraceback("hbond_detection_pyrex");
}

static char *__pyx_filenames[] = {
  "hbond_detection_pyrex.pyx",
  "numeric.pxi",
};

/* Runtime support code */

static void __pyx_init_filenames(void) {
  __pyx_f = __pyx_filenames;
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name) {
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if ((none_allowed && obj == Py_None) || PyObject_TypeCheck(obj, type))
        return 1;
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, obj->ob_type->tp_name);
    return 0;
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        if (!*t->p)
            return -1;
        if (t->i)
            PyString_InternInPlace(t->p);
        ++t;
    }
    return 0;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, 
    long size) 
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    result = PyObject_GetAttrString(py_module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError, 
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifdef __PYX_CHECK_IMPORTED_TYPES
    if (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError, 
            "%s.%s does not appear to be the correct type object",
            module_name, class_name);
        goto bad;
    }
#endif
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(char *name) {
    PyObject *py_name = 0;
    
    py_name = PyString_FromString(name);
    if (!py_name)
        goto bad;
    return PyImport_Import(py_name);
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyObject *empty_tuple = 0;
    PyObject *empty_string = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    
    py_srcfile = PyString_FromString(__pyx_filename);
    if (!py_srcfile) goto bad;
    py_funcname = PyString_FromString(funcname);
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    empty_tuple = PyTuple_New(0);
    if (!empty_tuple) goto bad;
    empty_string = PyString_FromString("");
    if (!empty_string) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        empty_string, /*PyObject *code,*/
        empty_tuple,  /*PyObject *consts,*/
        empty_tuple,  /*PyObject *names,*/
        empty_tuple,  /*PyObject *varnames,*/
        empty_tuple,  /*PyObject *freevars,*/
        empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        empty_string  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_Get(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(empty_tuple);
    Py_XDECREF(empty_string);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}
