[SciPy-User] Speeding up integrate.odeint with weave/blitz

Rob Clewley rob.clewley@gmail....
Fri Dec 10 16:58:25 CST 2010


Sebastian,

> Could you point me to some short code example where the "for" macro is used?

Actually I don't use it often myself. The syntax for defining
variables x_a through x_b (included) using dummy index "i" is:

for(i, a, b, expr_in_i)

where expr_in_i contains a mathematical definition for x_i and
involving any parameters defined, and variables, including x_a through
x_b, referred to using the syntax x[f(i)], where f(i) is an integer
arithmetical function of i. The for macro then creates a sequence of
expressions where each occurrence of `[f(i)]` is replaced with the
appropriate integer in square brackets.

E.g. a specification of variables x1, x2 and x3 coupled to their
neighbours in a ring could look like

specs = {'x[i]': 'for(i, 1, 3, x[i-1] + 2*x[i])',
              'x0': 'x2 + 2*x0'}

This required the special end-case definition for x0, that wraps back
to x2, in order to be valid. When parsed this will create a right-hand
side dX_dt function containing individual assignments for each x0, x1,
x2, and x3. For instance, the one for x1 will be an encoding of 'x0 +
2*x1'.

This works in essentially the same way as specifications in the older
program XPP (X-PhasePlane), for anyone familiar with that package's
syntax.

Hope that's what you wanted to know. BTW, this syntax structure just
enjoyed a small feature enhancement in the most recent update of
PyDSTool posted on sourceforge, thanks to your interest!

-- 
Robert Clewley, Ph.D.
Assistant Professor
Neuroscience Institute and
Department of Mathematics and Statistics
Georgia State University
PO Box 5030
Atlanta, GA 30302, USA

tel: 404-413-6420 fax: 404-413-5446
http://www2.gsu.edu/~matrhc
http://neuroscience.gsu.edu/rclewley.html


More information about the SciPy-User mailing list