Generated by Cython 0.18 on Wed Apr 10 08:56:34 2013

Raw output: reduce_p2.c

 1: import numpy as np
  /* "reduce_p2.pyx":1
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "reduce_p2.pyx":1
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 2: cimport numpy as np
 3: 
 4: def reduce(np.ndarray[np.float64_t, ndim=2]  arr ):
/* "reduce_p2.pyx":4
 * cimport numpy as np
 * 
 * def reduce(np.ndarray[np.float64_t, ndim=2]  arr ):             # <<<<<<<<<<<<<<
 * 	cdef double output = 0
 * 	cdef int N, M, i, j
 */

static PyObject *__pyx_pf_9reduce_p2_reduce(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_arr) {
  double __pyx_v_output;
  int __pyx_v_N;
  int __pyx_v_M;
  int __pyx_v_i;
  int __pyx_v_j;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_arr;
  __Pyx_Buffer __pyx_pybuffer_arr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("reduce", 0);
  __pyx_pybuffer_arr.pybuffer.buf = NULL;
  __pyx_pybuffer_arr.refcount = 0;
  __pyx_pybuffernd_arr.data = NULL;
  __pyx_pybuffernd_arr.rcbuffer = &__pyx_pybuffer_arr;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_arr.rcbuffer->pybuffer, (PyObject*)__pyx_v_arr, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_arr.diminfo[0].strides = __pyx_pybuffernd_arr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_arr.diminfo[0].shape = __pyx_pybuffernd_arr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_arr.diminfo[1].strides = __pyx_pybuffernd_arr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_arr.diminfo[1].shape = __pyx_pybuffernd_arr.rcbuffer->pybuffer.shape[1];

  /* "reduce_p2.pyx":4
 * cimport numpy as np
 * 
 * def reduce(np.ndarray[np.float64_t, ndim=2]  arr ):             # <<<<<<<<<<<<<<
 * 	cdef double output = 0
 * 	cdef int N, M, i, j
 */
  __pyx_k_tuple_13 = PyTuple_Pack(6, ((PyObject *)__pyx_n_s__arr), ((PyObject *)__pyx_n_s__output), ((PyObject *)__pyx_n_s__N), ((PyObject *)__pyx_n_s__M), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__j)); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_13);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13));

  /* "reduce_p2.pyx":4
 * cimport numpy as np
 * 
 * def reduce(np.ndarray[np.float64_t, ndim=2]  arr ):             # <<<<<<<<<<<<<<
 * 	cdef double output = 0
 * 	cdef int N, M, i, j
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_9reduce_p2_1reduce, NULL, __pyx_n_s__reduce_p2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__reduce, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 5: 	cdef double output = 0
  /* "reduce_p2.pyx":5
 * 
 * def reduce(np.ndarray[np.float64_t, ndim=2]  arr ):
 * 	cdef double output = 0             # <<<<<<<<<<<<<<
 * 	cdef int N, M, i, j
 * 	#need to unpack the implied python tuple
 */
  __pyx_v_output = 0.0;
 6: 	cdef int N, M, i, j
 7: 	#need to unpack the implied python tuple
 8: 	N = arr.shape[0]
  /* "reduce_p2.pyx":8
 * 	cdef int N, M, i, j
 * 	#need to unpack the implied python tuple
 * 	N = arr.shape[0]             # <<<<<<<<<<<<<<
 * 	M = arr.shape[1]
 * 	for i in range(N):
 */
  __pyx_v_N = (__pyx_v_arr->dimensions[0]);
 9: 	M = arr.shape[1]
  /* "reduce_p2.pyx":9
 * 	#need to unpack the implied python tuple
 * 	N = arr.shape[0]
 * 	M = arr.shape[1]             # <<<<<<<<<<<<<<
 * 	for i in range(N):
 * 		for j in range(M):
 */
  __pyx_v_M = (__pyx_v_arr->dimensions[1]);
 10: 	for i in range(N):
  /* "reduce_p2.pyx":10
 * 	N = arr.shape[0]
 * 	M = arr.shape[1]
 * 	for i in range(N):             # <<<<<<<<<<<<<<
 * 		for j in range(M):
 * 			output += arr[i,j]**2
 */
  __pyx_t_1 = __pyx_v_N;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;
 11: 		for j in range(M):
    /* "reduce_p2.pyx":11
 * 	M = arr.shape[1]
 * 	for i in range(N):
 * 		for j in range(M):             # <<<<<<<<<<<<<<
 * 			output += arr[i,j]**2
 * 
 */
    __pyx_t_3 = __pyx_v_M;
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_j = __pyx_t_4;
 12: 			output += arr[i,j]**2
      /* "reduce_p2.pyx":12
 * 	for i in range(N):
 * 		for j in range(M):
 * 			output += arr[i,j]**2             # <<<<<<<<<<<<<<
 * 
 * 	return output
 */
      __pyx_t_5 = __pyx_v_i;
      __pyx_t_6 = __pyx_v_j;
      __pyx_t_7 = -1;
      if (__pyx_t_5 < 0) {
        __pyx_t_5 += __pyx_pybuffernd_arr.diminfo[0].shape;
        if (unlikely(__pyx_t_5 < 0)) __pyx_t_7 = 0;
      } else if (unlikely(__pyx_t_5 >= __pyx_pybuffernd_arr.diminfo[0].shape)) __pyx_t_7 = 0;
      if (__pyx_t_6 < 0) {
        __pyx_t_6 += __pyx_pybuffernd_arr.diminfo[1].shape;
        if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 1;
      } else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_arr.diminfo[1].shape)) __pyx_t_7 = 1;
      if (unlikely(__pyx_t_7 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_7);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_output = (__pyx_v_output + pow((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_pybuffernd_arr.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_arr.diminfo[0].strides, __pyx_t_6, __pyx_pybuffernd_arr.diminfo[1].strides)), 2.0));
    }
  }
 13: 
 14: 	return output
  /* "reduce_p2.pyx":14
 * 			output += arr[i,j]**2
 * 
 * 	return output             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = PyFloat_FromDouble(__pyx_v_output); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_r = __pyx_t_8;
  __pyx_t_8 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_8);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("reduce_p2.reduce", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_arr.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}