// // File: ifft_8_3.cpp // // MATLAB Coder version : 5.2 // C/C++ source code generated on : 10-Mar-2023 15:16:29 // // Include Files #include "fun8_3_ifft.h" #include "fun8_3_FFTImplementationCallback.h" #include "fun8_3_jamming_H_data.h" #include "rt_nonfinite.h" #include "coder_array.h" #include // Function Definitions // // Arguments : const ::coder::array &x // ::coder::array &y // Return Type : void // namespace coder { void ifft_8_3(const ::coder::array &x, ::coder::array &y) { array fv; array fy; array wwc; array yCol; array costab; array costab1q; array sintab; array sintabinv; if (x.size(1) == 0) { y.set_size(1, 0); } else { double twid_re; int N2blue; int ihi; int j; int k; int pmax; int pmin; int pow2p; boolean_T useRadix2; useRadix2 = ((x.size(1) & (x.size(1) - 1)) == 0); N2blue = 1; if (useRadix2) { pmax = x.size(1); } else { ihi = (x.size(1) + x.size(1)) - 1; pmax = 31; if (ihi <= 1) { pmax = 0; } else { boolean_T exitg1; pmin = 0; exitg1 = false; while ((!exitg1) && (pmax - pmin > 1)) { k = (pmin + pmax) >> 1; pow2p = 1 << k; if (pow2p == ihi) { pmax = k; exitg1 = true; } else if (pow2p > ihi) { pmax = k; } else { pmin = k; } } } N2blue = 1 << pmax; pmax = N2blue; } twid_re = 6.2831853071795862 / static_cast(pmax); ihi = pmax / 2 / 2; costab1q.set_size(1, ihi + 1); costab1q[0] = 1.0; pmax = ihi / 2 - 1; for (k = 0; k <= pmax; k++) { costab1q[k + 1] = std::cos(twid_re * (static_cast(k) + 1.0)); } j = pmax + 2; pmax = ihi - 1; for (k = j; k <= pmax; k++) { costab1q[k] = std::sin(twid_re * static_cast(ihi - k)); } costab1q[ihi] = 0.0; if (!useRadix2) { ihi = costab1q.size(1) - 1; pmax = (costab1q.size(1) - 1) << 1; costab.set_size(1, pmax + 1); sintab.set_size(1, pmax + 1); costab[0] = 1.0; sintab[0] = 0.0; sintabinv.set_size(1, pmax + 1); for (k = 0; k < ihi; k++) { sintabinv[k + 1] = costab1q[(ihi - k) - 1]; } j = costab1q.size(1); for (k = j; k <= pmax; k++) { sintabinv[k] = costab1q[k - ihi]; } for (k = 0; k < ihi; k++) { costab[k + 1] = costab1q[k + 1]; sintab[k + 1] = -costab1q[(ihi - k) - 1]; } j = costab1q.size(1); for (k = j; k <= pmax; k++) { costab[k] = -costab1q[pmax - k]; sintab[k] = -costab1q[k - ihi]; } } else { ihi = costab1q.size(1) - 1; pmax = (costab1q.size(1) - 1) << 1; costab.set_size(1, pmax + 1); sintab.set_size(1, pmax + 1); costab[0] = 1.0; sintab[0] = 0.0; for (k = 0; k < ihi; k++) { costab[k + 1] = costab1q[k + 1]; sintab[k + 1] = costab1q[(ihi - k) - 1]; } j = costab1q.size(1); for (k = j; k <= pmax; k++) { costab[k] = -costab1q[pmax - k]; sintab[k] = costab1q[k - ihi]; } sintabinv.set_size(1, 0); } if (useRadix2) { pmax = x.size(1); wwc = x.reshape(pmax); internal::fft::fun8_3_FFTImplementationCallback::r2br_r2dit_trig_impl( wwc, x.size(1), costab, sintab, yCol); if (yCol.size(0) > 1) { twid_re = 1.0 / static_cast(yCol.size(0)); pmax = yCol.size(0); for (j = 0; j < pmax; j++) { yCol[j].re = twid_re * yCol[j].re; yCol[j].im = twid_re * yCol[j].im; } } } else { double nt_im; double nt_re; double twid_im; int i; int ju; int nRowsD2; int nfft; int nt_re_tmp; nfft = x.size(1); pmax = (x.size(1) + x.size(1)) - 1; wwc.set_size(pmax); pmin = 0; wwc[x.size(1) - 1].re = 1.0; wwc[x.size(1) - 1].im = 0.0; pow2p = x.size(1) << 1; j = x.size(1); for (k = 0; k <= j - 2; k++) { ju = ((k + 1) << 1) - 1; if (pow2p - pmin <= ju) { pmin += ju - pow2p; } else { pmin += ju; } nt_im = 3.1415926535897931 * static_cast(pmin) / 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); } wwc[(x.size(1) - k) - 2].re = nt_re; wwc[(x.size(1) - k) - 2].im = -nt_im; } j = pmax - 1; for (k = j; k >= nfft; k--) { wwc[k] = wwc[(pmax - k) - 1]; } yCol.set_size(x.size(1)); pmax = x.size(1); for (k = 0; k < pmax; k++) { nt_re_tmp = (nfft + k) - 1; nt_re = wwc[nt_re_tmp].re; nt_im = wwc[nt_re_tmp].im; yCol[k].re = nt_re * x[k].re + nt_im * x[k].im; yCol[k].im = nt_re * x[k].im - nt_im * x[k].re; } j = x.size(1) + 1; for (k = j; k <= nfft; k++) { yCol[k - 1].re = 0.0; yCol[k - 1].im = 0.0; } fy.set_size(N2blue); if (N2blue > yCol.size(0)) { fy.set_size(N2blue); for (j = 0; j < N2blue; j++) { fy[j].re = 0.0; fy[j].im = 0.0; } } pmin = yCol.size(0); if (pmin >= N2blue) { pmin = N2blue; } pow2p = N2blue - 2; nRowsD2 = N2blue / 2; k = nRowsD2 / 2; pmax = 0; ju = 0; for (i = 0; i <= pmin - 2; i++) { fy[pmax] = yCol[i]; ihi = N2blue; useRadix2 = true; while (useRadix2) { ihi >>= 1; ju ^= ihi; useRadix2 = ((ju & ihi) == 0); } pmax = ju; } fy[pmax] = yCol[pmin - 1]; if (N2blue > 1) { for (i = 0; i <= pow2p; 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; } } pmax = 2; pmin = 4; pow2p = ((k - 1) << 2) + 1; while (k > 0) { for (i = 0; i < pow2p; i += pmin) { nt_re_tmp = i + pmax; 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; } ju = 1; for (j = k; j < nRowsD2; j += k) { twid_re = costab[j]; twid_im = sintab[j]; i = ju; ihi = ju + pow2p; while (i < ihi) { nt_re_tmp = i + pmax; 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 += pmin; } ju++; } k /= 2; pmax = pmin; pmin += pmin; pow2p -= pmax; } internal::fft::fun8_3_FFTImplementationCallback::r2br_r2dit_trig_impl( wwc, N2blue, costab, sintab, fv); pmax = fy.size(0); for (j = 0; j < pmax; 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; } internal::fft::fun8_3_FFTImplementationCallback::r2br_r2dit_trig_impl( fy, N2blue, costab, sintabinv, fv); if (fv.size(0) > 1) { twid_re = 1.0 / static_cast(fv.size(0)); pmax = fv.size(0); for (j = 0; j < pmax; j++) { fv[j].re = twid_re * fv[j].re; fv[j].im = twid_re * fv[j].im; } } nt_re = x.size(1); 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) { pmax = k - nfft; yCol[pmax].re = twid_re / nt_re; yCol[pmax].im = 0.0; } else if (twid_re == 0.0) { pmax = k - nfft; yCol[pmax].re = 0.0; yCol[pmax].im = twid_im / nt_re; } else { pmax = k - nfft; yCol[pmax].re = twid_re / nt_re; yCol[pmax].im = twid_im / nt_re; } } } y.set_size(1, x.size(1)); pmax = x.size(1); for (j = 0; j < pmax; j++) { y[j] = yCol[j]; } } } } // namespace coder // // File trailer for ifft_8_3.cpp // // [EOF] //