InterpolationTestsF32.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "InterpolationTestsF32.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. #define SNR_THRESHOLD 120
  5. /*
  6. Reference patterns are generated with
  7. a double precision computation.
  8. */
  9. #define REL_ERROR (8.0e-6)
  10. void InterpolationTestsF32::test_linear_interp_f32()
  11. {
  12. const float32_t *inp = input.ptr();
  13. float32_t *outp = output.ptr();
  14. int nb;
  15. for(nb = 0; nb < input.nbSamples(); nb++)
  16. {
  17. outp[nb] = arm_linear_interp_f32(&S,inp[nb]);
  18. }
  19. ASSERT_EMPTY_TAIL(output);
  20. ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
  21. ASSERT_REL_ERROR(output,ref,REL_ERROR);
  22. }
  23. void InterpolationTestsF32::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 InterpolationTestsF32::TEST_LINEAR_INTERP_F32_1:
  29. input.reload(InterpolationTestsF32::INPUT_F32_ID,mgr,nb);
  30. y.reload(InterpolationTestsF32::YVAL_F32_ID,mgr,nb);
  31. ref.reload(InterpolationTestsF32::REF_LINEAR_F32_ID,mgr,nb);
  32. S.nValues=y.nbSamples(); /**< nValues */
  33. /* Those values must be coherent with the ones in the
  34. Python script generating the patterns */
  35. S.x1=0.0; /**< x1 */
  36. S.xSpacing=1.0; /**< xSpacing */
  37. S.pYData=y.ptr(); /**< pointer to the table of Y values */
  38. break;
  39. }
  40. output.create(ref.nbSamples(),InterpolationTestsF32::OUT_SAMPLES_F32_ID,mgr);
  41. }
  42. void InterpolationTestsF32::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  43. {
  44. output.dump(mgr);
  45. }