If you want to compute the dot product:
\[ <scale*(\overrightarrow{a}+\overrightarrow{b}),\overrightarrow{c}*\overrightarrow{d}> \]
with CMSIS-DSP, you would write:
There are several limitations with this way of writing the code:
_f32
suffix changed if the developer wants to use another datatypetmp1
,tmp2
,tmp3
,tmp4
)arm_add_f32
, two loads, an add instruction and a store. It is not enough to enable the compiler to reorder the instructions to improve the performanceWith this new C++ template library, you can write:
The code generated by this line computes the dot product in one pass with all the operators (+
, *
) included in the loop. There is no more any temporary buffers.
Let's look at another example:
\[ \overrightarrow{d} = \overrightarrow{a} + \overrightarrow{b} * \overrightarrow{c} \]
With the C++ library, it can be written as:
Here again : all the vector operations (+
,*
) are done in one pass with one loop. There is no more any temporary buffer.
If you're coming from C and does not know anything about C++ templates, we have a very quick introduction : The minimum you need to know about C++ template to use this library.
You can also jump directly to an example with vector operations.