ExampleCategoryQ31.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "ExampleCategoryQ31.h"
  2. #include "Error.h"
  3. #define SNR_THRESHOLD 100
  4. /*
  5. Reference patterns are generated with
  6. a double precision computation.
  7. */
  8. #define ABS_ERROR_Q31 ((q31_t)2)
  9. #define ABS_ERROR_Q63 ((q63_t)(1<<16))
  10. void ExampleCategoryQ31::test_op_q31()
  11. {
  12. const q31_t *inp1=input1.ptr();
  13. const q31_t *inp2=input2.ptr();
  14. q31_t *refp=ref.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. switch(id)
  25. {
  26. case ExampleCategoryQ31::TEST_OP_Q31_1:
  27. ref.reload(ExampleCategoryQ31::REF_OUT_Q31_ID,mgr);
  28. break;
  29. }
  30. input1.reload(ExampleCategoryQ31::INPUT1_Q31_ID,mgr,nb);
  31. input2.reload(ExampleCategoryQ31::INPUT2_Q31_ID,mgr,nb);
  32. output.create(ref.nbSamples(),ExampleCategoryQ31::OUT_Q31_ID,mgr);
  33. }
  34. void ExampleCategoryQ31::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  35. {
  36. output.dump(mgr);
  37. }