From: David F. <dav...@gm...> - 2012-07-30 08:35:01
|
On Mon, 30 Jul 2012 00:04:34 +0200, Oliver Willekens <oli...@el...> wrote: > 2012/7/29 David Froger <dav...@gm...> > > > Hi Oliver, > > > > > the numpy.i interface provides us with most of the items I need for a > > > project, however, I have a case whereby I build an array in C++ and need > > to > > > pass it to numpy. The size of the array is unknown at the beginning, so I > > > cannot use the numpy.i typedefs for ARGOUT_ARRAY1 (as these require you > > to > > > supply the dimension of the array to be returned). > > > > Could argoutview arrays be what you need? > > > > http://docs.scipy.org/doc/numpy/reference/swig.interface-file.html#argoutview-arrays > > > > I don't think so, unless I'm missing the point of argoutview. From the > example at http://www.scipy.org/Cookbook/SWIG_NumPy_examples , it looks > like here too the size of the array to be returned is known at compile > time, which is not the case. Actually, is this example, the typemap is not applied on my_ones (which take the size of the array as argument), but on my_set_ones (which does not take the size of the array as argument), and then my_set_ones is rename to set_ones... But another question: Do you want the C++ array to be copied in the numpy array (safe, ARGOUT_ARRAY1 + a helper function should words), or the numpy array to point on the C++ array (hard to make it safe, only required is array is very big and can not be duplicated, ARGOUTVIEW_ARRAY1 should works) ? |