| Reference | Tutorial | Example Code |
| smtk::rk4 | 4th order Runge-Kutta ODE solver |
Inheritance diagram for smtk::rk4< X, T, TS >:

Public Member Functions | |
| TS | get_current_t (void) const |
| int | get_num_diff_eq (void) const |
| TS | get_t_step (void) const |
| T | go (X *x, T t_to) |
| Advance to a given time. | |
| T | go (X *x, T t_to, T t_from) |
| Advance to a given time. | |
| T | go (X *x) |
| Advance one time step. | |
| void | go (X *x, T *t) |
| Advance one time step. | |
| bool | is_invalid (void) const |
| see if the object is invalid | |
| bool | is_valid (void) const |
| see if the object is valid | |
| rk4 (void(*difeq)(X *xdot, const X *x, T t), int num_diffeq, TS tstep, T t_0=(T) 0.0) | |
| void | set_current_t (T t) |
| Set the current time. | |
| TS | set_t_step (TS tstep_in) |
| Set the time step. | |
| virtual | ~rk4 (void) |
Protected Member Functions | |
| template<class T> | |
| T | invalidate (T t) |
| invalidate the object | |
| void | invalidate (void) |
| invalidate the object | |
| template<class T> | |
| T | validate (T t) |
| validate the object | |
| void | validate (void) |
| validate the object | |
| Reference | Tutorial | Example Code |
| smtk::rk4 | 4th order Runge-Kutta ODE solver |
A 4th order Runge-Kutta ordinary differential equation (ODE) solver. The solver step size is fixed, but you may request the solution at any time and it will do the looping for you and evolve the solution up to your requested time.
X is the data type of the dependent state variables.
T is the data type of the independent variable, here-in refered to as time.
TS is the data type of the independent vailable step size, here-in refered to as time step. You may in some cases want T to be a higher precession (like long double) than TS (double) in order to be able keep round off small when the independent variable (time) becomes large.
The class smtk::validation is inherited and will be set invalid only if memory allocation fails, which could happen if you have a large number of ODEs to solve, and this can only happen in the constructor of smtk::rk4.
| smtk::rk4< X, T, TS >::rk4 | ( | void(*)(X *xdot, const X *x, T t) | difeq, | |
| int | num_diffeq, | |||
| TS | tstep, | |||
| T | t_0 = (T) 0.0 | |||
| ) | [inline] |
| difeq | is a pointer to the function that computes the derivatives with respect to the independent variable. xdot is the array of derivatives that difeq will compute when called and t is the time that will be passed to the function difeq when it is called. difeq will be called many times when rk4::go() is called. | |
| num_diffeq | is the number of first order ODEs that are in difeq. | |
| tstep | is the step size used by the 4th order Runge-Kutta solver for each interation. Of course, smaller step size will be used if the requested independent variable value is less than the current independent variable value minus the step size. | |
| t_0 | is the initial value of the independent variable. |
Frees memory that was explictly allocated.
| TS smtk::rk4< X, T, TS >::get_current_t | ( | void | ) | const [inline] |
| int smtk::rk4< X, T, TS >::get_num_diff_eq | ( | void | ) | const [inline] |
| TS smtk::rk4< X, T, TS >::get_t_step | ( | void | ) | const [inline] |
| T smtk::rk4< X, T, TS >::go | ( | X * | x, | |
| T | t_to | |||
| ) | [inline] |
Advance to a given time.
Advance the state pointed to by x to a state with time t_to. The current time will be that which was the last time the system had evolved to.
| x | a pointer to an array with the current state. The values in this array will be changed to the new state. | |
| t_to | time to advance to. |
| T smtk::rk4< X, T, TS >::go | ( | X * | x, | |
| T | t_to, | |||
| T | t_from | |||
| ) | [inline] |
Advance to a given time.
Advance the state pointed to by x to a state with time t_to given the the current time is t_from.
| x | a pointer to an array with the current state. The values in this array will be changed to the new state. | |
| t_to | time to advance to. | |
| t_from | time to advance from. |
| T smtk::rk4< X, T, TS >::go | ( | X * | x | ) | [inline] |
| void smtk::rk4< X, T, TS >::go | ( | X * | x, | |
| T * | t | |||
| ) | [inline] |
| T smtk::validation::invalidate | ( | T | t | ) | [inline, protected, inherited] |
invalidate the object
Make the object invalid.
| void smtk::validation::invalidate | ( | void | ) | [inline, protected, inherited] |
invalidate the object
Make the object invalid.
| bool smtk::validation::is_invalid | ( | void | ) | const [inline, inherited] |
see if the object is invalid
| bool smtk::validation::is_valid | ( | void | ) | const [inline, inherited] |
see if the object is valid
| void smtk::rk4< X, T, TS >::set_current_t | ( | T | t | ) | [inline] |
| TS smtk::rk4< X, T, TS >::set_t_step | ( | TS | tstep_in | ) | [inline] |
| T smtk::validation::validate | ( | T | t | ) | [inline, protected, inherited] |
validate the object
Make the object valid.
| void smtk::validation::validate | ( | void | ) | [inline, protected, inherited] |
validate the object
Make the object valid.
1.5.2