Re: [Numpy-discussion] Global Numpy vector with Swig

2007-02-16 Thread Bill Spotz
OK, I looked at the varin, varout descriptions in the online manual, and they specifically mention global variables, but WOW is that documentation minimal. I would suggest asking Swig- [EMAIL PROTECTED] for some assistance. On Feb 16, 2007, at 1:10 PM, Bill Spotz wrote: > Andrea, > > It is

Re: [Numpy-discussion] Global Numpy vector with Swig

2007-02-16 Thread Bill Spotz
Andrea, It is my understanding that swig typemaps only apply to function arguments. Since what you are talking about is a global variable, I don't believe typemaps will help you. I would try %{ #include "header-that-contains-vec.h" npy_intp vec_dims[ ] = { (npy_intp) length_of_vec }; %} %re

Re: [Numpy-discussion] Global Numpy vector with Swig

2007-02-16 Thread Andrea Tomadin
Il giorno 15/feb/07, alle ore 22:26, Bill Spotz ha scritto: > It seems to me you would need to %ignore vec, so that it is not > wrapped as a raw pointer to a double, and then in your interface > file create a PyArrayObject whose data buffer points to vec (the > most efficient way to do this

Re: [Numpy-discussion] Global Numpy vector with Swig

2007-02-15 Thread Bill Spotz
It seems to me you would need to %ignore vec, so that it is not wrapped as a raw pointer to a double, and then in your interface file create a PyArrayObject whose data buffer points to vec (the most efficient way to do this is with %inline). Then use %rename to rename whatever you called y

[Numpy-discussion] Global Numpy vector with Swig

2007-02-15 Thread Andrea Tomadin
Hi, I need to pass a Numpy array to a C code wrapped by Swig. The array in the C code is a global variable declared as double *vec and I would like to set it in the calling Python module foo using e.g. foo.cvar.vec = numpy.zeros(10) so that the array is manipulated in place. I found out the exampl