Boost logo

Boost :

From: Martin Weiser (weiser_at_[hidden])
Date: 2002-10-23 05:23:40


On Mittwoch, 23. Oktober 2002 11:34, Victor A. Wagner, Jr. wrote:
> At Wednesday 2002/10/23 01:16, Martin Weiser <weiser_at_[hidden]> wrote:
> >On Dienstag, 22. Oktober 2002 18:14, Victor A. Wagner, Jr. wrote:

> > > Though in the simulations we used
> > > to run, we _needed_ a signature something like:
> > >
> > > double integrate_step<method>(double next_delta_x, double
> > > next_delta_t);
> > >
> > > Where often, delta_t would be a constant over the "run". Other
> > > times, it varied.
> >
> >It seems as if given only dx and dt, the only possibility to implement
> >such a function is the explicit Euler scheme, i.e. rectangular
> >integration - unless you store computed points and perform some
> > multistep method. But I gather this would require an interface
> > change.
>
> I can't see why, method can include the information

Let me be more detailed in order to ensure we're talking about the same
things. Omitting genericity,

double integrate_step(double dx, double dt) {
        // compute increment from dx and dt. Only possibility:
        return dx*dt;
}

Or, the more sophisticated version:

class integrator {
        double x;
        double old_x, old_dt;
        int step;
public:
        integrator(): x(0), step(0) {}
        double integrate_step(double dx, double dt) {
                if (n==0) {
                        x = dt*dx;
                        old_x = 0;
                        old_dt = dt;
                } else {
                        // perform some second order multistep method
                        double DX = multistep(old_x,old_dt,x,dt,dx/dt);
                        old_dt = dt;
                        old_x = x;
                        x += DX;
                }
                ++step;
                return x;
        }
};

Is that what you mean? I'd call that different interfaces, even though
"integrate_step" has the same signature.

Yours,
Martin

-- 
Dr. Martin Weiser            Zuse Institute Berlin
weiser_at_[hidden]                Scientific Computing
http://www.zib.de/weiser     Numerical Analysis and Modelling

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk