On Thu, Sep 15, 2011 at 3:24 PM, Rajeev Singh <rajs2...@gmail.com> wrote:
> On Thu, Sep 15, 2011 at 12:07 PM, Robert Bradshaw
> <rober...@math.washington.edu> wrote:
>> On Wed, Sep 14, 2011 at 2:31 AM, Rajeev Singh <rajs2...@gmail.com> wrote:
>>> Hi,
>>>
>>> The following examples compiles from the notebook
>>>
>>> %cython
>>> cimport sage.gsl.ode
>>> import sage.gsl.ode
>>> include 'gsl.pxi'
>>>
>>> cdef class van_der_pol(sage.gsl.ode.ode_system):
>>>    cdef double beta
>>>    def __cinit__(self, double beta=1.0):
>>>        self.beta = beta
>>>    cdef int c_f(self,double t, double *y,double *dydt):
>>>        dydt[0]=y[1]
>>>        dydt[1]=-y[0]-self.beta*y[1]*(y[0]*y[0]-1)
>>>        return GSL_SUCCESS
>>>    cdef int c_j(self, double t,double *y,double *dfdy,double *dfdt):
>>>        dfdy[0]=0
>>>        dfdy[1]=1.0
>>>        dfdy[2]=-2.0*10*y[0]*y[1]-1.0
>>>        dfdy[3]=-10*(y[0]*y[0]-1.0)
>>>        dfdt[0]=0
>>>        dfdt[1]=0
>>>        return GSL_SUCCESS
>>>
>>> However if I put it in a file vander.pyx (say) and use the following 
>>> setup.py -
>>>
>>> from distutils.core import setup
>>> from distutils.extension import Extension
>>> from Cython.Distutils import build_ext
>>>
>>> ext = Extension("vander", ["vander.pyx"],
>>>    include_dirs = ['/home/rajeev/bin/sage/devel/sage-main/sage/gsl/'])
>>>
>>> setup(ext_modules=[ext],
>>>      cmdclass = {'build_ext': build_ext})
>>>
>>>
>>> I get the following error -
>>>
>>> cdef class van_der_pol(sage.gsl.ode.ode_system):
>>>    ^
>>> ------------------------------------------------------------
>>>
>>> vander.pyx:10:5: 'ode_system' is not declared
>>>
>>>
>>> I guess the problem is with the setup.py. Can someone tell me how to do 
>>> this?
>>
>> IIRC, the notebook %cython creates a setup.py--you could just look at
>> that. Chances are your Extension object is missing include dirs and
>> libraries.
>>
>>  -Robert
>>
>> --
>> To post to this group, send email to sage-support@googlegroups.com
>> To unsubscribe from this group, send email to 
>> sage-support+unsubscr...@googlegroups.com
>> For more options, visit this group at 
>> http://groups.google.com/group/sage-support
>> URL: http://www.sagemath.org
>>
>
> Hi,
>
> The present script takes a pyx file as input and outputs a c, o and so
> file in the same directory. The so can now be imported in a sage
> program. I have already checked it and its seems to be working fine. I
> did look at the commands generated by setup.py file to write this
> script.
>
> Rajeev
>

Hi,

There is a better (safer I guess) way of doing the task using
something called cython_create_local_so. The following command will do
the job -

sage -c "from sage.all import cython_create_local_so;
cython_create_local_so('_laplace.pyx')"

Rajeev

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to