[SciPy-user] Swig and numpy again

Jaonary Rabarisoa jaonary@gmail....
Wed Oct 17 05:19:38 CDT 2007

Hi all,

I have another question about using numpy.i interface file. There are a lot
of macro and type maps defined
in this file that we can use to write rapidly a c/c++ extenstion code that
use numpy. But there is some case
that causes  problem to me. Suppose, to be simple that I want too wrap a
function that compute an element
wise sum of two matricies. The c/c++ function prototype could be like this :

void prod(double* A,int row_A,int col_A,double* B,in row_B,int col_B,double*
      res[i] = A[i]+B[i];

in python, I'd like to call this function like below :

A = numpy.ones((10,10))
B = numpy.ones((10,10))

R = prod(A,B)

There is a type map name ARGOUT_ARRAY in numpy.i but it is not really suited
for my situation. In
fact, with 2d array it needs the size of res to be hard code and with 1D
array I have to pass the size of the result
as argument in my python code (R = prod(A,B,size of r)). So how can I solve
this ? Any help will be appreciated.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20071017/c4ded7d5/attachment.html 

More information about the SciPy-user mailing list