DECIMF64.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #include "DECIMF64.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-4)
  10. void DECIMF64::test_fir_decimate_f64()
  11. {
  12. int nbTests;
  13. int nb;
  14. uint32_t *pConfig = config.ptr();
  15. const float64_t * pSrc = input.ptr();
  16. float64_t * pDst = output.ptr();
  17. float64_t * pCoefs = coefs.ptr();
  18. nbTests=config.nbSamples() / 4;
  19. for(nb=0;nb < nbTests; nb++)
  20. {
  21. this->q = pConfig[0];
  22. this->numTaps = pConfig[1];
  23. this->blocksize = pConfig[2];
  24. this->refsize = pConfig[3];
  25. pConfig += 4;
  26. this->status=arm_fir_decimate_init_f64(&(this->S),
  27. this->numTaps,
  28. this->q,
  29. pCoefs,
  30. state.ptr(),
  31. this->blocksize);
  32. ASSERT_TRUE(this->status == ARM_MATH_SUCCESS);
  33. arm_fir_decimate_f64(
  34. &(this->S),
  35. pSrc,
  36. pDst,
  37. this->blocksize);
  38. pSrc += this->blocksize;
  39. pDst += this->refsize;
  40. pCoefs += this->numTaps;
  41. }
  42. ASSERT_EMPTY_TAIL(output);
  43. ASSERT_SNR(output,ref,(float64_t)SNR_THRESHOLD);
  44. ASSERT_REL_ERROR(output,ref,REL_ERROR);
  45. }
  46. #if 0
  47. void DECIMF64::test_fir_interpolate_f64()
  48. {
  49. int nbTests;
  50. int nb;
  51. uint64_t *pConfig = config.ptr();
  52. const float64_t * pSrc = input.ptr();
  53. float64_t * pDst = output.ptr();
  54. float64_t * pCoefs = coefs.ptr();
  55. nbTests=config.nbSamples() / 4;
  56. for(nb=0;nb < nbTests; nb++)
  57. {
  58. this->q = pConfig[0];
  59. this->numTaps = pConfig[1];
  60. this->blocksize = pConfig[2];
  61. this->refsize = pConfig[3];
  62. pConfig += 4;
  63. this->status=arm_fir_interpolate_init_f64(&(this->SI),
  64. this->q,
  65. this->numTaps,
  66. pCoefs,
  67. state.ptr(),
  68. this->blocksize);
  69. ASSERT_TRUE(this->status == ARM_MATH_SUCCESS);
  70. arm_fir_interpolate_f64(
  71. &(this->SI),
  72. pSrc,
  73. pDst,
  74. this->blocksize);
  75. pSrc += this->blocksize;
  76. pDst += this->refsize;
  77. pCoefs += this->numTaps;
  78. }
  79. ASSERT_EMPTY_TAIL(output);
  80. ASSERT_SNR(output,ref,(float64_t)SNR_THRESHOLD);
  81. ASSERT_REL_ERROR(output,ref,REL_ERROR);
  82. }
  83. #endif
  84. void DECIMF64::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  85. {
  86. (void)params;
  87. switch(id)
  88. {
  89. case DECIMF64::TEST_FIR_DECIMATE_F64_1:
  90. config.reload(DECIMF64::CONFIGSDECIMF64_ID,mgr);
  91. input.reload(DECIMF64::INPUT1_F64_ID,mgr);
  92. coefs.reload(DECIMF64::COEFS1_F64_ID,mgr);
  93. ref.reload(DECIMF64::REF1_DECIM_F64_ID,mgr);
  94. state.create(16 + 768 - 1,DECIMF64::STATE_F64_ID,mgr);
  95. break;
  96. #if 0
  97. case DECIMF64::TEST_FIR_INTERPOLATE_F64_2:
  98. config.reload(DECIMF64::CONFIGSINTERPF64_ID,mgr);
  99. input.reload(DECIMF64::INPUT2_F64_ID,mgr);
  100. coefs.reload(DECIMF64::COEFS2_F64_ID,mgr);
  101. ref.reload(DECIMF64::REF2_INTERP_F64_ID,mgr);
  102. state.create(16 + 768 - 1,DECIMF64::STATE_F64_ID,mgr);
  103. break;
  104. #endif
  105. }
  106. output.create(ref.nbSamples(),DECIMF64::OUT_F64_ID,mgr);
  107. }
  108. void DECIMF64::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  109. {
  110. (void)id;
  111. output.dump(mgr);
  112. }