headmyshoulder / odeint-v2

odeint - solving ordinary differential equations in c++ v2
http://headmyshoulder.github.com/odeint-v2/
Other
337 stars 102 forks source link

Performance improvement for BS-Stepper #185

Closed mmlanger closed 8 years ago

mmlanger commented 8 years ago

We could improve the performance of time_type calc_h_opt() by eliminating one (of two) pow calls.

Something like this: constructor: for (int i = 0; i < k_max+1; ++i) { ... m_facmin_table[i] = std::pow(STEPFAC3, val1 / static_cast(2*i+1)); ... }

calc_h_opt: ... value_type facmin = m_facmin_table[k]; ...

mariomulansky commented 8 years ago

I can confirm the observation that for simple systems (Lorenz, Roessler) the pow function within the step size adjustment can significantly contribute to the computation time. The suggested improvement looks reasonable and straight forward. We would be very welcome about a pull request introducing this improvement, otherwise I will implement this when I find some time the next weeks.

mmlanger commented 8 years ago

I'll prepare a pull request, but may take a bit of time (some weeks ;).