col_test.cpp 1.8 KB

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