fun7_FFTImplementationCallback.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // File: fun7_FFTImplementationCallback.cpp
  3. //
  4. // MATLAB Coder version : 5.2
  5. // C/C++ source code generated on : 04-Mar-2023 17:44:30
  6. //
  7. // Include Files
  8. #include "fun7_FFTImplementationCallback.h"
  9. #include "coder_array.h"
  10. // Function Definitions
  11. //
  12. // Arguments : const ::coder::array<creal_T, 1U> &x
  13. // int unsigned_nRows
  14. // const ::coder::array<double, 2U> &costab
  15. // const ::coder::array<double, 2U> &sintab
  16. // ::coder::array<creal_T, 1U> &y
  17. // Return Type : void
  18. //
  19. namespace coder {
  20. namespace internal {
  21. namespace fft {
  22. void fun7_FFTImplementationCallback::r2br_r2dit_trig_impl(
  23. const ::coder::array<creal_T, 1U> &x, int unsigned_nRows,
  24. const ::coder::array<double, 2U> &costab,
  25. const ::coder::array<double, 2U> &sintab, ::coder::array<creal_T, 1U> &y)
  26. {
  27. double temp_im;
  28. double temp_re;
  29. double twid_im;
  30. double twid_re;
  31. int i;
  32. int iDelta2;
  33. int iheight;
  34. int iy;
  35. int ju;
  36. int k;
  37. int nRowsD2;
  38. y.set_size(unsigned_nRows);
  39. if (unsigned_nRows > x.size(0)) {
  40. y.set_size(unsigned_nRows);
  41. for (iy = 0; iy < unsigned_nRows; iy++) {
  42. y[iy].re = 0.0;
  43. y[iy].im = 0.0;
  44. }
  45. }
  46. iDelta2 = x.size(0);
  47. if (iDelta2 >= unsigned_nRows) {
  48. iDelta2 = unsigned_nRows;
  49. }
  50. iheight = unsigned_nRows - 2;
  51. nRowsD2 = unsigned_nRows / 2;
  52. k = nRowsD2 / 2;
  53. iy = 0;
  54. ju = 0;
  55. for (i = 0; i <= iDelta2 - 2; i++) {
  56. boolean_T tst;
  57. y[iy] = x[i];
  58. iy = unsigned_nRows;
  59. tst = true;
  60. while (tst) {
  61. iy >>= 1;
  62. ju ^= iy;
  63. tst = ((ju & iy) == 0);
  64. }
  65. iy = ju;
  66. }
  67. y[iy] = x[iDelta2 - 1];
  68. if (unsigned_nRows > 1) {
  69. for (i = 0; i <= iheight; i += 2) {
  70. temp_re = y[i + 1].re;
  71. temp_im = y[i + 1].im;
  72. twid_re = y[i].re;
  73. twid_im = y[i].im;
  74. y[i + 1].re = y[i].re - y[i + 1].re;
  75. y[i + 1].im = y[i].im - y[i + 1].im;
  76. twid_re += temp_re;
  77. twid_im += temp_im;
  78. y[i].re = twid_re;
  79. y[i].im = twid_im;
  80. }
  81. }
  82. iy = 2;
  83. iDelta2 = 4;
  84. iheight = ((k - 1) << 2) + 1;
  85. while (k > 0) {
  86. int temp_re_tmp;
  87. for (i = 0; i < iheight; i += iDelta2) {
  88. temp_re_tmp = i + iy;
  89. temp_re = y[temp_re_tmp].re;
  90. temp_im = y[temp_re_tmp].im;
  91. y[temp_re_tmp].re = y[i].re - temp_re;
  92. y[temp_re_tmp].im = y[i].im - temp_im;
  93. y[i].re = y[i].re + temp_re;
  94. y[i].im = y[i].im + temp_im;
  95. }
  96. ju = 1;
  97. for (int j{k}; j < nRowsD2; j += k) {
  98. int ihi;
  99. twid_re = costab[j];
  100. twid_im = sintab[j];
  101. i = ju;
  102. ihi = ju + iheight;
  103. while (i < ihi) {
  104. temp_re_tmp = i + iy;
  105. temp_re = twid_re * y[temp_re_tmp].re - twid_im * y[temp_re_tmp].im;
  106. temp_im = twid_re * y[temp_re_tmp].im + twid_im * y[temp_re_tmp].re;
  107. y[temp_re_tmp].re = y[i].re - temp_re;
  108. y[temp_re_tmp].im = y[i].im - temp_im;
  109. y[i].re = y[i].re + temp_re;
  110. y[i].im = y[i].im + temp_im;
  111. i += iDelta2;
  112. }
  113. ju++;
  114. }
  115. k /= 2;
  116. iy = iDelta2;
  117. iDelta2 += iDelta2;
  118. iheight -= iy;
  119. }
  120. }
  121. } // namespace fft
  122. } // namespace internal
  123. } // namespace coder
  124. //
  125. // File trailer for fun7_FFTImplementationCallback.cpp
  126. //
  127. // [EOF]
  128. //