octave-maintainers
[Top][All Lists]
Advanced

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

Re: matlab compatibility of od45 with adaptive stepping


From: Carlo De Falco
Subject: Re: matlab compatibility of od45 with adaptive stepping
Date: Sun, 11 Oct 2015 11:22:33 +0000

On 11 Oct 2015, at 12:57, Sebastian Schoeps <address@hidden> wrote:

> But Carlo indicated that we might have to rewrite a lot.
Actually we need to delete a lot of code, but the new version will be much 
simpler in the end.
In pseudo code the new version should be something as simple as:

---------------------------------------------------------------
function [t, x] = adaptive (fun, stepper, tspan, x0)

  fixed_times = numel (tspan) > 2;

  t_new = t_old = t = tspan(1);
  x_new = x_old = x = x0;
  dt = initial_step ();

  iout  = istep = 1;
  while (t_old < tspan(end))

    [t_new, x_new, error] = stepper (fun, t_old, x_old);

    if (error < tol)
      t_old = t_new;
      x_old = x_new;
      if (fixed_times)
        t_caught = find ((t(iout:end) > t_old) & (t(iout:end) <= t_new));
        if (! isempty (t_caught))
          iout = max (t_caught);
          x(:, t_caught) = interpolate ([t_old, t_new], [x_old, x_new],
                                        t(t_caught));
          istep++;
        endif
      else
        t(++istep) = t_old = t_new;
        x(:, istep) = x_old = x_new;
        iout = istep;
      endif
    endif

    dt = new_step (dt, error, tol);
  endwhile
  
endfunction
---------------------------------------------------------------

The main difficulty in writing the patch is understanding all the output flags 
and maintaining 
compatibility so that high level interface functions such as ode45 do not 
require too many modifications.

c.


reply via email to

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