[SciPy-user] What can and cannot be interpreted as a vector by odeint?
David Goldsmith
David.L.Goldsmith at noaa.gov
Fri Nov 17 02:28:24 EST 2006
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
...
>>> f([3,2]) # check that f does what I think it does
matrix([[ 2],
[-3]])
>>> # it does
>>> SI.odeint(f, (1,0), N.linspace(0,2*N.pi)) # should return cosine
over the domain 0 to 2pi, instead results in:
ValueError: object too deep for desired array
odepack.error: Result from function call is not a proper array of floats.
ValueError: object too deep for desired array
odepack.error: Result from function call is not a proper array of floats.
Illegal input detected (internal error).
Granted, my way is more verbose than how it's done in the test, but
what's wrong with it technically?
DG
PS: Is there a substantive difference between odeint and odepack (I
couldn't detect one from their resp. help doc)? And what're the chances
of getting more examples, described as such and placed in a folder
called Examples (even if it's only by essentially duplicating the
tests)? Thanks!
More information about the SciPy-User
mailing list