InterpolationTestsQ15.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "InterpolationTestsQ15.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. #define SNR_THRESHOLD 70
  5. /*
  6. Reference patterns are generated with
  7. a double precision computation.
  8. */
  9. #define ABS_ERROR_Q15 ((q15_t)2)
  10. void InterpolationTestsQ15::test_linear_interp_q15()
  11. {
  12. const q31_t *inp = input.ptr();
  13. q15_t *outp = output.ptr();
  14. int nb;
  15. for(nb = 0; nb < input.nbSamples(); nb++)
  16. {
  17. outp[nb] = arm_linear_interp_q15(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_Q15);
  22. }
  23. void InterpolationTestsQ15::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 InterpolationTestsQ15::TEST_LINEAR_INTERP_Q15_1:
  29. input.reload(InterpolationTestsQ15::INPUT_Q31_ID,mgr,nb);
  30. y.reload(InterpolationTestsQ15::YVAL_Q15_ID,mgr,nb);
  31. ref.reload(InterpolationTestsQ15::REF_LINEAR_Q15_ID,mgr,nb);
  32. break;
  33. }
  34. output.create(ref.nbSamples(),InterpolationTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
  35. }
  36. void InterpolationTestsQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  37. {
  38. output.dump(mgr);
  39. }