TransformF32.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #include "TransformF32.h"
  2. #include "Error.h"
  3. #include "arm_math.h"
  4. #include "arm_const_structs.h"
  5. void TransformF32::test_cfft_f32()
  6. {
  7. arm_cfft_f32(&(this->cfftInstance), this->pDst, this->ifft,this->bitRev);
  8. }
  9. void TransformF32::test_rfft_f32()
  10. {
  11. arm_rfft_fast_f32(&this->rfftFastInstance, this->pSrc, this->pDst, this->ifft);
  12. }
  13. void TransformF32::test_dct4_f32()
  14. {
  15. arm_dct4_f32(
  16. &this->dct4Instance,
  17. this->pState,
  18. this->pDst);
  19. }
  20. void TransformF32::test_cfft_radix4_f32()
  21. {
  22. arm_cfft_radix4_f32(&this->cfftRadix4Instance,this->pDst);
  23. }
  24. void TransformF32::test_cfft_radix2_f32()
  25. {
  26. arm_cfft_radix2_f32(&this->cfftRadix2Instance,this->pDst);
  27. }
  28. void TransformF32::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  29. {
  30. float32_t normalize;
  31. std::vector<Testing::param_t>::iterator it = params.begin();
  32. this->nbSamples = *it++;
  33. this->ifft = *it++;
  34. this->bitRev = *it;
  35. switch(id)
  36. {
  37. case TEST_CFFT_F32_1:
  38. samples.reload(TransformF32::INPUTC_F32_ID,mgr,2*this->nbSamples);
  39. output.create(2*this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  40. this->pSrc=samples.ptr();
  41. this->pDst=output.ptr();
  42. status=arm_cfft_init_f32(&cfftInstance,this->nbSamples);
  43. memcpy(this->pDst,this->pSrc,2*sizeof(float32_t)*this->nbSamples);
  44. break;
  45. case TEST_RFFT_F32_2:
  46. samples.reload(TransformF32::INPUTR_F32_ID,mgr,this->nbSamples);
  47. output.create(this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  48. this->pSrc=samples.ptr();
  49. this->pDst=output.ptr();
  50. arm_rfft_fast_init_f32(&this->rfftFastInstance, this->nbSamples);
  51. break;
  52. case TEST_DCT4_F32_3:
  53. samples.reload(TransformF32::INPUTR_F32_ID,mgr,this->nbSamples);
  54. output.create(this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  55. state.create(2*this->nbSamples,TransformF32::STATE_F32_ID,mgr);
  56. this->pSrc=samples.ptr();
  57. this->pDst=output.ptr();
  58. this->pState=state.ptr();
  59. normalize = sqrt((2.0f/(float32_t)this->nbSamples));
  60. memcpy(this->pDst,this->pSrc,sizeof(float32_t)*this->nbSamples);
  61. arm_dct4_init_f32(
  62. &this->dct4Instance,
  63. &this->rfftInstance,
  64. &this->cfftRadix4Instance,
  65. this->nbSamples,
  66. this->nbSamples/2,
  67. normalize);
  68. break;
  69. case TEST_CFFT_RADIX4_F32_4:
  70. samples.reload(TransformF32::INPUTC_F32_ID,mgr,2*this->nbSamples);
  71. output.create(2*this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  72. this->pSrc=samples.ptr();
  73. this->pDst=output.ptr();
  74. memcpy(this->pDst,this->pSrc,2*sizeof(float32_t)*this->nbSamples);
  75. arm_cfft_radix4_init_f32(&this->cfftRadix4Instance,
  76. this->nbSamples,
  77. this->ifft,
  78. this->bitRev);
  79. break;
  80. case TEST_CFFT_RADIX2_F32_5:
  81. samples.reload(TransformF32::INPUTC_F32_ID,mgr,2*this->nbSamples);
  82. output.create(2*this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  83. this->pSrc=samples.ptr();
  84. this->pDst=output.ptr();
  85. memcpy(this->pDst,this->pSrc,2*sizeof(float32_t)*this->nbSamples);
  86. arm_cfft_radix2_init_f32(&this->cfftRadix2Instance,
  87. this->nbSamples,
  88. this->ifft,
  89. this->bitRev);
  90. break;
  91. }
  92. }
  93. void TransformF32::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  94. {
  95. }