[SciPy-user] 2D arrays in weave.inline

william ratcliff william.ratcliff at gmail.com
Sat Nov 17 18:16:26 EST 2007


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 at ajackson.org> wrote:
> On Sat, 17 Nov 2007 22:46:59 +0100
> Gael Varoquaux <gael.varoquaux at 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 at 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 at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list