dot_product.cpp 759 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "RTE_Components.h"
  2. #include CMSIS_device_header
  3. #if defined(MPS3)
  4. #include "cmsis_driver_config.h"
  5. #include "stdout_USART.h"
  6. #endif
  7. #include <iostream>
  8. #include <dsppp/memory_pool.hpp>
  9. #include <dsppp/matrix.hpp>
  10. using namespace arm_cmsis_dsp;
  11. int main(void)
  12. {
  13. #if defined(MPS3)
  14. stdout_init();
  15. #endif
  16. std::cout << "Dot product example\r\n";
  17. constexpr int NB = 32;
  18. Vector<float32_t,NB> a;
  19. Vector<float32_t,NB> b;
  20. Vector<float32_t,NB> c;
  21. Vector<float32_t,NB> d;
  22. float32_t scale = 0.5;
  23. for(int i = 0;i< NB;i++)
  24. {
  25. a[i] = b[i] = c[i] = d[i] = i;
  26. }
  27. float32_t r;
  28. r = dot(scale*(a+b),c*d);
  29. std::cout << "Result = " << r << "\r\n";
  30. #if defined(MPS3)
  31. while(1);
  32. #endif
  33. }