Dear swig-user group!
I am new to Swig and after a couple of successfully performed tests (the
numpyi. pdf document helped a lot), I decided to create a "simple"
function which receives a 1D NumPy array and returns ANOTHER. The simple
question is... is there any way to create a function which accept a
vector and returns another vector?
something like
>>>mymodule.myfunc(inputarray)
>>> array([ 20.25, 12.25, 6.25, 2.25, 0.25, 0.25, 2.25,
6.25, 12.25, 20.25])
The only solution I found was the following.
My C function is defined as follows:
void sse(double *vec, int n); // actually I wanted to use void sse
(double *invec, double *outvec, int size);
Then I use In-Place arrays:
%apply (double *INPLACE_ARRAY1, int DIM1) { (double *vec, int n)}
and modify the function to receive only one array which is gonna be
transformed. After that I modified my function
%pythoncode{
def ssem(list):
a = np.array(list,dtype=float)
sse(a)
return a
}
Now I have only to use ssem in stead of sse. :(
Is there any better/simple way to do it?
Thanks a lot in advance!!!
Jose.
------------------------------------------------------------------------------
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user