Generated by Cython 0.16 on Sat Sep 22 15:45:08 2012

Raw output: cy_opt.html

 1: import math
  /* "cy_opt.pyx":1
 * import math             # <<<<<<<<<<<<<<
 * 
 * cdef double f(double x):
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__math), 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__math, __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;
 2: 
 3: cdef double f(double x):
/* "cy_opt.pyx":3
 * import math
 * 
 * cdef double f(double x):             # <<<<<<<<<<<<<<
 *     return math.sqrt(1.0-x*x)
 * 
 */

static double __pyx_f_6cy_opt_f(double __pyx_v_x) {
  double __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("f", 0);
 4:     return math.sqrt(1.0-x*x)
  /* "cy_opt.pyx":4
 * 
 * cdef double f(double x):
 *     return math.sqrt(1.0-x*x)             # <<<<<<<<<<<<<<
 * 
 * def pi(int n):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__math); 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);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__sqrt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble((1.0 - (__pyx_v_x * __pyx_v_x))); 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);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); 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);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_WriteUnraisable("cy_opt.f", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_6cy_opt_1pi(PyObject *__pyx_self, PyObject *__pyx_arg_n); /*proto*/
static PyMethodDef __pyx_mdef_6cy_opt_1pi = {__Pyx_NAMESTR("pi"), (PyCFunction)__pyx_pw_6cy_opt_1pi, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_6cy_opt_1pi(PyObject *__pyx_self, PyObject *__pyx_arg_n) {
  int __pyx_v_n;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pi (wrapper)", 0);
  __pyx_self = __pyx_self;
  assert(__pyx_arg_n); {
    __pyx_v_n = __Pyx_PyInt_AsInt(__pyx_arg_n); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("cy_opt.pi", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_6cy_opt_pi(__pyx_self, ((int)__pyx_v_n));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 5: 
 6: def pi(int n):
/* "cy_opt.pyx":6
 *     return math.sqrt(1.0-x*x)
 * 
 * def pi(int n):             # <<<<<<<<<<<<<<
 *     cdef:
 *         double s, h, x
 */

static PyObject *__pyx_pf_6cy_opt_pi(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n) {
  double __pyx_v_s;
  double __pyx_v_h;
  double __pyx_v_x;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("pi", 0);

  /* "cy_opt.pyx":6
 *     return math.sqrt(1.0-x*x)
 * 
 * def pi(int n):             # <<<<<<<<<<<<<<
 *     cdef:
 *         double s, h, x
 */
  __pyx_k_tuple_1 = PyTuple_New(6); if (unlikely(!__pyx_k_tuple_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n));
  PyTuple_SET_ITEM(__pyx_k_tuple_1, 0, ((PyObject *)__pyx_n_s__n));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__n));
  PyTuple_SET_ITEM(__pyx_k_tuple_1, 1, ((PyObject *)__pyx_n_s__n));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__s));
  PyTuple_SET_ITEM(__pyx_k_tuple_1, 2, ((PyObject *)__pyx_n_s__s));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__s));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__h));
  PyTuple_SET_ITEM(__pyx_k_tuple_1, 3, ((PyObject *)__pyx_n_s__h));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__h));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__x));
  PyTuple_SET_ITEM(__pyx_k_tuple_1, 4, ((PyObject *)__pyx_n_s__x));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__x));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__i));
  PyTuple_SET_ITEM(__pyx_k_tuple_1, 5, ((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_1));

  /* "cy_opt.pyx":6
 *     return math.sqrt(1.0-x*x)
 * 
 * def pi(int n):             # <<<<<<<<<<<<<<
 *     cdef:
 *         double s, h, x
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_6cy_opt_1pi, NULL, __pyx_n_s__cy_opt); 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__pi, __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:     cdef:
 8:         double s, h, x
 9:         int i
 10:     s = 0.5*(f(-1)+f(1))
  /* "cy_opt.pyx":10
 *         double s, h, x
 *         int i
 *     s = 0.5*(f(-1)+f(1))             # <<<<<<<<<<<<<<
 *     h=2./n
 *     for i in xrange(1,n):
 */
  __pyx_v_s = (0.5 * (__pyx_f_6cy_opt_f(-1.0) + __pyx_f_6cy_opt_f(1.0)));
 11:     h=2./n
  /* "cy_opt.pyx":11
 *         int i
 *     s = 0.5*(f(-1)+f(1))
 *     h=2./n             # <<<<<<<<<<<<<<
 *     for i in xrange(1,n):
 *         x = -1+i*h
 */
  if (unlikely(__pyx_v_n == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_h = (2. / __pyx_v_n);
 12:     for i in xrange(1,n):
  /* "cy_opt.pyx":12
 *     s = 0.5*(f(-1)+f(1))
 *     h=2./n
 *     for i in xrange(1,n):             # <<<<<<<<<<<<<<
 *         x = -1+i*h
 *         s += f(x)
 */
  __pyx_t_1 = __pyx_v_n;
  for (__pyx_t_2 = 1; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;
 13:         x = -1+i*h
    /* "cy_opt.pyx":13
 *     h=2./n
 *     for i in xrange(1,n):
 *         x = -1+i*h             # <<<<<<<<<<<<<<
 *         s += f(x)
 *     return s*h*2
 */
    __pyx_v_x = (-1.0 + (__pyx_v_i * __pyx_v_h));
 14:         s += f(x)
    /* "cy_opt.pyx":14
 *     for i in xrange(1,n):
 *         x = -1+i*h
 *         s += f(x)             # <<<<<<<<<<<<<<
 *     return s*h*2
 */
    __pyx_v_s = (__pyx_v_s + __pyx_f_6cy_opt_f(__pyx_v_x));
  }
 15:     return s*h*2
  /* "cy_opt.pyx":15
 *         x = -1+i*h
 *         s += f(x)
 *     return s*h*2             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyFloat_FromDouble(((__pyx_v_s * __pyx_v_h) * 2.0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("cy_opt.pi", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}