
Boost : 
From: Victor A. Wagner, Jr. (vawjr_at_[hidden])
Date: 20021023 11:58:47
At Wednesday 2002/10/23 03:23, Martin Weiser <weiser_at_[hidden]> wrote:
>On Mittwoch, 23. Oktober 2002 11:34, Victor A. Wagner, Jr. wrote:
[deleted]
> > >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;
//not really.... for example (delete the previous line (return dx*dt;))
static double x = 0.0;
static double old_x, old_dt;
static int step = 0;
static bool first_time = true;
double new_x;
if (first_time) {
new_x = dx * dt;
first_time = false;
} else {
//perform some multistep method
new_x = multistep(old_x,old_dt,x,dt);
}
old_x = x;
old_dt = dt;
++step; // not sure what this does
return x += new_x;
>}
Now, I've made NO changes to what was in the header file describing the
function.
I don't see how one could say the "interface" changed.
Of course, I prefer the function object idea as you show below, but I don't
follow your comment about "changing the interface".
Unless you're referring to the obvious change from a free function to a
member function, but somehow I don't think that's what you meant.
>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
>
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Victor A. Wagner Jr. http://rudbek.com
PGP RSA fingerprint = 4D20 EBF6 0101 B069 3817 8DBF C846 E47A
PGP DH fingerprint = 98BC 65E3 1A19 43EC 3908 65B9 F755 E6F4 63BB 9D93
The five most dangerous words in the English language:
"There oughta be a law"
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk