InterpolationTestsQ7.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "InterpolationTestsQ7.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. #define SNR_THRESHOLD 20
  5. /*
  6. Reference patterns are generated with
  7. a double precision computation.
  8. */
  9. #define ABS_ERROR_Q7 ((q7_t)2)
  10. void InterpolationTestsQ7::test_linear_interp_q7()
  11. {
  12. const q31_t *inp = input.ptr();
  13. q7_t *outp = output.ptr();
  14. int nb;
  15. for(nb = 0; nb < input.nbSamples(); nb++)
  16. {
  17. outp[nb] = arm_linear_interp_q7(y.ptr(),inp[nb],y.nbSamples());
  18. }
  19. ASSERT_EMPTY_TAIL(output);
  20. ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
  21. ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q7);
  22. }
  23. void InterpolationTestsQ7::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  24. {
  25. Testing::nbSamples_t nb=MAX_NB_SAMPLES;
  26. switch(id)
  27. {
  28. case InterpolationTestsQ7::TEST_LINEAR_INTERP_Q7_1:
  29. input.reload(InterpolationTestsQ7::INPUT_Q31_ID,mgr,nb);
  30. y.reload(InterpolationTestsQ7::YVAL_Q7_ID,mgr,nb);
  31. ref.reload(InterpolationTestsQ7::REF_LINEAR_Q7_ID,mgr,nb);
  32. break;
  33. }
  34. output.create(ref.nbSamples(),InterpolationTestsQ7::OUT_SAMPLES_Q7_ID,mgr);
  35. }
  36. void InterpolationTestsQ7::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  37. {
  38. output.dump(mgr);
  39. }