fun1_fftshift.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // File: fftshift.cpp
  3. //
  4. // MATLAB Coder version : 5.2
  5. // C/C++ source code generated on : 11-Mar-2023 10:38:07
  6. //
  7. // Include Files
  8. #include "fun1_fftshift.h"
  9. #include "rt_nonfinite.h"
  10. #include "coder_array.h"
  11. // Function Definitions
  12. //
  13. // Arguments : ::coder::array<creal_T, 2U> &x
  14. // Return Type : void
  15. //
  16. namespace coder {
  17. void fftshift(::coder::array<creal_T, 2U> &x)
  18. {
  19. for (int dim{0}; dim < 2; dim++) {
  20. int a;
  21. a = x.size(dim) - 1;
  22. if (x.size(dim) > 1) {
  23. int i;
  24. int k;
  25. int npages;
  26. int vlend2;
  27. vlend2 = x.size(dim) / 2 - 1;
  28. npages = 1;
  29. i = dim + 2;
  30. for (k = i; k < 3; k++) {
  31. npages *= x.size(1);
  32. }
  33. if ((vlend2 + 1) << 1 == x.size(dim)) {
  34. int i2;
  35. i2 = 0;
  36. for (int b_i{0}; b_i < npages; b_i++) {
  37. int i1;
  38. int ib;
  39. i1 = i2;
  40. i2 += a;
  41. i1++;
  42. i2++;
  43. ib = i1 + vlend2;
  44. for (k = 0; k <= vlend2; k++) {
  45. double xtmp_im;
  46. double xtmp_re;
  47. int xtmp_re_tmp;
  48. xtmp_re_tmp = (i1 + k) - 1;
  49. xtmp_re = x[xtmp_re_tmp].re;
  50. xtmp_im = x[xtmp_re_tmp].im;
  51. i = ib + k;
  52. x[xtmp_re_tmp] = x[i];
  53. x[i].re = xtmp_re;
  54. x[i].im = xtmp_im;
  55. }
  56. }
  57. } else {
  58. int i2;
  59. i2 = 0;
  60. for (int b_i{0}; b_i < npages; b_i++) {
  61. double xtmp_im;
  62. double xtmp_re;
  63. int i1;
  64. int ib;
  65. i1 = i2;
  66. i2 += a;
  67. i1++;
  68. i2++;
  69. ib = i1 + vlend2;
  70. xtmp_re = x[ib].re;
  71. xtmp_im = x[ib].im;
  72. for (k = 0; k <= vlend2; k++) {
  73. int xtmp_re_tmp;
  74. i = ib + k;
  75. xtmp_re_tmp = (i1 + k) - 1;
  76. x[i] = x[xtmp_re_tmp];
  77. x[xtmp_re_tmp] = x[i + 1];
  78. }
  79. ib = (ib + vlend2) + 1;
  80. x[ib].re = xtmp_re;
  81. x[ib].im = xtmp_im;
  82. }
  83. }
  84. }
  85. }
  86. }
  87. } // namespace coder
  88. //
  89. // File trailer for fftshift.cpp
  90. //
  91. // [EOF]
  92. //