Generated by Cython 0.13 on Tue Nov 30 15:06:46 2010
Raw output: _Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.c
1:
2: include "interrupt.pxi" # ctrl-c interrupt block support
/* "/Users/slabbe/.sage/temp/pol/10351/spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx":2 * * include "interrupt.pxi" # ctrl-c interrupt block support #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* include "stdsage.pxi" # ctrl-c interrupt block support * */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2))<
0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
3: include "stdsage.pxi" # ctrl-c interrupt block support
4:
5: include "cdefs.pxi"
6: from math import sin
/* "/Users/slabbe/.sage/temp/pol/10351/spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx":6 * * include "cdefs.pxi" * from math import sin #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * def f(double x): */ __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __Pyx_INCREF(((PyObject *)__pyx_n_s__sin)); PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__sin)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__sin)); __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__math), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__sin); 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__sin, __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; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7:
8: def f(double x):
/* "/Users/slabbe/.sage/temp/pol/10351/spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx":8 * from math import sin * * def f(double x): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* return sin(x**2) * */ static PyObject *__pyx_pf_73_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0_f(PyObject *__pyx_self, PyObject *__pyx_arg_x); /*proto*/ static char __pyx_doc_73_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0_f[] = "File: _Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx (starting at line 8)"; static PyObject *__pyx_pf_73_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0_f(PyObject *__pyx_self, PyObject *__pyx_arg_x) { double __pyx_v_x; PyObject *__pyx_r = NULL; __Pyx_RefNannySetupContext("f"); __pyx_self = __pyx_self; assert(__pyx_arg_x); { __pyx_v_x = __pyx_PyFloat_AsDouble(__pyx_arg_x); if (unlikely((__pyx_v_x == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.f"); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:;
9: return sin(x**2)
/* "/Users/slabbe/.sage/temp/pol/10351/spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx":9 * * def f(double x): * return sin(x**2) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* * def integrate_f_cy(double a, double b, int N): */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sin); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyFloat_FromDouble(pow(__pyx_v_x, 2.0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; 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_AddTraceback("_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.f"); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
10:
11: def integrate_f_cy(double a, double b, int N):
/* "/Users/slabbe/.sage/temp/pol/10351/spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx":11 * return sin(x**2) * * def integrate_f_cy(double a, double b, int N): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* cdef int i * cdef double s, dx */ static PyObject *__pyx_pf_73_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0_integrate_f_cy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_73_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0_integrate_f_cy[] = "File: _Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx (starting at line 11)"; static PyObject *__pyx_pf_73_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0_integrate_f_cy(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { double __pyx_v_a; double __pyx_v_b; int __pyx_v_N; int __pyx_v_i; double __pyx_v_s; double __pyx_v_dx; PyObject *__pyx_r = NULL; static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__a,&__pyx_n_s__b,&__pyx_n_s__N,0}; __Pyx_RefNannySetupContext("integrate_f_cy"); __pyx_self = __pyx_self; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args = PyDict_Size(__pyx_kwds); PyObject* values[3] = {0,0,0}; switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; } switch (PyTuple_GET_SIZE(__pyx_args)) { case 0: values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a); if (likely(values[0])) kw_args--; else goto __pyx_L5_argtuple_error; case 1: values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b); if (likely(values[1])) kw_args--; else { __Pyx_RaiseArgtupleInvalid("integrate_f_cy", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__N); if (likely(values[2])) kw_args--; else { __Pyx_RaiseArgtupleInvalid("integrate_f_cy", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "integrate_f_cy")<
0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } __pyx_v_a = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_a == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_b = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_b == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_N = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { __pyx_v_a = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_a == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_b = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_b == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_N = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_N == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("integrate_f_cy", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.integrate_f_cy"); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:;
12: cdef int i
13: cdef double s, dx
14: s = 0
/* "/Users/slabbe/.sage/temp/pol/10351/spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx":14 * cdef int i * cdef double s, dx * s = 0 #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* dx = (b-a)/N * for i in range(N): */ __pyx_v_s = 0.0;
15: dx = (b-a)/N
/* "/Users/slabbe/.sage/temp/pol/10351/spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx":15 * cdef double s, dx * s = 0 * dx = (b-a)/N #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* for i in range(N): * s += f(a+i*dx) */ __pyx_t_1 = (__pyx_v_b - __pyx_v_a); if (unlikely(__pyx_v_N == 0)) { PyErr_Format(PyExc_ZeroDivisionError, "float division"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_dx = (__pyx_t_1 / __pyx_v_N);
16: for i in range(N):
/* "/Users/slabbe/.sage/temp/pol/10351/spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx":16 * s = 0 * dx = (b-a)/N * for i in range(N): #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* s += f(a+i*dx) * return s * dx */ __pyx_t_2 = __pyx_v_N; for (__pyx_t_3 = 0; __pyx_t_3<
__pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3;
17: s += f(a+i*dx)
/* "/Users/slabbe/.sage/temp/pol/10351/spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx":17 * dx = (b-a)/N * for i in range(N): * s += f(a+i*dx) #<
<
<
<
<
<
<
<
<
<
<
<
<
<
* return s * dx */ __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__f); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyFloat_FromDouble((__pyx_v_a + (__pyx_v_i * __pyx_v_dx))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_s += __pyx_t_1; }
18: return s * dx
/* "/Users/slabbe/.sage/temp/pol/10351/spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx/_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.pyx":18 * for i in range(N): * s += f(a+i*dx) * return s * dx #<
<
<
<
<
<
<
<
<
<
<
<
<
<
*/ __Pyx_XDECREF(__pyx_r); __pyx_t_5 = PyFloat_FromDouble((__pyx_v_s * __pyx_v_dx)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("_Users_slabbe__sage_sage_notebook_sagenb_home_admin_20_code_sage35_spyx_0.integrate_f_cy"); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }