Generated by Cython 0.15.1 on Fri Mar 9 21:35:49 2012

Raw output: _home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.c

 1: 
 2: include "interrupt.pxi"  # ctrl-c interrupt block support
  /* "_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx":2
 * 
 * include "interrupt.pxi"  # ctrl-c interrupt block support             # <<<<<<<<<<<<<<
 * include "stdsage.pxi"  # ctrl-c interrupt block support
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __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 = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 3: include "stdsage.pxi"  # ctrl-c interrupt block support
 4: 
 5: include "cdefs.pxi"
 6: import numpy as np
  /* "_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx":6
 * 
 * include "cdefs.pxi"
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * import cython
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __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 = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 7: cimport numpy as np
 8: import cython
 9: cimport cython
 10: 
 11: ctypedef np.float64_t DTYPE_t
 12: 
 13: @cython.boundscheck(False)
 14: @cython.wraparound(False)
 15: @cython.nonecheck(False)
 16: def cyneighbors(np.ndarray[DTYPE_t, ndim=2] M):
/* "_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx":16
 * @cython.wraparound(False)
 * @cython.nonecheck(False)
 * def cyneighbors(np.ndarray[DTYPE_t, ndim=2] M):             # <<<<<<<<<<<<<<
 *     cdef int r = M.shape[0]
 *     cdef int c = M.shape[1]
 */

static PyObject *__pyx_pf_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_cyneighbors(PyObject *__pyx_self, PyObject *__pyx_v_M); /*proto*/
static char __pyx_doc_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_cyneighbors[] = "File: _home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx (starting at line 16)";
static PyMethodDef __pyx_mdef_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_cyneighbors = {__Pyx_NAMESTR("cyneighbors"), (PyCFunction)__pyx_pf_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_cyneighbors, METH_O, __Pyx_DOCSTR(__pyx_doc_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_cyneighbors)};
static PyObject *__pyx_pf_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_cyneighbors(PyObject *__pyx_self, PyObject *__pyx_v_M) {
  int __pyx_v_r;
  int __pyx_v_c;
  PyArrayObject *__pyx_v_N = 0;
  unsigned int __pyx_v_i;
  unsigned int __pyx_v_j;
  Py_buffer __pyx_bstruct_M;
  Py_ssize_t __pyx_bstride_0_M = 0;
  Py_ssize_t __pyx_bstride_1_M = 0;
  Py_ssize_t __pyx_bshape_0_M = 0;
  Py_ssize_t __pyx_bshape_1_M = 0;
  Py_buffer __pyx_bstruct_N;
  Py_ssize_t __pyx_bstride_0_N = 0;
  Py_ssize_t __pyx_bstride_1_N = 0;
  Py_ssize_t __pyx_bshape_0_N = 0;
  Py_ssize_t __pyx_bshape_1_N = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("cyneighbors");
  __pyx_self = __pyx_self;
  __pyx_bstruct_N.buf = NULL;
  __pyx_bstruct_M.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_M), __pyx_ptype_5numpy_ndarray, 1, "M", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_M, (PyObject*)__pyx_v_M, &__Pyx_TypeInfo_nn___pyx_t_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_M = __pyx_bstruct_M.strides[0]; __pyx_bstride_1_M = __pyx_bstruct_M.strides[1];
  __pyx_bshape_0_M = __pyx_bstruct_M.shape[0]; __pyx_bshape_1_M = __pyx_bstruct_M.shape[1];

  /* "_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx":16
 * @cython.wraparound(False)
 * @cython.nonecheck(False)
 * def cyneighbors(np.ndarray[DTYPE_t, ndim=2] M):             # <<<<<<<<<<<<<<
 *     cdef int r = M.shape[0]
 *     cdef int c = M.shape[1]
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_cyneighbors, NULL, __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__cyneighbors, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 17:     cdef int r = M.shape[0]
  /* "_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx":17
 * @cython.nonecheck(False)
 * def cyneighbors(np.ndarray[DTYPE_t, ndim=2] M):
 *     cdef int r = M.shape[0]             # <<<<<<<<<<<<<<
 *     cdef int c = M.shape[1]
 *     cdef np.ndarray[DTYPE_t, ndim=2] N = np.zeros((r,c))
 */
  __pyx_v_r = (((PyArrayObject *)__pyx_v_M)->dimensions[0]);
 18:     cdef int c = M.shape[1]
  /* "_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx":18
 * def cyneighbors(np.ndarray[DTYPE_t, ndim=2] M):
 *     cdef int r = M.shape[0]
 *     cdef int c = M.shape[1]             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE_t, ndim=2] N = np.zeros((r,c))
 *     cdef unsigned int i, j
 */
  __pyx_v_c = (((PyArrayObject *)__pyx_v_M)->dimensions[1]);
 19:     cdef np.ndarray[DTYPE_t, ndim=2] N = np.zeros((r,c))
  /* "_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx":19
 *     cdef int r = M.shape[0]
 *     cdef int c = M.shape[1]
 *     cdef np.ndarray[DTYPE_t, ndim=2] N = np.zeros((r,c))             # <<<<<<<<<<<<<<
 *     cdef unsigned int i, j
 *     for i in xrange(r-2):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(__pyx_v_r); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_c); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_N, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_N = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_N.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_N = __pyx_bstruct_N.strides[0]; __pyx_bstride_1_N = __pyx_bstruct_N.strides[1];
      __pyx_bshape_0_N = __pyx_bstruct_N.shape[0]; __pyx_bshape_1_N = __pyx_bstruct_N.shape[1];
    }
  }
  __pyx_t_5 = 0;
  __pyx_v_N = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;
 20:     cdef unsigned int i, j
 21:     for i in xrange(r-2):
  /* "_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx":21
 *     cdef np.ndarray[DTYPE_t, ndim=2] N = np.zeros((r,c))
 *     cdef unsigned int i, j
 *     for i in xrange(r-2):             # <<<<<<<<<<<<<<
 *         for j in xrange(c-2):
 *             N[i + 1, j  + 1] = M[i , j] + M[i, j+1] + M[i, j + 2] + M[i+1, j] + M[i + 1, j+2] + M[i+2 , j] + M[i+2, j+1] + M[i+2, j + 2]
 */
  __pyx_t_6 = (__pyx_v_r - 2);
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;
 22:         for j in xrange(c-2):
    /* "_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx":22
 *     cdef unsigned int i, j
 *     for i in xrange(r-2):
 *         for j in xrange(c-2):             # <<<<<<<<<<<<<<
 *             N[i + 1, j  + 1] = M[i , j] + M[i, j+1] + M[i, j + 2] + M[i+1, j] + M[i + 1, j+2] + M[i+2 , j] + M[i+2, j+1] + M[i+2, j + 2]
 *     return N
 */
    __pyx_t_8 = (__pyx_v_c - 2);
    for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
      __pyx_v_j = __pyx_t_9;
 23:             N[i + 1, j  + 1] = M[i , j] + M[i, j+1] + M[i, j + 2] + M[i+1, j] + M[i + 1, j+2] + M[i+2 , j] + M[i+2, j+1] + M[i+2, j + 2]
      /* "_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx":23
 *     for i in xrange(r-2):
 *         for j in xrange(c-2):
 *             N[i + 1, j  + 1] = M[i , j] + M[i, j+1] + M[i, j + 2] + M[i+1, j] + M[i + 1, j+2] + M[i+2 , j] + M[i+2, j+1] + M[i+2, j + 2]             # <<<<<<<<<<<<<<
 *     return N
 */
      __pyx_t_10 = __pyx_v_i;
      __pyx_t_11 = __pyx_v_j;
      __pyx_t_12 = __pyx_v_i;
      __pyx_t_13 = (__pyx_v_j + 1);
      __pyx_t_14 = __pyx_v_i;
      __pyx_t_15 = (__pyx_v_j + 2);
      __pyx_t_16 = (__pyx_v_i + 1);
      __pyx_t_17 = __pyx_v_j;
      __pyx_t_18 = (__pyx_v_i + 1);
      __pyx_t_19 = (__pyx_v_j + 2);
      __pyx_t_20 = (__pyx_v_i + 2);
      __pyx_t_21 = __pyx_v_j;
      __pyx_t_22 = (__pyx_v_i + 2);
      __pyx_t_23 = (__pyx_v_j + 1);
      __pyx_t_24 = (__pyx_v_i + 2);
      __pyx_t_25 = (__pyx_v_j + 2);
      __pyx_t_26 = (__pyx_v_i + 1);
      __pyx_t_27 = (__pyx_v_j + 1);
      *__Pyx_BufPtrStrided2d(__pyx_t_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_DTYPE_t *, __pyx_bstruct_N.buf, __pyx_t_26, __pyx_bstride_0_N, __pyx_t_27, __pyx_bstride_1_N) = ((((((((*__Pyx_BufPtrStrided2d(__pyx_t_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_DTYPE_t *, __pyx_bstruct_M.buf, __pyx_t_10, __pyx_bstride_0_M, __pyx_t_11, __pyx_bstride_1_M)) + (*__Pyx_BufPtrStrided2d(__pyx_t_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_DTYPE_t *, __pyx_bstruct_M.buf, __pyx_t_12, __pyx_bstride_0_M, __pyx_t_13, __pyx_bstride_1_M))) + (*__Pyx_BufPtrStrided2d(__pyx_t_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_DTYPE_t *, __pyx_bstruct_M.buf, __pyx_t_14, __pyx_bstride_0_M, __pyx_t_15, __pyx_bstride_1_M))) + (*__Pyx_BufPtrStrided2d(__pyx_t_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_DTYPE_t *, __pyx_bstruct_M.buf, __pyx_t_16, __pyx_bstride_0_M, __pyx_t_17, __pyx_bstride_1_M))) + (*__Pyx_BufPtrStrided2d(__pyx_t_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_DTYPE_t *, __pyx_bstruct_M.buf, __pyx_t_18, __pyx_bstride_0_M, __pyx_t_19, __pyx_bstride_1_M))) + (*__Pyx_BufPtrStrided2d(__pyx_t_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_DTYPE_t *, __pyx_bstruct_M.buf, __pyx_t_20, __pyx_bstride_0_M, __pyx_t_21, __pyx_bstride_1_M))) + (*__Pyx_BufPtrStrided2d(__pyx_t_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_DTYPE_t *, __pyx_bstruct_M.buf, __pyx_t_22, __pyx_bstride_0_M, __pyx_t_23, __pyx_bstride_1_M))) + (*__Pyx_BufPtrStrided2d(__pyx_t_72_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0_DTYPE_t *, __pyx_bstruct_M.buf, __pyx_t_24, __pyx_bstride_0_M, __pyx_t_25, __pyx_bstride_1_M)));
    }
  }
 24:     return N
  /* "_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.pyx":24
 *         for j in xrange(c-2):
 *             N[i + 1, j  + 1] = M[i , j] + M[i, j+1] + M[i, j + 2] + M[i+1, j] + M[i + 1, j+2] + M[i+2 , j] + M[i+2, j+1] + M[i+2, j + 2]
 *     return N             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_N));
  __pyx_r = ((PyObject *)__pyx_v_N);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_M);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_N);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_home_gautam__sage_sage_notebook_sagenb_home_admin_11_code_sage14_spyx_0.cyneighbors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_M);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_N);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_N);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}