Re: [Numpy-discussion] swig numpy2carray converters

2007-12-01 Thread Georg Holzmann
Hallo! * A new ARGOUTVIEW suite of typemaps is provided that allows your wrapped function to provide a pointer to internal data and that returns a numpy array encapsulating it. Thanks for integrating it ! * New typemaps are provided that correctly handle FORTRAN ordered 2D

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-30 Thread Sebastian Haase
On Nov 30, 2007 5:16 AM, Bill Spotz [EMAIL PROTECTED] wrote: I have just committed the latest version of numpy.i (a swig interface file for bridging between C arrays and numerical python) to the numpy svn repository. There are three relatively new features that are now supported: * It is

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-29 Thread Bill Spotz
I have just committed the latest version of numpy.i (a swig interface file for bridging between C arrays and numerical python) to the numpy svn repository. There are three relatively new features that are now supported: * It is now possible to wrap functions that expect integer arguments

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-26 Thread Georg Holzmann
Hallo! First, my plan is to add to numpy.i, typemaps for signatures like the following: %typemap(argout) (double** ARGOUT_ARRAY1, int* DIM1) It is important to note that even though the same argument *names* are used, this is a different typemap signature than

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-26 Thread Christopher Barker
Bill Spotz wrote: First, my plan is to add to numpy.i, typemaps for signatures like the following: %typemap(argout) (double** ARGOUT_ARRAY1, int* DIM1) It is important to note that even though the same argument *names* are used, this is a different typemap signature than

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-25 Thread Bill Spotz
OK, I'm going to try to get to this soon, but I want to discuss the interface some before committing to development. First, my plan is to add to numpy.i, typemaps for signatures like the following: %typemap(argout) (double** ARGOUT_ARRAY1, int* DIM1) It is important to note that even

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-21 Thread Christopher Barker
David.Goldsmith wrote: Chris, just to be clear, this is addressed to the OP, correct? yes, but if anyone else want to come up with one, that would work too. -Chris What would be great is a simple trimmed down example -- a small-as-you-can-make-it class with a method that shows what you

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-21 Thread Christopher Barker
Georg Holzmann wrote: As chris said, I need to make an example: http://grh.mur.at/software/numpy2carray.tar.gz Ah, I see now: /// @return internal big data without copying void getBigData(double **mtx, int *rows, int *cols) { *rows = drows; *cols = dcols; *mtx =

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-21 Thread Georg Holzmann
Hallo! As chris said, I need to make an example: http://grh.mur.at/software/numpy2carray.tar.gz I added the following class-example: class_example.h: the C++ code class_example.i: the SWIG interface file class_example_usage.py: example usage in python And some comments: Bill Spotz schrieb:

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-21 Thread Bill Spotz
On Nov 21, 2007, at 10:07 AM, Georg Holzmann wrote: BTW: what is the difference between PyArray_SimpleNewFromData() and PyArray_FromDimsAndData() ? (I don't have this book ...) PyArray_SimpleNewFromData() is the new version and PyArray_FromDimsAndData() is the old version :-) Travis may

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Georg Holzmann
Hallo! How is this better/different than numpy.i in: numpy/doc/swig/numpy.i The problem I had with numpy.i: - it copies the arrays on output (Argout Arrays) which was not possible for my algorithms (I have some very big matrices) - it is not possible to 2D or 3D Argout Arrays (why?), in

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread David.Goldsmith
Georg Holzmann wrote: (I also included an example for an interface to fortran style arrays). That, it doesn't have. It has ;) ... look in numpy2carray.i, FARRAY2_OUT (line 175). But yes, sorry, I did no example in example.cpp ... I'm pretty sure Chris meant that numpy.i doesn't

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Bill Spotz
On Nov 20, 2007, at 1:12 AM, Georg Holzmann wrote: The problem I had with numpy.i: - it copies the arrays on output (Argout Arrays) which was not possible for my algorithms (I have some very big matrices) Really? I worked pretty hard to avoid copies when they were not necessary. For

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Georg Holzmann
Hallo! Really? I worked pretty hard to avoid copies when they were not necessary. For the ARGOUT typemaps, I allocate an array of the requested size and then pass its data buffer to your function. If Yes but this means that you again allocate an array of the same size. E.g. in my

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Georg Holzmann
Hallo! E.g. in my algorithm I can have a very big internal matrix in C++ (say 700 MB - in fortran style). Now I want to have this matrix in numpy to plot some parts of it, get some data out of it ... whatever - if I again allocate an array of the same size, I am out of memory.

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Neal Becker
Christopher Barker wrote: Georg Holzmann wrote: Because I had some troubles in wrapping my C++ library in python/numpy, I did (another) numpy2carray.i file for SWIG. How is this better/different than numpy.i in: numpy/doc/swig/numpy.i With that interface file it is possible to

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Matthieu Brucher
If what you want is to provide a view from your C++ matrix, this is different. You must either : - propose the array interface - use a Python object inside your C++ matrix (this is to be done, I've a basic example in my blog) Of course : http://matt.eifelle.com/item/5 It's a basic

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Georg Holzmann
Hallo! Is there any doc on numpy.i usage? yes there is a pdf in /numpy/doc/swig ! LG Georg ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Georg Holzmann
Hallo! Of course : http://matt.eifelle.com/item/5 It's a basic version of the wrapper I use in my lab (pay attention to the constructor for instance), I hope you will be able to do something Thanks ! But this assumes that the data in my C++ library is stored in a PyArrayObject ? This is

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Matthieu Brucher
Of course : http://matt.eifelle.com/item/5 It's a basic version of the wrapper I use in my lab (pay attention to the constructor for instance), I hope you will be able to do something Thanks ! But this assumes that the data in my C++ library is stored in a PyArrayObject ? Yes, but if

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Bill Spotz
On Nov 20, 2007, at 7:24 AM, Georg Holzmann wrote: Yes but this means that you again allocate an array of the same size. E.g. in my algorithm I can have a very big internal matrix in C++ OK, so the key here is the *internal* matrix. I think you need to provide a way to extract that matrix

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread David.Goldsmith
Bill Spotz wrote: Again, see above for my use case. But the fortran ordering should not be that hard (only setting the flags and strides right, as in FARRAY2_OUT in numpy2carray.i) - but of course someone has to do it ... ;) Yes, it shouldn't be too hard. And I like your FARRAY

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Georg Holzmann
Hallo! OK, so the key here is the *internal* matrix. I think you need to provide a way to extract that matrix from the C++ application as a numpy array. Then you can provide it to your function/method as an INPLACE array. No new memory will be allocated. [...] The INPLACE typemaps

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Bill Spotz
Here is what I am proposing you do: in your interface file, add something like PyObject * getMatrix() { npy_intp dims[2] = { /* Obtain the dimensions to your internal matrix */ }; double * data = /* Obtain the pointer to you internal matrix */; return

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Christopher Barker
I'm a bit confused too. What would be great is a simple trimmed down example -- a small-as-you-can-make-it class with a method that shows what you need, perhaps with a little C++ sample that uses it. Then we can see how best to wrap it for python. -Chris -- Christopher Barker, Ph.D.

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread Christopher Barker
Christopher Barker wrote: What would be great is a simple trimmed down example -- .. and then we'd have an example to put in the numpy.i docs and examples, too. By the way Bill, I haven't forgotten the examples I said I'd add to the docs. I've been distracted away from my SWIG work lately,

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-20 Thread David.Goldsmith
Chris, just to be clear, this is addressed to the OP, correct? DG Christopher Barker wrote: I'm a bit confused too. What would be great is a simple trimmed down example -- a small-as-you-can-make-it class with a method that shows what you need, perhaps with a little C++ sample that uses

Re: [Numpy-discussion] swig numpy2carray converters

2007-11-19 Thread Christopher Barker
Georg Holzmann wrote: Because I had some troubles in wrapping my C++ library in python/numpy, I did (another) numpy2carray.i file for SWIG. How is this better/different than numpy.i in: numpy/doc/swig/numpy.i With that interface file it is possible to input/output arrays with or without

[Numpy-discussion] swig numpy2carray converters

2007-11-16 Thread Georg Holzmann
Hallo! Because I had some troubles in wrapping my C++ library in python/numpy, I did (another) numpy2carray.i file for SWIG. With that interface file it is possible to input/output arrays with or without copying data (I also included an example for an interface to fortran style arrays). I am