1 extern "C" {
2     extern void col_test();
3 }
4 
5 #include "allocator.h"
6 
7 #include <dsppp/arch.hpp>
8 #include <dsppp/fixed_point.hpp>
9 #include <dsppp/matrix.hpp>
10 
11 #include <iostream>
12 
13 #include <cmsis_tests.h>
14 
15 
16 
17 #include "dsp/matrix_functions.h"
18 #include "matrix_utils.h"
19 
20 template<typename T,int R,int C>
test()21 static void test()
22 {
23    std::cout << "----\r\n";
24    std::cout << R << " x " << C << "\r\n";
25 
26    #if defined(STATIC_TEST)
27    PMat<T,R,C> a;
28    PVector<T,R> ref;
29    #else
30    PMat<T> a(R,C);
31    PVector<T> ref(R);
32    #endif
33 
34    init_array(a,R*C);
35 
36 
37 
38    INIT_SYSTICK;
39    START_CYCLE_MEASUREMENT;
40    startSectionNB(1);
41    #if defined(STATIC_TEST)
42    PVector<T,R> res = copy(a.col(4));
43    #else
44    PVector<T> res = copy(a.col(4));
45    #endif
46    stopSectionNB(1);
47    STOP_CYCLE_MEASUREMENT;
48 
49 
50    INIT_SYSTICK;
51    START_CYCLE_MEASUREMENT;
52    for(int i=0;i<R;i++)
53    {
54       ref[i] = a(i,4);
55 
56    }
57    STOP_CYCLE_MEASUREMENT;
58 
59    if (!validate(res,ref))
60    {
61       printf("col failed \r\n");
62    }
63 
64    std::cout << "=====\r\n";
65 }
66 
67 
68 
69 template<typename T>
all_col_test()70 void all_col_test()
71 {
72    const int nb_tails = TailForTests<T>::tail;
73    const int nb_loops = TailForTests<T>::loop;
74 
75     title<T>("Col test");
76 
77     test<T,NBVEC_4,5>();
78     test<T,NBVEC_8,5>();
79     test<T,NBVEC_16,5>();
80     test<T,NBVEC_32,5>();
81 
82     test<T,1,5>();
83     test<T,nb_tails,5>();
84     test<T,nb_loops,5>();
85     test<T,nb_loops+1,5>();
86     test<T,nb_loops+nb_tails,5>();
87 
88 }
89 
col_test()90 void col_test()
91 {
92 #if defined(COL_TEST)
93    #if defined(F64_DT)
94    all_col_test<double>();
95    #endif
96    #if defined(F32_DT)
97    all_col_test<float>();
98    #endif
99    #if defined(F16_DT) && !defined(DISABLEFLOAT16)
100    all_col_test<float16_t>();
101    #endif
102    #if defined(Q31_DT)
103    all_col_test<Q31>();
104    #endif
105    #if defined(Q15_DT)
106    all_col_test<Q15>();
107    #endif
108    #if defined(Q7_DT)
109    all_col_test<Q7>();
110    #endif
111 #endif
112 }