Thanks all for your help. The path I chose was to redo my indexing - that was the path of least resistance. I'm not sure where the blitz errors came from - the same code compiled clean with inline, so that is a mystery (I did modify the arrays for blitz before compiling). I also created all the arrays I wanted returned in numpy first - which makes for a really long function call, but it works and it is not too awkward. I got a speed up of x37 on my real test. On Sat, 17 Nov 2007 18:16:26 -0500 "william ratcliff" <william.ratcliff@gmail.com> wrote:
I had good luck with it using blitz type converters (though if there's a bug in the C code, it's painful to find ;>). Did you look at the array3d example that came with the code? So far, I've been able to pass 1,2, and 3d arrays successfully. But, I've been cheating and creating the arrays that I want returned in numpy before calling the routine in weave and passing them in as arguments. I modify them within weave, and then check the results when weave terminates to make sure they have the values I think they should have in numpy. Then I didn't have to work on figuring out return types, allocating memory,etc. I also use blitz type converters.
What kind of errors are you getting? When I was writing my first program using weave, I got tons of errors--even if it was something as minor as forgetting a ";" in one of the lines of code--one helpful thing to do is to find the temporary directory where weave stores the c++ versions of your code and deleting it--there should be two directories. However, if it's not a simple question of stale code lying around, then wade through the pages of output and try to find out whether there is a simple bug in your C code. The next possible source of error could be a compiler issue--for example, I normally use an older version of gcc (I forget, something like 3.4) and upgraded to version 4.x (one of the most recent) and found that it no longer worked. Is the real code involved something simple enough that you can post it?
Cheers, William
On Nov 17, 2007 5:44 PM, Alan Jackson <alan@ajackson.org> wrote:
On Sat, 17 Nov 2007 22:46:59 +0100 Gael Varoquaux <gael.varoquaux@normalesup.org> wrote:
On Sat, Nov 17, 2007 at 03:30:10PM -0600, Alan Jackson wrote:
This is probably an astonishingly simple question, but I've been struggling for some time with it.
I am trying to work with weave for the first time, and it is becoming clear that I don't understand how 2D arrays get passed.
Me neither. This is why I use the blitz converter. I modified your example to use the vlitz converters, it is just so much nicer:
Well, with my *real* code, blitz gave me several pages of errors - I tried treating the 2D arrays as a 1D array, doing all the index arithmetic myself, and that seems to work. Which strikes me as odd...
-- ----------------------------------------------------------------------- | Alan K. Jackson | To see a World in a Grain of Sand | | alan@ajackson.org | And a Heaven in a Wild Flower, | | www.ajackson.org | Hold Infinity in the palm of your hand | | Houston, Texas | And Eternity in an hour. - Blake | ----------------------------------------------------------------------- _______________________________________________
SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
-- ----------------------------------------------------------------------- | Alan K. Jackson | To see a World in a Grain of Sand | | alan@ajackson.org | And a Heaven in a Wild Flower, | | www.ajackson.org | Hold Infinity in the palm of your hand | | Houston, Texas | And Eternity in an hour. - Blake | -----------------------------------------------------------------------