ExampleCategoryQ31.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "ExampleCategoryQ31.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. #define SNR_THRESHOLD 100
  5. /*
  6. Reference patterns are generated with
  7. a double precision computation.
  8. */
  9. #define ABS_ERROR_Q31 ((q31_t)2)
  10. #define ABS_ERROR_Q63 ((q63_t)(1<<16))
  11. void ExampleCategoryQ31::test_op_q31()
  12. {
  13. const q31_t *inp1=input1.ptr();
  14. const q31_t *inp2=input2.ptr();
  15. q31_t *outp=output.ptr();
  16. arm_add_q31(inp1,inp2,outp,input1.nbSamples());
  17. ASSERT_EMPTY_TAIL(output);
  18. ASSERT_SNR(output,ref,(q31_t)SNR_THRESHOLD);
  19. ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q31);
  20. }
  21. void ExampleCategoryQ31::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  22. {
  23. Testing::nbSamples_t nb=MAX_NB_SAMPLES;
  24. (void)params;
  25. switch(id)
  26. {
  27. case ExampleCategoryQ31::TEST_OP_Q31_1:
  28. ref.reload(ExampleCategoryQ31::REF_OUT_Q31_ID,mgr);
  29. break;
  30. }
  31. input1.reload(ExampleCategoryQ31::INPUT1_Q31_ID,mgr,nb);
  32. input2.reload(ExampleCategoryQ31::INPUT2_Q31_ID,mgr,nb);
  33. output.create(ref.nbSamples(),ExampleCategoryQ31::OUT_Q31_ID,mgr);
  34. }
  35. void ExampleCategoryQ31::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  36. {
  37. (void)id;
  38. output.dump(mgr);
  39. }