[SciPy-user] What can and cannot be interpreted as a vector by odeint?

Robert Kern robert.kern at gmail.com
Fri Nov 17 02:41:00 EST 2006


David Goldsmith wrote:
> I was having trouble getting odeint to work w/ what I thought should be 
> legitimate vector arguments.  Looking for examples, I found 
> test_integrate.py and thus found at least one way which works.  However, 
> I'm left wondering why the following behaves the way it does:
> 
>  >>> import numpy as N
>  >>> import scipy as S
>  >>> from scipy import integrate as SI
>  >>> def f(y,t0=0):
> ...     return N.matrix([[0,1],[-1,0]])*N.matrix([[y[0]],[y[1]]]) # 
> [y,y']'=f([y,y']) = "simplest" harmonic oscillator system

You'll probably want to return a real array object, not a matrix. The
handwritten C code that wraps FORTRAN ODEPACK was written long before arrays
could be subclassed.

> PS: Is there a substantive difference between odeint and odepack (I 
> couldn't detect one from their resp. help doc)? 

odeint() is a function that wraps the functionality of ODEPACK. It is defined in
the module called odepack.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco



More information about the SciPy-User mailing list