title: The equivalence of "enumerate" in cython
body: <p>If one defines a pointer vector in <code>cython</code>, what is the similar function or procedure as <code>enumerate</code> in python to go through both indexes and values of elements in the pointer array in a loop inside a <strong>C</strong> declared type function?</p>
  
  <p><strong>test.pyx</strong></p>
  
  <pre><code>#cython: wraparound=False
  #cython: boundscheck=False
  #cython: cdivision=True
  #cython: nonecheck=False
  from cpython cimport array
  import cython
  import numpy as np
  import ctypes
  cimport numpy as np
  cdef extern from "math.h":
       cpdef double log(double x)
       cpdef double exp(double x)
  
  def void initial(int *ns, int *m, double *emax, double* x, double* hx, double*
          hpx, int *lb, double *xlb, int *ub, double *xub, int* ifault, int* iwv,
          double* rwv):
        cdef int nn, ilow, ihigh, i
        cdef int iipt, iz, ihuz, iscum, ix, ihx, ihpx
        cdef bint horiz
        cdef double hulb, huub, eps, cu, alcu, huzmax
  
        eps = exp(-emax[0])
        ifault[0] = 0
        ilow = 0
        ihigh = 0
        nn = ns[0]+1
  
        if (m[0] &lt; 1):
           ifault[0] = 1
  
        huzmax = hx[0]
        if not ub[0]:
           xub[0] = 0.0
  
        if not lb[0]:
           xlb[0] = 0.0
  
        hulb = (xlb[0]-x[0])*hpx[0] + hx[0]
        huub = (xub[0]-x[0])*hpx[0] + hx[0]
        if (ub[0] and lb[0]):
           huzmax = max(huub, hulb)
            cu = exp((huub+hulb)*0.5-huzmax)*(xub[0]-xlb[0])  
        else:
           cu = 0.0
           if (m[0] &lt; 2):
               ifault[0] = 1
  
        if (cu &gt; 0.0):
            alcu = log(cu)
        #set pointers
        iipt = 5
        iz = 8
        ihuz = nn+iz
        iscum = nn+ihuz
        ix = nn+iscum
        ihx = nn+ix
        ihpx = nn+ihx
        iwv[0] = ilow
        iwv[1] = ihigh
        iwv[2] = ns[0]
        iwv[3] = 1
        if lb[0]:
           iwv[4] = 1
        else:
           iwv[4] = 0
  
        if ub[0]:
           iwv[5] = 1
        else:
           iwv[5] = 0
  
        if ( ns[0] &lt; m[0]):
           ifault[0] = 2
  
        iwv[iipt+1] = 0
        rwv[0] = hulb
        rwv[1] = huub
        rwv[2] = emax[0]
        rwv[3] = eps
        rwv[4] = cu
        rwv[5] = alcu
        rwv[6] = huzmax
        rwv[7] = xlb[0]
        rwv[8] = xub[0]
        rwv[iscum+1] = 1.0
        for i from 0 &lt;= i &lt; m[0]:
           rwv[ix+i] = x[i]
           rwv[ihx+i] = hx[i]
           rwv[ihpx+i] = hpx[i]
        i = 0
        while (i &lt; m[0]):
              update(&amp;iwv[3], &amp;iwv[0], &amp;iwv[1], &amp;iwv[iipt+1], &amp;rwv[iscum+1], &amp;rwv[4],
                      &amp;rwv[ix+1], &amp;rwv[ihx+1], &amp;rwv[ihpx+1], &amp;rwv[iz+1],
                      &amp;rwv[ihuz+1], &amp;rwv[6], &amp;rwv[2], lb, &amp;rwv[7], &amp;rwv[0], ub,
                      &amp;rwv[8], &amp;rwv[1], ifault, &amp;rwv[3], &amp;rwv[5])
              i = iwv[3]
  
  def void update(int *n, int *ilow, int *ihigh, int* ipt, double* scum, double
          *cu, double* x, double* hx, const double* hpx, double* z, double* huz,
          double *huzmax, double *emax, int *lb, double *xlb, double *hulb, int *ub,
          double *xub, double *huub, int* ifault, double *eps, double *alcu):
  
  
        n[0] = n[0]+1
        print "number of points defining the hulls", n[0]
        print " values of x: " , x[0],x[1],x[n[0]] 
        print "index of the smallest x(i)", ilow[0] 
        print " values of x: " ,x[ilow[0]]                     
        print "Update z,huz and ipt   "                              
  
  def foo(int ns, int m, double emax,
           np.ndarray[ndim=1, dtype=np.float64_t] x,
           np.ndarray[ndim=1, dtype=np.float64_t] hx,
           np.ndarray[ndim=1, dtype=np.float64_t] hpx,
           int num):
  
      cdef np.ndarray[ndim=1, dtype=np.float64_t] rwv
      cdef np.ndarray[ndim=1, dtype=np.int64_t] iwv
      # initializing arrays
      rwv = np.zeros(ns*6+15, dtype=np.float64)
      iwv = np.zeros(ns+7, dtype=np.int64)        
      cdef double xlb = np.min(x)
      cdef double xub = np.max(x)
      cdef int lb=0
      cdef int ub=0
      cdef int ifault = 0
      cdef double beta = 0.
  
      initial(&amp;ns, &amp;m, &amp;emax,
              &amp;x[0], 
              &amp;hx[0], 
              &amp;hpx[0], 
              &amp;lb, 
              &amp;xlb,
              &amp;ub, 
              &amp;xub, 
              &amp;ifault, 
              &lt;int *&gt;(&amp;iwv[0]), 
              &amp;rwv[0] 
              )
  </code></pre>
  
  <p><strong>python code</strong></p>
  
  <pre><code>import numpy as np
  from test import foo
  
  m = 3
  ns = 100
  emax = 64
  
  x = np.zeros(10, float)
  hx = np.zeros(10, float)
  hpx = np.zeros(10, float)
  
  x[0] = 0
  x[1] = 1.0
  x[2] = -1.0
  print x
  def normal(x):
      return -x*x*0.5,-x
  
  hx[0], hpx[0] = normal(x[1])
  hx[1], hpx[1] = normal(x[2])
  hx[2], hpx[2] = normal(x[3])
  print hpx
  
  
  num = 20
  foo(ns, m, emax, x, hx, hpx, num)
  </code></pre>