InterpolationTestsQ31.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "InterpolationTestsQ31.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)5)
  10. void InterpolationTestsQ31::test_linear_interp_q31()
  11. {
  12. const q31_t *inp = input.ptr();
  13. q31_t *outp = output.ptr();
  14. int nb;
  15. for(nb = 0; nb < input.nbSamples(); nb++)
  16. {
  17. outp[nb] = arm_linear_interp_q31(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_Q31);
  22. }
  23. void InterpolationTestsQ31::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 InterpolationTestsQ31::TEST_LINEAR_INTERP_Q31_1:
  29. input.reload(InterpolationTestsQ31::INPUT_Q31_ID,mgr,nb);
  30. y.reload(InterpolationTestsQ31::YVAL_Q31_ID,mgr,nb);
  31. ref.reload(InterpolationTestsQ31::REF_LINEAR_Q31_ID,mgr,nb);
  32. break;
  33. }
  34. output.create(ref.nbSamples(),InterpolationTestsQ31::OUT_SAMPLES_Q31_ID,mgr);
  35. }
  36. void InterpolationTestsQ31::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  37. {
  38. output.dump(mgr);
  39. }