help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LSODE Question - External Inputs?


From: Olaf Till
Subject: Re: LSODE Question - External Inputs?
Date: Fri, 24 Feb 2012 15:19:42 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

On Fri, Feb 24, 2012 at 05:40:47AM -0800, damian.harty wrote:
> I don't mind the code I have now unless there is some particular reason it
> isn't preferred?

It seems that you wanted to send some code with your last e-mail,
but it was not there.

> However, I do have a new quest (same model) which is to pass back some of
> the intermediate variables.

Lsode (and other solvers) will call your user function with unpredictable
values of the state variables and for the independent variable. So it
would be not much use to fiddle with global variables to get intermediate
values back. It would be an idea to expand lsode to keep track of
intermediate variables, but currently it does not do so.

But the problem is solved easily. Make your function 'xdot' return more
than one variable. Only the first returned variable, the derivative, will
be used by lsode. In the second and further returned variables, you can
return intermediates from xdot. After lsode is ready, you will have the
values of the state variables corresponding to the supplied values of the
independent variable. Now feed these values into xdot and you will have
the intermediate variables as its second and further output arguments.

For this to work efficiently, you should program xdot in a way that it
is able to handle vector inputs (with vectorized computations), though
lsode itself will only call it with scalars. If not vectorized, you will
have to call xdot in a loop, which is much slower.

(I did not examine the rest of your mail, hope I havn't missed the point.)

Olaf

--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]