odeint/libs/numeric/odeint/doc/details_boost_ref.qbk
2012-04-02 20:27:51 +02:00

21 lines
994 B
Plaintext

[section Using boost::ref]
In odeint all system functions and observers are passed by value. For example, if you call a `do_step` method of a particular stepper or the integration functions your system and your stepper will be passed by value:
[c++]
``
rk4.do_step( sys , x , t , dt ); // pass sys by value
``
This behaviour is suitable for most systems, especially if your system only does not contain any data or only a few parameters. However, in some cases you might pass some large amount of data with you system function and passing them by value is not desired since the data will be copied.
In such cases you can easily use `boost::ref` (and its relative `boost::cref`) which passes its argument by reference (or const reference). odeint will unpack the arguments and no copying at all of you system will take place:
``
rk4.do_step( boost::ref( sys ) , x , t , dt ); // pass sys as references
``
The same mechanism can for the observers in the integrate functions.
[endsect]