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

Stefan van der Walt stefan@sun.ac...
Sat Nov 17 17:13:44 CST 2007


On Sat, Nov 17, 2007 at 04:44:52PM -0600, Alan Jackson wrote:
> On Sat, 17 Nov 2007 22:46:59 +0100
> 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...

With Blitz, you are allowed M(i,j) indexing.  Otherwise, only the
memory address of the data is passed and, as you noticed, you must
calculate the offset yourself, i.e. M[i*nr_cols + j].

I modified your code to work with ctypes, which you may find
interesting.

Use

  python setup.py build_ext -i

to build the C file.  Then run alan.py.

Cheers
Stéfan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: setup.py
Type: text/x-python
Size: 461 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20071118/bf802271/attachment.py 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alan.c
Type: text/x-csrc
Size: 243 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20071118/bf802271/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alan.py
Type: text/x-python
Size: 1973 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20071118/bf802271/attachment-0001.py 


More information about the SciPy-user mailing list