/* Generated by Pyrex 0.9.9 on Fri Jul 30 16:19:43 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 "math.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 coordination_number_pyrex */


/* Declarations from implementation of coordination_number_pyrex */

static PyTypeObject *__pyx_ptype_25coordination_number_pyrex_array_type = 0;




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



/* Implementation of coordination_number_pyrex */

static PyObject *__pyx_f_25coordination_number_pyrex_coordination_number_pyrex(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_25coordination_number_pyrex_coordination_number_pyrex(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_gIndexes = 0;
  int __pyx_v_mol;
  PyArrayObject *__pyx_v_indexes = 0;
  PyArrayObject *__pyx_v_molecules = 0;
  PyArrayObject *__pyx_v_elements = 0;
  PyArrayObject *__pyx_v_cnIntra = 0;
  PyArrayObject *__pyx_v_cnInter = 0;
  PyArrayObject *__pyx_v_scalec = 0;
  PyArrayObject *__pyx_v_groupcenter = 0;
  double __pyx_v_rmin;
  double __pyx_v_dr;
  int *__pyx_v_atomindex;
  int *__pyx_v_molindex;
  int *__pyx_v_elementindex;
  int *__pyx_v_groupindex;
  double *__pyx_v_config;
  double *__pyx_v_cell;
  double *__pyx_v_rcell;
  double *__pyx_v_scaleconfig;
  double *__pyx_v_center;
  float *__pyx_v_coordNumberIntra;
  float *__pyx_v_coordNumberInter;
  double __pyx_v_x;
  double __pyx_v_y;
  double __pyx_v_z;
  double __pyx_v_sdx;
  double __pyx_v_sdy;
  double __pyx_v_sdz;
  double __pyx_v_rx;
  double __pyx_v_ry;
  double __pyx_v_rz;
  double __pyx_v_r;
  int __pyx_v_i;
  int __pyx_v_ind;
  int __pyx_v_bin;
  int __pyx_v_index;
  int __pyx_v_dim;
  int __pyx_v_nbins;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  static char *__pyx_argnames[] = {"configuration","directCell","reverseCell","gIndexes","mol","indexes","molecules","elements","cnIntra","cnInter","scalec","groupcenter","rmin","dr",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOiOOOOOOOdd", __pyx_argnames, &__pyx_v_configuration, &__pyx_v_directCell, &__pyx_v_reverseCell, &__pyx_v_gIndexes, &__pyx_v_mol, &__pyx_v_indexes, &__pyx_v_molecules, &__pyx_v_elements, &__pyx_v_cnIntra, &__pyx_v_cnInter, &__pyx_v_scalec, &__pyx_v_groupcenter, &__pyx_v_rmin, &__pyx_v_dr)) return 0;
  Py_INCREF(__pyx_v_configuration);
  Py_INCREF(__pyx_v_directCell);
  Py_INCREF(__pyx_v_reverseCell);
  Py_INCREF(__pyx_v_gIndexes);
  Py_INCREF(__pyx_v_indexes);
  Py_INCREF(__pyx_v_molecules);
  Py_INCREF(__pyx_v_elements);
  Py_INCREF(__pyx_v_cnIntra);
  Py_INCREF(__pyx_v_cnInter);
  Py_INCREF(__pyx_v_scalec);
  Py_INCREF(__pyx_v_groupcenter);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_configuration), __pyx_ptype_25coordination_number_pyrex_array_type, 1, "configuration")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_directCell), __pyx_ptype_25coordination_number_pyrex_array_type, 1, "directCell")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reverseCell), __pyx_ptype_25coordination_number_pyrex_array_type, 1, "reverseCell")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gIndexes), __pyx_ptype_25coordination_number_pyrex_array_type, 1, "gIndexes")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_indexes), __pyx_ptype_25coordination_number_pyrex_array_type, 1, "indexes")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_molecules), __pyx_ptype_25coordination_number_pyrex_array_type, 1, "molecules")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_elements), __pyx_ptype_25coordination_number_pyrex_array_type, 1, "elements")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cnIntra), __pyx_ptype_25coordination_number_pyrex_array_type, 1, "cnIntra")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cnInter), __pyx_ptype_25coordination_number_pyrex_array_type, 1, "cnInter")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_scalec), __pyx_ptype_25coordination_number_pyrex_array_type, 1, "scalec")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_groupcenter), __pyx_ptype_25coordination_number_pyrex_array_type, 1, "groupcenter")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; goto __pyx_L1;}

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":33 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_configuration->nd == 2)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":34 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_directCell->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":35 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_reverseCell->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":36 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_gIndexes->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":37 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_indexes->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":38 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_molecules->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":39 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_elements->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":40 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_cnIntra->nd == 2)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":41 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_cnInter->nd == 2)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":42 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_scalec->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":43 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_groupcenter->nd == 1)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":46 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_configuration->descr->type_num == PyArray_DOUBLE)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":47 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_directCell->descr->type_num == PyArray_DOUBLE)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":48 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_reverseCell->descr->type_num == PyArray_DOUBLE)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":49 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_scalec->descr->type_num == PyArray_DOUBLE)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":50 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_groupcenter->descr->type_num == PyArray_DOUBLE)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":52 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (__pyx_v_gIndexes->descr->type_num == PyArray_INT);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_gIndexes->descr->type_num == PyArray_LONG);
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_gIndexes->descr->elsize == (sizeof(int)));
  }
  if (!__pyx_1) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":55 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (__pyx_v_indexes->descr->type_num == PyArray_INT);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_indexes->descr->type_num == PyArray_LONG);
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_indexes->descr->elsize == (sizeof(int)));
  }
  if (!__pyx_1) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":58 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (__pyx_v_molecules->descr->type_num == PyArray_INT);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_molecules->descr->type_num == PyArray_LONG);
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_molecules->descr->elsize == (sizeof(int)));
  }
  if (!__pyx_1) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":61 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_1 = (__pyx_v_elements->descr->type_num == PyArray_INT);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_elements->descr->type_num == PyArray_LONG);
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_elements->descr->elsize == (sizeof(int)));
  }
  if (!__pyx_1) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":64 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_cnIntra->descr->type_num == PyArray_FLOAT)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":65 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!(__pyx_v_cnInter->descr->type_num == PyArray_FLOAT)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":67 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!((__pyx_v_cnInter->dimensions[0]) == (__pyx_v_cnIntra->dimensions[0]))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":68 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  if (!((__pyx_v_cnInter->dimensions[1]) == (__pyx_v_cnIntra->dimensions[1]))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; goto __pyx_L1;}
  }
  #endif

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":70 */
  __pyx_v_nbins = (__pyx_v_cnInter->dimensions[1]);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":72 */
  __pyx_v_config = ((double *)__pyx_v_configuration->data);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":73 */
  __pyx_v_cell = ((double *)__pyx_v_directCell->data);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":74 */
  __pyx_v_rcell = ((double *)__pyx_v_reverseCell->data);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":75 */
  __pyx_v_groupindex = ((int *)__pyx_v_gIndexes->data);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":76 */
  __pyx_v_atomindex = ((int *)__pyx_v_indexes->data);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":77 */
  __pyx_v_molindex = ((int *)__pyx_v_molecules->data);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":78 */
  __pyx_v_elementindex = ((int *)__pyx_v_elements->data);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":79 */
  __pyx_v_coordNumberIntra = ((float *)__pyx_v_cnIntra->data);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":80 */
  __pyx_v_coordNumberInter = ((float *)__pyx_v_cnInter->data);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":81 */
  __pyx_v_scaleconfig = ((double *)__pyx_v_scalec->data);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":82 */
  __pyx_v_center = ((double *)__pyx_v_groupcenter->data);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":84 */
  (__pyx_v_center[0]) = 0.0;

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":85 */
  (__pyx_v_center[1]) = 0.0;

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":86 */
  (__pyx_v_center[2]) = 0.0;

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":88 */
  __pyx_1 = (__pyx_v_gIndexes->dimensions[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":90 */
    __pyx_v_ind = (3 * (__pyx_v_groupindex[__pyx_v_i]));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":92 */
    __pyx_v_x = (__pyx_v_config[__pyx_v_ind]);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":93 */
    __pyx_v_y = (__pyx_v_config[(__pyx_v_ind + 1)]);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":94 */
    __pyx_v_z = (__pyx_v_config[(__pyx_v_ind + 2)]);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":96 */
    (__pyx_v_center[0]) += (((__pyx_v_x * (__pyx_v_rcell[0])) + (__pyx_v_y * (__pyx_v_rcell[3]))) + (__pyx_v_z * (__pyx_v_rcell[6])));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":97 */
    (__pyx_v_center[1]) += (((__pyx_v_x * (__pyx_v_rcell[1])) + (__pyx_v_y * (__pyx_v_rcell[4]))) + (__pyx_v_z * (__pyx_v_rcell[7])));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":98 */
    (__pyx_v_center[2]) += (((__pyx_v_x * (__pyx_v_rcell[2])) + (__pyx_v_y * (__pyx_v_rcell[5]))) + (__pyx_v_z * (__pyx_v_rcell[8])));
  }

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":100 */
  (__pyx_v_center[0]) /= ((double)(__pyx_v_gIndexes->dimensions[0]));

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":101 */
  (__pyx_v_center[1]) /= ((double)(__pyx_v_gIndexes->dimensions[0]));

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":102 */
  (__pyx_v_center[2]) /= ((double)(__pyx_v_gIndexes->dimensions[0]));

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":104 */
  __pyx_1 = (__pyx_v_indexes->dimensions[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":106 */
    __pyx_v_ind = (3 * (__pyx_v_atomindex[__pyx_v_i]));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":108 */
    __pyx_v_x = (__pyx_v_config[__pyx_v_ind]);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":109 */
    __pyx_v_y = (__pyx_v_config[(__pyx_v_ind + 1)]);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":110 */
    __pyx_v_z = (__pyx_v_config[(__pyx_v_ind + 2)]);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":112 */
    __pyx_v_ind = (3 * __pyx_v_i);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":114 */
    (__pyx_v_scaleconfig[__pyx_v_ind]) = (((__pyx_v_x * (__pyx_v_rcell[0])) + (__pyx_v_y * (__pyx_v_rcell[3]))) + (__pyx_v_z * (__pyx_v_rcell[6])));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":115 */
    (__pyx_v_scaleconfig[(__pyx_v_ind + 1)]) = (((__pyx_v_x * (__pyx_v_rcell[1])) + (__pyx_v_y * (__pyx_v_rcell[4]))) + (__pyx_v_z * (__pyx_v_rcell[7])));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":116 */
    (__pyx_v_scaleconfig[(__pyx_v_ind + 2)]) = (((__pyx_v_x * (__pyx_v_rcell[2])) + (__pyx_v_y * (__pyx_v_rcell[5]))) + (__pyx_v_z * (__pyx_v_rcell[8])));
  }

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":118 */
  __pyx_v_dim = (__pyx_v_cnInter->dimensions[1]);

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":120 */
  __pyx_1 = (__pyx_v_indexes->dimensions[0]);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":122 */
    __pyx_v_ind = (3 * __pyx_v_i);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":124 */
    __pyx_v_sdx = ((__pyx_v_scaleconfig[__pyx_v_ind]) - (__pyx_v_center[0]));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":125 */
    __pyx_v_sdy = ((__pyx_v_scaleconfig[(__pyx_v_ind + 1)]) - (__pyx_v_center[1]));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":126 */
    __pyx_v_sdz = ((__pyx_v_scaleconfig[(__pyx_v_ind + 2)]) - (__pyx_v_center[2]));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":128 */
    __pyx_v_sdx -= round(__pyx_v_sdx);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":129 */
    __pyx_v_sdy -= round(__pyx_v_sdy);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":130 */
    __pyx_v_sdz -= round(__pyx_v_sdz);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":132 */
    __pyx_v_rx = (((__pyx_v_sdx * (__pyx_v_cell[0])) + (__pyx_v_sdy * (__pyx_v_cell[3]))) + (__pyx_v_sdz * (__pyx_v_cell[6])));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":133 */
    __pyx_v_ry = (((__pyx_v_sdx * (__pyx_v_cell[1])) + (__pyx_v_sdy * (__pyx_v_cell[4]))) + (__pyx_v_sdz * (__pyx_v_cell[7])));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":134 */
    __pyx_v_rz = (((__pyx_v_sdx * (__pyx_v_cell[2])) + (__pyx_v_sdy * (__pyx_v_cell[5]))) + (__pyx_v_sdz * (__pyx_v_cell[8])));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":136 */
    __pyx_v_r = sqrt((((__pyx_v_rx * __pyx_v_rx) + (__pyx_v_ry * __pyx_v_ry)) + (__pyx_v_rz * __pyx_v_rz)));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":138 */
    __pyx_v_bin = ((int)((__pyx_v_r - __pyx_v_rmin) / __pyx_v_dr));

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":140 */
    __pyx_2 = (__pyx_v_bin < 0);
    if (!__pyx_2) {
      __pyx_2 = (__pyx_v_bin >= __pyx_v_nbins);
    }
    if (__pyx_2) {
      goto __pyx_L6;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":143 */
    __pyx_v_index = (((__pyx_v_elementindex[__pyx_v_i]) * __pyx_v_dim) + __pyx_v_bin);

    /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":145 */
    __pyx_2 = (__pyx_v_mol == (__pyx_v_molindex[__pyx_v_i]));
    if (__pyx_2) {
      (__pyx_v_coordNumberIntra[__pyx_v_index]) += 1.0;
      goto __pyx_L9;
    }
    /*else*/ {
      (__pyx_v_coordNumberInter[__pyx_v_index]) += 1.0;
    }
    __pyx_L9:;
    __pyx_L6:;
  }

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("coordination_number_pyrex.coordination_number_pyrex");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_configuration);
  Py_DECREF(__pyx_v_directCell);
  Py_DECREF(__pyx_v_reverseCell);
  Py_DECREF(__pyx_v_gIndexes);
  Py_DECREF(__pyx_v_indexes);
  Py_DECREF(__pyx_v_molecules);
  Py_DECREF(__pyx_v_elements);
  Py_DECREF(__pyx_v_cnIntra);
  Py_DECREF(__pyx_v_cnInter);
  Py_DECREF(__pyx_v_scalec);
  Py_DECREF(__pyx_v_groupcenter);
  return __pyx_r;
}

static struct PyMethodDef __pyx_methods[] = {
  {"coordination_number_pyrex", (PyCFunction)__pyx_f_25coordination_number_pyrex_coordination_number_pyrex, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

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

PyMODINIT_FUNC initcoordination_number_pyrex(void); /*proto*/
PyMODINIT_FUNC initcoordination_number_pyrex(void) {
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("coordination_number_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_25coordination_number_pyrex_array_type = __Pyx_ImportType("Scientific.N", "array_type", sizeof(PyArrayObject)); if (!__pyx_ptype_25coordination_number_pyrex_array_type) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; goto __pyx_L1;}

  /* "..\Include\nMOLDYN\numeric.pxi":36 */
  import_array();

  /* "C:\Datas\Eclipse_Projects\Python\nMOLDYN\trunk\Src\coordination_number_pyrex.pyx":9 */
  return;
  __pyx_L1:;
  __Pyx_AddTraceback("coordination_number_pyrex");
}

static char *__pyx_filenames[] = {
  "coordination_number_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);
}
