Passing params to cythonized ode_system()
Hi, I am trying to code a batch process to solve an ODE many times over a range of parameters. I am using a modified version of an example in the sage documentation:
%cython cimport sage.gsl.ode import sage.gsl.ode include 'gsl.pxi' cdef class duffing_osc(sage.gsl.ode.ode_system): cdef int c_f(self,double t, double *y,double *dydt): dydt=y dydt=y-params*y-y*y*y+params*cos(params*t) return GSL_SUCCESS cdef int c_j(self, double t,double *y,double *dfdy,double *dfdt): dfdy=0 dfdy=1.0 dfdy=-3*y*y+1 dfdy=-params*y dfdt=0 dfdt=-params*params*sin(params*t) return GSL_SUCCESS
Now, the problem of course is that when trying to generate the .spyx file, param is undeclared, since I can't overload the c_f and c_j functions. Is there a way I can further modify my derived class (duffing_osc) so that when I instantiate an object I can pass in the parameters, such as d = duffing_osc(params). Then I suppose I would have to change params[i] to self.params[i] in my definitions for c_f and c_j.