From: Roy D. <Roy...@cc...> - 2001-01-05 13:53:48
|
Hello all. I'm trying to figure out a (simple) way to wrap extension functions using Numeric and swig. I want to use swig because I find the method described i ch. 12 of the user manual a bit too elaborate. The problem I'm facing with swig is that I cannot figure out a way to pass arrays to the functions expecting double pointers as input. Say, for example, that I want to wrap daxpy: 1. I put the function call interface into a swig file: void daxpy(int* n,double* a, double* x,int* incx, double* y, int* incy) 2. I want the function call visible to python to be something like: x =3D Numeric.arange(0.0,10.0) y =3D a[:] a =3D 1.0 daxpy(a,x,y) 3. To achieve 2. I make a python function that does the real call to daxpy: def daxpy(a,x,y): <Do consistency checking between x and y> =20 n =3D len(x) d_x =3D GetDataPointer(x) inc_x =3D <x's incrment> . . . daxpy_c(n,a,d_x,inc_x,d_y,inc_y)=20 (daxpy_c is the real daxpy) The problem I'm facing is that I cannot grab the internal data pointer from Numeric arrays and pass it to a function. Is there a simple way to do that without having to write a wrapper function in c for every function I want to use? How should I write the function GetDataPointer()? Any hints is greatly appreciated. Best regards, Roy. The Computer Center, University of Troms=F8, N-9037 TROMS=D8, Norway. phone:+47 77 64 41 07, fax:+47 77 64 41 00 Roy Dragseth, High Perfomance Computing System Administrator Direct call: +47 77 64 62 56. email: ro...@cc... |