Trying to wrap an existing library.
I managed to at least get started with a .spyx file as follows:
----------------------------------------
cdef extern from "stdlib.h":
  void *malloc(size_t size)
  int free(void*)
  int sizeof()
cdef extern from "func.h":
  int func( int n, float* x )
  cdef double* d

  def __cinit__(self):
      self.d = <double*>malloc( sizeof(double))
      self.n = 1
  def __dealloc__(self):
      free( self.d )
  def func( self, data ):
      cdef int i
      self.n = len(data)
      free( self.d )
      self.d = <double*> malloc( self.n*sizeof(double) )
      for i from 0 <= i < self.n:
          self.d[i] = data[i]
      func( self.n, self.d )
      l = []
      for i from 0 <= i < self.n:
         l.append( d[i] )
      return l
-------------------------
but this leaves much to be desired.
It should be a fairly standard operation
for which sage has good solutions.

Could someone please give me some pointers
as to how to improve the above?

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

Reply via email to