[SciPy-user] scipy 0.3.2 versus scipy 0.4.8
Travis Oliphant
oliphant.travis at ieee.org
Wed May 17 15:17:10 EDT 2006
GÓMEZ GARRIDO wrote:
> Dear all,
>
> I'm confused with the Scipy versions and its relationships with Numpy and Numeric. I have understood that the old Scipy (0.3.2 version) use Numeric and the new version (0.4.8) use Numpy.
>
> But I have a difference of very great speed among them in a script which integrate a ode's system. I have made comparisions with the same script in the same PC. One time I ran using scipy 0.3.2 with Numeric and later I uninstalled scipy and numeric and installed scipy 0.4.8 and numpy 0.9.6 and I run again using the new versions. The first time I take 7 seconds and the other 40 seconds. My question is, Is the old scipy fast than the new scipy? or Do I have any installation problem? However, I have followed the webpages instructions during the installation.
>
> My script is:
>
> from scipy import *
> def func(x, t, *args):
> xdot = [0.0, 5.0, 0.0, 15.0, 0.0, 0.0, 0.0]
> xdot[0] = + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0
> xdot[1] = - (x[1] * beta) + x[4] * beta
> xdot[2] = - (x[2] * beta) + x[5] * beta
> xdot[3] = + x[6] * beta - (x[3] * beta)
> xdot[4] = + alpha0 + (alpha + (x[3])**(n) * alpha1) / ((K)**(n) + (x[3])**(n)) - (k1 * x[4])
> xdot[5] = + alpha0 + (alpha + (x[1])**(n) * alpha1) / ((K)**(n) + (x[1])**(n)) - (k1 * x[5])
> xdot[6] = - (k1 * x[6]) + alpha0 + (alpha + (x[2])**(n) * alpha1) / ((K)**(n) + (x[2])**(n))
> g.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n'%(t, xdot[0], xdot[1], xdot[2], xdot[3], xdot[4], xdot[5], xdot[6]))
> return xdot
> t = arange(0, 12.01, 0.01)
> alpha0 = 0.0
> alpha1 = 0.0
> K = 1.0
> beta = 5.0
> n = 2.1
> k1 = 1.0
> alpha = 250.0
> cell = 1.0
> parameters = [alpha0, alpha1, K, beta, n, k1, alpha, cell]
> x_0 = [0.0, 5.0, 0.0, 15.0, 0.0, 0.0, 0.0]
> g = open('veloc.out', 'w')
> args = (parameters,g)
> for i in range(100):
> x = integrate.odeint(func, x_0, t, args)
>
>
>
The speed difference here is very likely related to the fact that
selection from arrays now returns numpy scalars instead of standard
Python scalars. The arithmetic for these scalars is done using ufuncs
instead of the builtin Python arithmetic. Since your inner-most
function uses a lot of scalar arithmetic, I'm pretty sure that that is
the slow-down.
The scalar math module in NumPy version 0.9.8 is intended to speed these
operations up. Your feedback after making use of the scalarmath module
will be greatly appreciated.
The scalarmath module still goes through ufuncs for certain mixed-mode
operations which means that certain commutative operations will be
slower written one way then the other. I don't like the current
situation and am looking for other options.
-Travis
More information about the SciPy-User
mailing list