// // File: fun8_FFTImplementationCallback.cpp // // MATLAB Coder version : 5.2 // C/C++ source code generated on : 09-Mar-2023 16:57:20 // // Include Files #include "fun8_FFTImplementationCallback.h" #include "fun8_AMJamming_H_data.h" #include "rt_nonfinite.h" #include "coder_array.h" #include // Function Definitions // // Arguments : const ::coder::array &x // int n2blue // int nfft // const ::coder::array &costab // const ::coder::array &sintab // const ::coder::array &sintabinv // ::coder::array &y // Return Type : void // namespace coder { namespace internal { namespace fft { void fun8_FFTImplementationCallback::dobluesteinfft( const ::coder::array &x, int n2blue, int nfft, const ::coder::array &costab, const ::coder::array &sintab, const ::coder::array &sintabinv, ::coder::array &y) { array fv; array fy; array wwc; double nt_im; double nt_re; double twid_im; double twid_re; int i; int j; int k; int minNrowsNx; int nInt2; int nInt2m1; int nRowsD2; int nt_re_tmp; int rt; nInt2m1 = (nfft + nfft) - 1; wwc.set_size(nInt2m1); rt = 0; wwc[nfft - 1].re = 1.0; wwc[nfft - 1].im = 0.0; nInt2 = nfft << 1; for (k = 0; k <= nfft - 2; k++) { minNrowsNx = ((k + 1) << 1) - 1; if (nInt2 - rt <= minNrowsNx) { rt += minNrowsNx - nInt2; } else { rt += minNrowsNx; } nt_im = 3.1415926535897931 * static_cast(rt) / static_cast(nfft); if (nt_im == 0.0) { nt_re = 1.0; nt_im = 0.0; } else { nt_re = std::cos(nt_im); nt_im = std::sin(nt_im); } j = (nfft - k) - 2; wwc[j].re = nt_re; wwc[j].im = -nt_im; } j = nInt2m1 - 1; for (k = j; k >= nfft; k--) { wwc[k] = wwc[(nInt2m1 - k) - 1]; } y.set_size(nfft); if (nfft > x.size(0)) { y.set_size(nfft); for (j = 0; j < nfft; j++) { y[j].re = 0.0; y[j].im = 0.0; } } minNrowsNx = x.size(0); if (nfft < minNrowsNx) { minNrowsNx = nfft; } for (k = 0; k < minNrowsNx; k++) { nt_re_tmp = (nfft + k) - 1; nt_re = wwc[nt_re_tmp].re; nt_im = wwc[nt_re_tmp].im; y[k].re = nt_re * x[k].re + nt_im * x[k].im; y[k].im = nt_re * x[k].im - nt_im * x[k].re; } j = minNrowsNx + 1; for (k = j; k <= nfft; k++) { y[k - 1].re = 0.0; y[k - 1].im = 0.0; } fy.set_size(n2blue); if (n2blue > y.size(0)) { fy.set_size(n2blue); for (j = 0; j < n2blue; j++) { fy[j].re = 0.0; fy[j].im = 0.0; } } nInt2m1 = y.size(0); if (nInt2m1 >= n2blue) { nInt2m1 = n2blue; } rt = n2blue - 2; nRowsD2 = n2blue / 2; k = nRowsD2 / 2; minNrowsNx = 0; nInt2 = 0; for (i = 0; i <= nInt2m1 - 2; i++) { boolean_T tst; fy[minNrowsNx] = y[i]; minNrowsNx = n2blue; tst = true; while (tst) { minNrowsNx >>= 1; nInt2 ^= minNrowsNx; tst = ((nInt2 & minNrowsNx) == 0); } minNrowsNx = nInt2; } fy[minNrowsNx] = y[nInt2m1 - 1]; if (n2blue > 1) { for (i = 0; i <= rt; i += 2) { nt_re = fy[i + 1].re; nt_im = fy[i + 1].im; twid_re = fy[i].re; twid_im = fy[i].im; fy[i + 1].re = fy[i].re - fy[i + 1].re; fy[i + 1].im = fy[i].im - fy[i + 1].im; twid_re += nt_re; twid_im += nt_im; fy[i].re = twid_re; fy[i].im = twid_im; } } minNrowsNx = 2; nInt2m1 = 4; rt = ((k - 1) << 2) + 1; while (k > 0) { for (i = 0; i < rt; i += nInt2m1) { nt_re_tmp = i + minNrowsNx; nt_re = fy[nt_re_tmp].re; nt_im = fy[nt_re_tmp].im; fy[nt_re_tmp].re = fy[i].re - nt_re; fy[nt_re_tmp].im = fy[i].im - nt_im; fy[i].re = fy[i].re + nt_re; fy[i].im = fy[i].im + nt_im; } nInt2 = 1; for (j = k; j < nRowsD2; j += k) { int ihi; twid_re = costab[j]; twid_im = sintab[j]; i = nInt2; ihi = nInt2 + rt; while (i < ihi) { nt_re_tmp = i + minNrowsNx; nt_re = twid_re * fy[nt_re_tmp].re - twid_im * fy[nt_re_tmp].im; nt_im = twid_re * fy[nt_re_tmp].im + twid_im * fy[nt_re_tmp].re; fy[nt_re_tmp].re = fy[i].re - nt_re; fy[nt_re_tmp].im = fy[i].im - nt_im; fy[i].re = fy[i].re + nt_re; fy[i].im = fy[i].im + nt_im; i += nInt2m1; } nInt2++; } k /= 2; minNrowsNx = nInt2m1; nInt2m1 += nInt2m1; rt -= minNrowsNx; } fun8_FFTImplementationCallback::r2br_r2dit_trig_impl(wwc, n2blue, costab, sintab, fv); minNrowsNx = fy.size(0); for (j = 0; j < minNrowsNx; j++) { twid_im = fy[j].re * fv[j].im + fy[j].im * fv[j].re; fy[j].re = fy[j].re * fv[j].re - fy[j].im * fv[j].im; fy[j].im = twid_im; } fun8_FFTImplementationCallback::r2br_r2dit_trig_impl(fy, n2blue, costab, sintabinv, fv); if (fv.size(0) > 1) { twid_re = 1.0 / static_cast(fv.size(0)); minNrowsNx = fv.size(0); for (j = 0; j < minNrowsNx; j++) { fv[j].re = twid_re * fv[j].re; fv[j].im = twid_re * fv[j].im; } } j = wwc.size(0); for (k = nfft; k <= j; k++) { twid_re = wwc[k - 1].re * fv[k - 1].re + wwc[k - 1].im * fv[k - 1].im; twid_im = wwc[k - 1].re * fv[k - 1].im - wwc[k - 1].im * fv[k - 1].re; if (twid_im == 0.0) { minNrowsNx = k - nfft; y[minNrowsNx].re = twid_re / static_cast(nfft); y[minNrowsNx].im = 0.0; } else if (twid_re == 0.0) { minNrowsNx = k - nfft; y[minNrowsNx].re = 0.0; y[minNrowsNx].im = twid_im / static_cast(nfft); } else { minNrowsNx = k - nfft; y[minNrowsNx].re = twid_re / static_cast(nfft); y[minNrowsNx].im = twid_im / static_cast(nfft); } } } // // Arguments : const ::coder::array &x // int unsigned_nRows // const ::coder::array &costab // const ::coder::array &sintab // ::coder::array &y // Return Type : void // void fun8_FFTImplementationCallback::r2br_r2dit_trig_impl( const ::coder::array &x, int unsigned_nRows, const ::coder::array &costab, const ::coder::array &sintab, ::coder::array &y) { double temp_im; double temp_re; double twid_im; double twid_re; int i; int iDelta2; int iheight; int iy; int ju; int k; int nRowsD2; y.set_size(unsigned_nRows); if (unsigned_nRows > x.size(0)) { y.set_size(unsigned_nRows); for (iy = 0; iy < unsigned_nRows; iy++) { y[iy].re = 0.0; y[iy].im = 0.0; } } iDelta2 = x.size(0); if (iDelta2 >= unsigned_nRows) { iDelta2 = unsigned_nRows; } iheight = unsigned_nRows - 2; nRowsD2 = unsigned_nRows / 2; k = nRowsD2 / 2; iy = 0; ju = 0; for (i = 0; i <= iDelta2 - 2; i++) { boolean_T tst; y[iy] = x[i]; iy = unsigned_nRows; tst = true; while (tst) { iy >>= 1; ju ^= iy; tst = ((ju & iy) == 0); } iy = ju; } y[iy] = x[iDelta2 - 1]; if (unsigned_nRows > 1) { for (i = 0; i <= iheight; i += 2) { temp_re = y[i + 1].re; temp_im = y[i + 1].im; twid_re = y[i].re; twid_im = y[i].im; y[i + 1].re = y[i].re - y[i + 1].re; y[i + 1].im = y[i].im - y[i + 1].im; twid_re += temp_re; twid_im += temp_im; y[i].re = twid_re; y[i].im = twid_im; } } iy = 2; iDelta2 = 4; iheight = ((k - 1) << 2) + 1; while (k > 0) { int temp_re_tmp; for (i = 0; i < iheight; i += iDelta2) { temp_re_tmp = i + iy; temp_re = y[temp_re_tmp].re; temp_im = y[temp_re_tmp].im; y[temp_re_tmp].re = y[i].re - temp_re; y[temp_re_tmp].im = y[i].im - temp_im; y[i].re = y[i].re + temp_re; y[i].im = y[i].im + temp_im; } ju = 1; for (int j{k}; j < nRowsD2; j += k) { int ihi; twid_re = costab[j]; twid_im = sintab[j]; i = ju; ihi = ju + iheight; while (i < ihi) { temp_re_tmp = i + iy; temp_re = twid_re * y[temp_re_tmp].re - twid_im * y[temp_re_tmp].im; temp_im = twid_re * y[temp_re_tmp].im + twid_im * y[temp_re_tmp].re; y[temp_re_tmp].re = y[i].re - temp_re; y[temp_re_tmp].im = y[i].im - temp_im; y[i].re = y[i].re + temp_re; y[i].im = y[i].im + temp_im; i += iDelta2; } ju++; } k /= 2; iy = iDelta2; iDelta2 += iDelta2; iheight -= iy; } } } // namespace fft } // namespace internal } // namespace coder // // File trailer for fun8_FFTImplementationCallback.cpp // // [EOF] //