Definitely use Cython. 

For array of doubles, say, you just need a sage/libs/my_library.pyx with

include "stdsage.pxi"

cdef extern from "my_library.h"
    my_c_function(double*)

def my_python_function(values):
    cdef double * c_values = <double*> 
sage_malloc(sizeof(double)*len(values))
    for i,v in enumerate(values):
        c_values[i] = values[i]
    my_c_function(c_values)






On Wednesday, September 25, 2013 10:08:24 AM UTC+1, mmarco wrote:
>
> We are working on a c library to do homotoy continuation of polynomial 
> roots using interval arithmetic. Our idea is to make a spkg with it, and 
> write some functions in the sage library that would use it (in particular, 
> to compute the fundamental group of the complement of an algebraic curve). 
> so i have a question:
>
> how should we pass the data to the library, and retrieve it back? Both the 
> input and output can be seen as an array of mpfr reals (or, depending on 
> the version, floats or doubles). The length of the arrays is not known a 
> priori.
>
> Which should be the best way to go? Write our interface in cython? or use 
> ctypes? And in any case, is there some easy tutorial that we could follow?
>
> Thanks in advance.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to