[SciPy-user] about weave performance evaluation
Pau Gargallo
pau.gargallo at gmail.com
Tue Oct 25 07:45:53 CDT 2005
Hi all,
I'm not completely sure but it seems to me that there is an error in
the performance evaluation of pure python, scipy, weave, fortran and
C++ implementations of the laplace equation solver in
http://www.scipy.org/documentation/weave/weaveperformance.html
the code used to solve the laplace equation in pure python is:
for i in range(1, nx-1):
for j in range(1, ny-1):
u[i,j] = ((u[i-1, j] + u[i+1, j])*dy**2 +
(u[i, j-1] + u[i, j+1])*dx**2)/(2.0*(dx**2 + dy**2))
my guess is that this implementation overwrites u while running the
loop. In other terms, when computing the term u[i,j], the terms
u[i-1,j] and u[i,j-1] are used, and these terms where already modified
in previous iterations.
The same error is done in the weave.inline, fortran and C++
implementations, so as they are all computing the same wrong algorithm
this may not be a problem when evaluation performances. However the
scipy (or numeric) and weave.blitz implementation is:
u[1:-1, 1:-1] = ((u[0:-2, 1:-1] + u[2:, 1:-1])*dy2 +
(u[1:-1,0:-2] + u[1:-1, 2:])*dx2)*dnr_inv
the previous error is not in this implementation so the code is not
computing the same algorithm, and comparisons in the execution times
would make no sense.
Is my guess true?
should the performances be reevaluated?
thank you,
pau
More information about the SciPy-user
mailing list