InterpolationTestsF32.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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-5)
  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::test_bilinear_interp_f32()
  24. {
  25. const float32_t *inp = input.ptr();
  26. float32_t *outp = output.ptr();
  27. float32_t x,y;
  28. int nb;
  29. for(nb = 0; nb < input.nbSamples(); nb += 2)
  30. {
  31. x = inp[nb];
  32. y = inp[nb+1];
  33. *outp++=arm_bilinear_interp_f32(&SBI,x,y);
  34. }
  35. ASSERT_EMPTY_TAIL(output);
  36. ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
  37. ASSERT_REL_ERROR(output,ref,REL_ERROR);
  38. }
  39. void InterpolationTestsF32::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  40. {
  41. const int16_t *pConfig;
  42. Testing::nbSamples_t nb=MAX_NB_SAMPLES;
  43. switch(id)
  44. {
  45. case InterpolationTestsF32::TEST_LINEAR_INTERP_F32_1:
  46. input.reload(InterpolationTestsF32::INPUT_F32_ID,mgr,nb);
  47. y.reload(InterpolationTestsF32::YVAL_F32_ID,mgr,nb);
  48. ref.reload(InterpolationTestsF32::REF_LINEAR_F32_ID,mgr,nb);
  49. S.nValues=y.nbSamples(); /**< nValues */
  50. /* Those values must be coherent with the ones in the
  51. Python script generating the patterns */
  52. S.x1=0.0; /**< x1 */
  53. S.xSpacing=1.0; /**< xSpacing */
  54. S.pYData=y.ptr(); /**< pointer to the table of Y values */
  55. break;
  56. case InterpolationTestsF32::TEST_BILINEAR_INTERP_F32_2:
  57. input.reload(InterpolationTestsF32::INPUTBI_F32_ID,mgr,nb);
  58. config.reload(InterpolationTestsF32::CONFIGBI_S16_ID,mgr,nb);
  59. y.reload(InterpolationTestsF32::YVALBI_F32_ID,mgr,nb);
  60. ref.reload(InterpolationTestsF32::REF_BILINEAR_F32_ID,mgr,nb);
  61. pConfig = config.ptr();
  62. SBI.numRows = pConfig[1];
  63. SBI.numCols = pConfig[0];
  64. SBI.pData = y.ptr();
  65. break;
  66. }
  67. output.create(ref.nbSamples(),InterpolationTestsF32::OUT_SAMPLES_F32_ID,mgr);
  68. }
  69. void InterpolationTestsF32::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  70. {
  71. output.dump(mgr);
  72. }