Using boost::fusion
compile time containers if fine with the fusion_algebra
and the default_operations
, as long as each of its elements support
- Multiplication with a scalar (*)
- Addition and subtraction (+,-)
- Resizing
This is the case for the elementary floating point types, like double
, float
, or even std::complex
. This is also the case for types supporting expression templates like the vector and matrix types from the MTL, boost::ublas, or vexcl and viennacl. But it is not possible for std::vector
, since vectors do not implement or overload the appropriate +*-/ operators. In this case you have three possibilities
- Choose an vector type supporting expression templates
- Implement a nested algebra which iterates the fusion sequence with fusion's
for_each
and calls the correctfor_each
from the sub algebra - Implement a custom operation which iterates over the elements of the fusion sequence.
Note 1: Resizing usually means, that if your type needs resizing you specialize is_resizable
to a compile time true, for example via
template<>
is_resizable< YourType > : boost::true_type { };
and specialize resize_impl<>
and same_size<>
. Have a look at the default implementations. This is really ease and should be only a one-liner.
Note 2: If you also need step size control and you choose to take a vector type with expresson templates the operator /
and the function max
must exist and they must perform element-wise division and element-wise max. This might be tricky to implement. If you need some help feel free to contact us again.