Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-21 Thread Alexander Schmolck
David Cournapeau [EMAIL PROTECTED] writes: Alexander Schmolck wrote: Charles R Harris [EMAIL PROTECTED] writes: The automatic handling of pointers for the default allocation type is also convenient and makes it reasonable to have functions return matrices and vectors. Hmm, I

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-21 Thread Bill Baxter
On 9/21/07, Alexander Schmolck [EMAIL PROTECTED] wrote: David Cournapeau [EMAIL PROTECTED] writes: Alexander Schmolck wrote: Charles R Harris [EMAIL PROTECTED] writes: The automatic handling of pointers for the default allocation type is also convenient and makes it reasonable to

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-20 Thread Alexander Schmolck
Charles R Harris [EMAIL PROTECTED] writes: The automatic handling of pointers for the default allocation type is also convenient and makes it reasonable to have functions return matrices and vectors. Hmm, I wonder whether I missed something when I read the manual. I didn't see anything in the

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-20 Thread David Cournapeau
Alexander Schmolck wrote: Charles R Harris [EMAIL PROTECTED] writes: The automatic handling of pointers for the default allocation type is also convenient and makes it reasonable to have functions return matrices and vectors. Hmm, I wonder whether I missed something when I read

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-18 Thread Charles R Harris
On 9/17/07, David Cournapeau [EMAIL PROTECTED] wrote: Christopher Barker wrote: David Cournapeau wrote: Christopher Barker wrote: My real question is what compiler and library writers are doing -- has anyone (OK, I guess MS and gcc are all I care about anyway) built anything optimized

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-17 Thread David Cournapeau
Christopher Barker wrote: David Cournapeau wrote: Christopher Barker wrote: My real question is what compiler and library writers are doing -- has anyone (OK, I guess MS and gcc are all I care about anyway) built anything optimized for them? Are they going to dump them? Who knows? What do

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-16 Thread Charles R Harris
On 9/10/07, Christopher Barker [EMAIL PROTECTED] wrote: Thanks for you input Xavier. Xavier Gnata wrote: std:valarray are quite strange containers because they are not well integrated in the STL. I always use vector when I have to deal with arrays. ps : There are no real performance

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-16 Thread Christopher Barker
Charles R Harris wrote: On 9/10/07, *Christopher Barker* [EMAIL PROTECTED] STL either, so I'm not sure there is any downside to valarray. It looks like neither one [vector or valarray] supports any kind of view semantics, so for the purposes of numpy array wrapping, they really

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-10 Thread Christopher Barker
Thanks for you input Xavier. Xavier Gnata wrote: std:valarray are quite strange containers because they are not well integrated in the STL. I always use vector when I have to deal with arrays. ps : There are no real performance differences between vector and valarray (in my use cases...)

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-10 Thread Christopher Barker
Xavier Gnata wrote: Here it is :) Thanks, that's helpful. Am I reading it right? Are you running the python process embedded in your C++ app? (rather than extending?) valarray double Data (NbData); array = PyArray_SimpleNewFromData (NbDims, Dims, PyArray_DOUBLE, Data[0]); OK, so

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-10 Thread Matthieu Brucher
OK, so you've now got a view of the data from the valarray. Nice to know this works, but, of course, fragile if the valarray is re-sized or anything, so it probably won't work for us. Unless you use a special allocator/desallocator (I don't know if the latter is possible), I don't know how

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-10 Thread Xavier Gnata
Christopher Barker wrote: Xavier Gnata wrote: Here it is :) Thanks, that's helpful. Am I reading it right? Are you running the python process embedded in your C++ app? (rather than extending?) Yes! The point is this way I'm able to debug my C++ code plotting the array using

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-10 Thread Xavier Gnata
yeah! Looks good! Thanks a lot. Xavier Thanks! DG Lisandro Dalcin wrote: David, I'll try to show you what I do for a custom C++ class, of course this does not solve the issue resizing (my class does not actually support resizing, so this is fine for me): My custom class is a

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-08 Thread Xavier Gnata
Christopher Barker wrote: Xavier Gnata wrote: I'm using the numpy C API (PyArray_SimpleNewFromData) to perform the conversion but my code is written by hands. I'd like to see that. How are you getting the pointer to pass in to PyArray_SimpleNewFromData? It looks like you can do

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-08 Thread Xavier Gnata
Bryan Van de Ven wrote: Christopher Barker wrote: Does anyone know the status of support for valarrays now? I used std::valarray to implement a variant of the example Matrix class in Stroustrup's book (2D only) about two years ago. I was aware that is in disuse, by and large,

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-07 Thread David M. Cooke
Christopher Barker [EMAIL PROTECTED] writes: Joris De Ridder wrote: A related question, just out of curiosity: is there a technical reason why Numpy has been coded in C rather than C++? There was a fair bit of discussion about this back when the numarray project started, which was a

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-07 Thread David M. Cooke
Bill Spotz [EMAIL PROTECTED] writes: On Sep 5, 2007, at 11:38 AM, Christopher Barker wrote: Of course, it should be possible to write C++ wrappers around the core ND-array object, if anyone wants to take that on! boost::python has done this for Numeric, but last I checked, they have not

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-07 Thread Lisandro Dalcin
David, I'll try to show you what I do for a custom C++ class, of course this does not solve the issue resizing (my class does not actually support resizing, so this is fine for me): My custom class is a templatized one called DTable (is like a 2d contiguous array), but currently I only

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-07 Thread David Goldsmith
Thanks! DG Lisandro Dalcin wrote: David, I'll try to show you what I do for a custom C++ class, of course this does not solve the issue resizing (my class does not actually support resizing, so this is fine for me): My custom class is a templatized one called DTable (is like a 2d

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-06 Thread Matthieu Brucher
2007/9/5, Christopher Barker [EMAIL PROTECTED]: Matthieu Brucher wrote: Blitz++ is more or less avandoned. It uses indexes than can be not-portable between 32bits platforms and 64bits ones. Oh well -- that seems remarkably short sited, but would I have done better? Well, it's too bad

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-06 Thread Christopher Barker
Xavier Gnata wrote: I'm using the numpy C API (PyArray_SimpleNewFromData) to perform the conversion but my code is written by hands. I'd like to see that. How are you getting the pointer to pass in to PyArray_SimpleNewFromData? It looks like you can do something like: (VA is a

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Joris De Ridder
A related question, just out of curiosity: is there a technical reason why Numpy has been coded in C rather than C++? Joris On 05 Sep 2007, at 02:24, David Goldsmith wrote: Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share? Thanks! DG --

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Xavier Gnata
I'm using the numpy C API (PyArray_SimpleNewFromData) to perform the conversion but my code is written by hands. I would like to simplify it using SWIG but I also would like to see a good typemap valarray = numpy.array :) Joris : Historical ones? Maybe also the fact that distutils has some

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Travis Vaught
Have you seen this? http://www.scipy.org/Cookbook/SWIG_and_NumPy Also, the numpy/doc/swig directory has the simple typemaps. Travis On Sep 5, 2007, at 7:08 AM, Xavier Gnata wrote: I'm using the numpy C API (PyArray_SimpleNewFromData) to perform the conversion but my code is written by

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Bill Spotz
I have been considering adding some C++ STL support to numpy/doc/swig/ numpy.i. Probably std::vectorTYPE = PyArrayObject (and some std::complexTYPE support as well). Is this what you had in mind? On Sep 4, 2007, at 6:24 PM, David Goldsmith wrote: Anyone have a well-tested SWIG-based C++

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread David Goldsmith
Point of clarification: below well-tested = well-use-tested, not (necessarily) well-unit-tested. DG David Goldsmith wrote: Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share? Thanks! DG -- ERD/ORR/NOS/NOAA

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread David Goldsmith
No I hadn't - thanks! (Probably should have Google-d first, huh. :-[ ) DG Travis Vaught wrote: Have you seen this? http://www.scipy.org/Cookbook/SWIG_and_NumPy Also, the numpy/doc/swig directory has the simple typemaps. Travis On Sep 5, 2007, at 7:08 AM, Xavier Gnata wrote: I'm

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread David Goldsmith
Not presently, as the C++ code I need to wrap now is using the valarray class template (largely at my behest), though I (and I imagine others) might find this useful in the future. DG Bill Spotz wrote: I have been considering adding some C++ STL support to numpy/doc/swig/numpy.i. Probably

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Russell E. Owen
In article [EMAIL PROTECTED], Bill Spotz [EMAIL PROTECTED] wrote: I have been considering adding some C++ STL support to numpy/doc/swig/ numpy.i. Probably std::vectorTYPE = PyArrayObject (and some std::complexTYPE support as well). Is this what you had in mind? That sounds very useful,

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Christopher Barker
Joris De Ridder wrote: A related question, just out of curiosity: is there a technical reason why Numpy has been coded in C rather than C++? There was a fair bit of discussion about this back when the numarray project started, which was a re-implementation of the original Numeric. IIRC, one

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Bill Spotz
On Sep 5, 2007, at 11:19 AM, Christopher Barker wrote: Bill Spotz wrote: I have been considering adding some C++ STL support to numpy/doc/ swig/ numpy.i. Probably std::vectorTYPE = PyArrayObject (and some std::complexTYPE support as well). Is this what you had in mind? well,

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Bill Spotz
On Sep 5, 2007, at 11:38 AM, Christopher Barker wrote: Of course, it should be possible to write C++ wrappers around the core ND-array object, if anyone wants to take that on! boost::python has done this for Numeric, but last I checked, they have not upgraded to numpy. ** Bill Spotz

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Christopher Barker
Bill Spotz wrote: Yes, this resizing memory management issue is the main reason I haven't tried to implement it in numpy.i yet. thinking out loud A possibly better solution would be to develop a class that inherits from std::valarrayTYPE but also implements the array interface attributes

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Matthieu Brucher
He goes on to suggest that Blitz++ might have more of a future. (though it looks like he's involved with the Boost project now) Blitz++ is more or less avandoned. It uses indexes than can be not-portable between 32bits platforms and 64bits ones. Is there another alternative? At the moment,

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Bill Baxter
On 9/6/07, Christopher Barker [EMAIL PROTECTED] wrote: Bill Spotz wrote: However, I'm beginning to have my doubts about valarrays. I'm reading: Josuttis, Nicolai M. 1999. The C+= Standard Library: A Tutorial and Reference It's 8 years old now, but he writes: The valarray classes were not

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Christopher Barker
Matthieu Brucher wrote: Blitz++ is more or less avandoned. It uses indexes than can be not-portable between 32bits platforms and 64bits ones. Oh well -- that seems remarkably short sited, but would I have done better? The Boost.Array is a fixed-size array, determined at compile-time, Ah, I

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Philip Austin
Christopher Barker writes: I've seen that -- it does look like all we'd need is the header. So, can one: - create a Multiarray from an existing data pointer? - get the data pointer for an existing Multiarray? I think that's what I'd need to make the numpy array -

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Christopher Barker
Philip Austin wrote: Albert Strasheim has done some work on this: http://thread.gmane.org/gmane.comp.python.c++/11559/focus=11560 Thanks for the pointer. Not a lot of docs, and it looks like he's using boost::python, and I want to use SWIG, but I'm sure there's something useful in there.

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread David Goldsmith
Travis Vaught wrote: Have you seen this? http://www.scipy.org/Cookbook/SWIG_and_NumPy Unclear (to me): precisely what does one get from running python numpy/docs/swig/setup.py install, and is the product necessary, and if so, which other components rely on the product? I ask 'cause I'm

Re: [Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-05 Thread Bill Spotz
The setup.py script in numpy/doc/swig is for compiling test code for numpy.i. It is properly invoked by the Makefile, which will first run swig to generate the wrapper code for the test classes. All a developer, who is using swig to interface some code with numpy in python, needs is

[Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share?

2007-09-04 Thread David Goldsmith
Anyone have a well-tested SWIG-based C++ STL valarray = numpy.array typemap to share? Thanks! DG -- ERD/ORR/NOS/NOAA http://response.restoration.noaa.gov/emergencyresponse/ ___ Numpy-discussion mailing list Numpy-discussion@scipy.org