1 
2 #include "RTE_Components.h"
3 #include  CMSIS_device_header
4 
5 #if defined(MPS3)
6 #include "cmsis_driver_config.h"
7 #include "stdout_USART.h"
8 #endif
9 
10 #include <iostream>
11 
12 #include <dsppp/memory_pool.hpp>
13 #include <dsppp/fixed_point.hpp>
14 #include <dsppp/matrix.hpp>
15 
16 using namespace arm_cmsis_dsp;
17 
18 
main(void)19 int main(void)
20 {
21 #if defined(MPS3)
22     stdout_init();
23 #endif
24 
25     std::cout << "Vector operation examples\r\n";
26 
27     constexpr int NB = 32;
28 
29     // float32 example
30 
31     Vector<float32_t,NB> a;
32     Vector<float32_t,NB> b;
33     Vector<float32_t,NB> c;
34 
35     for(int i = 0;i< NB;i++)
36     {
37         a[i] = b[i] = c[i] = i;
38     }
39 
40 
41     Vector<float32_t,NB> d = a + b * c;
42 
43 
44     std::cout << "Result = " << d ;
45 
46     // Vector view example 1
47     auto subD = d.sub(2);
48     subD = subD + 2.0f;
49 
50     // d vector has been modified starting from the 3rd element
51     // (index 2)
52     std::cout << "Result = " << d ;
53 
54     // Now we set all odd elements to 0.
55     d.sub<2>(1) = 0.0f;
56     std::cout << "Result = " << d ;
57 
58 
59     // Q15 example
60     Vector<Q15,NB> aQ15;
61     Vector<Q15,NB> bQ15;
62     Vector<Q15,NB> cQ15;
63 
64     for(int i = 0;i< NB;i++)
65     {
66         aQ15[i] = bQ15[i] = cQ15[i] = Q15(i);
67     }
68 
69 
70     Vector<Q15,NB> dQ15 = aQ15 + bQ15 * cQ15;
71 
72 
73     std::cout << "Result = " << dQ15 ;
74 
75 
76 
77 
78 #if defined(MPS3)
79     while(1);
80 #endif
81 }
82 
83 
84