function - c++ odeint - integrate a static ode -


i have trouble c++ program , not enough in c++... please me ?

so use boost::odeint. i've got ode , integration function, coming library, in class c. i've got error "ode" has non-static (error: reference non-static member function must called). if integrate , ode in same class.

how can make integration function uses static ode ?

thank in advance !

class c { public : typedef boost::array< double , 3 > state_type; c(const state_type &b); ~c();  const void ode( const state_type &x , state_type &dxdt , double t); void write_out( const state_type &x , const double t ); void integration();  private : const state_type x; };  void c :: ode(const state_type &x , state_type &dxdt , double t) { (...) }  void c :: integration() {     out.open( "results.txt" );     integrate_const( runge_kutta_fehlberg78< state_type >() , ode,                     x , 0.0 , 10.0 , 0.01, write_out );     out.close(); }  ## main.cpp  using namespace std; using namespace boost::numeric::odeint;   int main(int argc, const char * argv[]) {  c::state_type x = {{ 10.0 , 10.0 , 10.0 }}; c com1 (x);  com1.integration();  return 0; } 

i see 2 problems:

first, remove const in definition of x class member:

class c {     /* ... */     state_type x; } 

second, defining ode in terms of member function possible need bind current object. easier define ode via bracket operator operator(). replace ode with

void operator()( const state_type &x , state_type &dxdt , double t); 

and call ode via

integrate_const( runge_kutta_fehlberg78< state_type >() , boost::ref( *this ) ,                 x , 0.0 , 10.0 , 0.01, write_out ); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -