Python crash after using weave inline
Soren
soren.skou.nielsen at gmail.com
Wed Apr 18 08:45:43 EDT 2007
Hi,
I have a strange and very annoying problem when using weave in scipy..
when I run the code below.. the first time it needs to compile.. it
says <compiling> and then python.exe crashes! and no result is shown..
the second time i run it, it does not compile but gives the completely
wrong answer.. prints a matrix of all zeros except for point 1,1 in
the matrix which seems to have some random high number like
-5.39403959e+08. .... !!??
Basicly I run through a 10 by 10 matrix do some calculations with
respect to some center values x_c and y_c and insert the result into
the empty numpy matrix array "res".
Any help is appreciated!
Thanks,
Sroren
from numpy import *
from scipy import weave
from scipy.weave import converters
def cartPolFast(xlen, ylen, x_c, y_c):
res = zeros((xlen,ylen))
code = """
{
int xlen, ylen, x_c, y_c;
double rel_x, rel_y;
int x, y;
for( x = 0; x == xlen; x++)
for( y = 0; y == ylen; y++)
rel_x = x-x_c;
rel_y = y_c-y;
res(x,y) = rel_y*rel_y;
}
"""
weave.inline(code,['xlen','ylen','x_c','y_c','res'],
type_converters=converters.blitz, compiler="gcc")
return res
if __name__ == "__main__":
tst = cartPolFast(10,10,5,5)
print tst
More information about the Python-list
mailing list