\[ \overrightarrow{d} = \overrightarrow{a} + \overrightarrow{b} * \overrightarrow{c} \]
we need to:
The headers are not yet part of the CMSIS-DSP packs since they are experimental. You can get them from the CMSIS-DSP github
If fixed point datatypes are required, #include <dsppp/fixed_point>
should be used before <dsppp/matrix>
Fixed point requires the use of CMSIS-DSP.
To create a vector a
you would write:
Vector<float32_t,NB>
is creating a vector of dimension NB
(known at build time) and datatype float32_t
. This creation is requiring some memory allocation and by default it is done with a malloc
.
It is possible to change the memory allocator for the vectors (and it is advised) to avoid using malloc
and instead have deterministic allocation without fragmentation.
See section Memory allocation.
Vectors of different dimensions are considered as being different types.
If you don't know the dimension at build time, you can use a different type of vector with:
For the trade-off between vector with build time dimension or runtime dimension please see the section Static / dynamic .
You can index the vectors as normal C arrays.
The computation can be written normally as :
Note that the computation can be parametrized with template arguments so the same computation could be used with any datatype or length. In that case you would have to define a template (and not just a normal function) and inside you would use something like:
where T
is a type variable coming from the template.
The operators +
, *
are computed in one pass with one loop : we have loop fusion and instead of having a loop per operator we have a loop for the whole computation.
To understand fusion and how to extend it with new operators, see section Fusion .
For an overview of vector operators, see section Vector . For an overview of matrix operators, see section Matrix .
The vectors can be displayed on stdout
for debug purpose.