odeint also works well with Boost.Units
- a library for compile time unit and dimension analysis. It works by decoding
unit information into the types of values. For a one-dimensional unit you
can just use the Boost.Unit types as state type, deriv type and time type
and hand the vector_space_algebra
to the stepper definition and everything works just fine:

If you want to solve more-dimensional problems the individual entries typically
have different units. That means that the state_type
is now possibly heterogeneous, meaning that every entry might have a different
type. To solve this problem, compile-time sequences from Boost.Fusion
can be used.

To illustrate how odeint works with Boost.Units
we use the harmonic oscillator as primary example. We start with defining
all quantities

Note, that the state_type
and the deriv_type are now
a compile-time fusion sequences. deriv_type
represents x' and is now different from the state type
as it has different unit definitions. Next, we define the ordinary differential
equation which is completely equivalent to the example in Harmonic
Oscillator:

When using compile-time sequences, the iteration over vector elements is
done by the fusion_algebra,
which is automatically chosen by odeint. For more on the state types /
algebras see chapter Adapt
your own state types.

It is quite easy but the compilation time might take very long. Furthermore,
the observer is defined a bit different