[Numpy-discussion] indexing numpy arrays in extensions created with ext_tools
Søren Nielsen
soren.skou.nielsen at gmail.com
Fri Oct 31 11:28:38 EDT 2008
Hi,
I'm trying to make a weave python extension to use in my program. I already
did it in inline, but that doesn't work with py2exe (needs compiler), so I'm
creating extensions instead using ext_tools.
Is there a way I can use blitz with ext_tools? so that I can refer to numpy
arrays like a(x,y) in the c code?? I have alot of 2D arrays that needs
indexing in the C code.. right now I can only index one dimension since the
first is always zero for some reason.. so if I write a[1,1] in the c code, I
still get returned the a[0,1]
Any help is appreciated!
Thanks,
Soren
Some silly test code:
-----------------------------------------
mod = ext_tools.ext_module('test_ext')
a = zeros((2,2))
x = 1
y = 0
test_code = """
py::tuple args(1);
if(a[x,y] == 1)
{
args[0] = 1;
}
else
{
args[0] = 0;
}
args[0] = a[x,y];
return_val = args;
"""
ravg = ext_tools.ext_function('test', test_code, ['a', 'x', 'y'])
mod.add_function(ravg)
mod.compile()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20081031/21f43403/attachment.html>
More information about the NumPy-Discussion
mailing list