Commit a4e82f81 authored by Christophe Favergeon's avatar Christophe Favergeon
Browse files

Improvements to dsppp doxygen documentation

parent 1bd68d7e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
# Guidelines {#dsppp_guidelines}

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:

* Cost of the memory allocation
* Fragmentations

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.
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ struct Vector:Vector_Base<P>

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:

+5 −5
Original line number Diff line number Diff line
@@ -2,16 +2,16 @@

As we have seen in the previous sections, there are two kind of vectors:

* `Vector<T>` with a dimension know at runtime
* `Vector<T>` with a dimension known at runtime
* `Vector<T,NB>` with a dimension known at build time

The 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.

# Static objects

@@ -19,9 +19,9 @@ The advantage of static objects is that the dimension is known at build time. Th

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.
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 nort known at build time, then you need to use dynamic object
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

# Dynamic objects

+2 −1
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ The generic `arm_add` source code is a template used to generate different imple

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.

## Templates for datatypes

C++ templates also apply to structs and classes.
@@ -57,4 +59,3 @@ A template is just a C++ header. You only need to include this header to start u

Now you can look at an @ref dsppp_vector_example "example with vector operations" showing how to use the library
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ Virtual vectors can have a stride:
d.sub<2>(1) = 0.0f;
```

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`.

Loading