If I integrate a system with boosts odeint
module, using a class to define the derivative, the destructor of this class is called very often.
- Is this behavior intended?
- Why is it the case?
- What should I do if I want to allocate arrays dynamically in this class?
For example, this code:
#include <iostream>
#include <boost/numeric/odeint.hpp>
using namespace std;
using namespace boost::numeric::odeint;
class foo
{
public:
virtual ~foo() {
std::cout << "destructor called" << std::endl;
}
void operator()(const double &x, double &dxdt, double t) const {
dxdt = 1;
}
};
int main( int argc , char **argv )
{
double x = 0;
const double dt = 0.1;
typedef runge_kutta4< double > stepper_type;
integrate_const( stepper_type() , foo(), x , 0.0 , 10.0 , dt);
return 0;
}
calls the destructor around 400 times. (I'am a beginner in c++)