diff --git a/main/dsppp_guidelines.html b/main/dsppp_guidelines.html index c6f82d17..a8756b80 100644 --- a/main/dsppp_guidelines.html +++ b/main/dsppp_guidelines.html @@ -131,7 +131,13 @@
If you use dynamic objects in your algorithms and some temporaries need to be allocated, they'll generally be allocated through a malloc
since the size is not known at build time. It can be an issue:
If you need to allocate those temporaries very often then it may be better to write the algorithm in such a way that the temporary can be reused between different calls.
+The function implementing your algorithm would have additional arguments for the temporary matrixes and vectors required in the algorithm.
It means that by default the memory allocator is TMP_ALLOC
.
This TMP_ALLOC
#define
can be changed if you define it before including any header from the library.
This TMP_ALLOC
is a #define
and can be changed if you define it before including any header from the library.
An allocator should implement a template like:
As we have seen in the previous sections, there are two kind of vectors:
Vector<T>
with a dimension know at runtimeVector<T>
with a dimension known at runtimeVector<T,NB>
with a dimension known at build timeThe former vectors are called "dynamic" ins this library. The later are called "static".
+The former vectors are called "dynamic" in this library. The later are called "static".
This naming "static" / "dynamic" is referring to the dimension. With "dynamic" vectors the same code can, at runtime, create vectors of different length based on a runtime length.
With "static" vectors : the length is fixed at build time and will never change at runtime.
-Note that the library also have "static" / "dynamic" matrixes. So, we are going to use "objects" to cover both cases
+Note that the library also have "static" / "dynamic" matrixes. So, we are going to use the name "object" to cover both cases in the below explanations.
The advantage of static objects is that the dimension is known at build time. The compiler can thus generate an algorithm that is specialized for those dimensions and thus more efficient.
With static objects it is also possible to use different memory allocator with better performances and determinism.
-But, with static objects, objects of different dimension are considered as different types. The compiler will generate different implementation so it will have an impact on the code dimension.
-If you need lots of objects of different dimensions, or if the dimensions are nort known at build time, then you need to use dynamic object
+But, with static objects, objects of different dimension are considered as different types. The compiler will generate different implementation so it will have an impact on the code size.
+If you need lots of objects of different dimensions, or if the dimensions are not known at build time, then you need to use dynamic object
With dynamic objects, the dimension is know at runtime. So object of different dimensions have the same datatype and the compiler is generating only one implementation for all those objects. It cannot generate specialized implementations based on the dimension. It is better for code size, but the implementations will be less efficient.
diff --git a/main/dsppp_template.html b/main/dsppp_template.html index 5688f76f..feb35340 100644 --- a/main/dsppp_template.html +++ b/main/dsppp_template.html @@ -147,6 +147,7 @@And if the function is used with a float64_t *
, the compiler would generate code for a function using float64_t
.
The generic arm_add
source code is a template used to generate different implementations. It is like a code generator.
And if the compiler is unable to generate an implementation because the type variable T
is replaced by a type with no addition operator, then it would be detected by the compiler.
Note that in C++, you can also use overloading of functions. They'll use the same name (but different arguments) but they won't share the same source code.
C++ templates also apply to structs and classes.
diff --git a/main/dsppp_vector.html b/main/dsppp_vector.html index ea6a9aba..de982cd2 100644 --- a/main/dsppp_vector.html +++ b/main/dsppp_vector.html @@ -177,7 +177,7 @@It is advised to always use the copy
operator (even with normal vectors).
Virtual vectors can have a stride:
This line sets the odd elements of the vector to 0.0f
. It is creating a vvirtual vector with stride 2
and starting at index 1
of first vector.
This line sets the odd elements of the vector to 0.0f
. It is creating a virtual vector with stride 2
and starting at index 1
of first vector.
Then, all elements of this virtual vector are set to 0.0f
.
The sub
API is:
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 <fixed_point>
should be used before <matrix>
If fixed point datatypes are required, #include <dsppp/fixed_point>
should be used before <dsppp/matrix>
Fixed point requires the use of CMSIS-DSP.