OONumerics User : |
From: Peter Foelsche _at_[hidden] (_at_[hidden])
Date: 2005-02-16 16:38:04
"Problem" is not an object!
I would think you should create an object representing the ode
dx/dt=f(x, t)
with x and f() being a vector probably.
So you got already two objects -- the function f(t) and the vector x.
now you need just a function doing the integration
-- it gets passed the f() object and the x object and t.
If you want you can make the integration an interface so you could have
different implementation of this integration method.
// an interface representing the ode -- there may be different ones
class Iode
{ public:
virtual void calculateOde(
std::vector<double> *dx_dt,
const std::vector<double> &_x,
double _dTime) const = 0;
// returning the dimension of the ode
virtual unsigned int getDimension(void) const = 0;
};
// an interface representing an integration method -- there may be different
ones
class IIntegration
{ public:
virtual void integrate(
// input and output of the state vector
std::vector<double> *x,
// input and output of the time
double *pTime,
double _hSuggestedStep,
double _dMaxError,
const Iode &) const = 0;
};
-- btw I prefer pointers to non-const references
-- as they tend to obfuscate code
Peter
----- Original Message -----
From: "Aleksander Grm" <grm_at_[hidden]>
To: <oon-list_at_[hidden]>
Sent: Wednesday, February 16, 2005 11:43
Subject: [oon-list] how to make link to vector function in c++
> Dear all,
>
> I have problems to figure out how to do in elegant way in c++ the link
> for arbitrary function or operator.
>
> For example I have class Problem (ex. integrate system of ode). In
> Problem I create object Method (let say ode integrator). Then Problem
> has member function, which calculates the values of vector function (or
> operator()(...)) for ode system. This function (or operator) must be
> then passed to Method, which uses it to calculate the values of vector
> function at any time.
> I have no idea how to do it. Can somebody suggest me hint, hoe to do it.
>
> best + thanks
> Aleksander
> _______________________________________________
> oon-list mailing list
> oon-list_at_[hidden]
> http://www.oonumerics.org/mailman/listinfo.cgi/oon-list