// // File: ifft_1.cpp // // MATLAB Coder version : 5.2 // C/C++ source code generated on : 11-Mar-2023 10:38:07 // // Include Files #include "fun1_ifft.h" #include "fun1_FFTImplementationCallback.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_1(const ::coder::array &x, ::coder::array &y) { array b_fv; array fv; array wwc; array yCol; array costab; array costab1q; array sintab; array sintabinv; int N2blue; int nd2; int nfft; nfft = x.size(1); if (x.size(1) == 0) { y.set_size(1, 0); } else { double nt_im; int i; int k; int nInt2; int rt; boolean_T useRadix2; useRadix2 = ((x.size(1) & (x.size(1) - 1)) == 0); internal::fun1_FFTImplementationCallback::get_algo_sizes(x.size(1), useRadix2, &N2blue, &nd2); nt_im = 6.2831853071795862 / static_cast(nd2); nInt2 = nd2 / 2 / 2; costab1q.set_size(1, nInt2 + 1); costab1q[0] = 1.0; nd2 = nInt2 / 2 - 1; for (k = 0; k <= nd2; k++) { costab1q[k + 1] = std::cos(nt_im * (static_cast(k) + 1.0)); } i = nd2 + 2; rt = nInt2 - 1; for (k = i; k <= rt; k++) { costab1q[k] = std::sin(nt_im * static_cast(nInt2 - k)); } costab1q[nInt2] = 0.0; if (!useRadix2) { nInt2 = costab1q.size(1) - 1; nd2 = (costab1q.size(1) - 1) << 1; costab.set_size(1, nd2 + 1); sintab.set_size(1, nd2 + 1); costab[0] = 1.0; sintab[0] = 0.0; sintabinv.set_size(1, nd2 + 1); for (k = 0; k < nInt2; k++) { sintabinv[k + 1] = costab1q[(nInt2 - k) - 1]; } i = costab1q.size(1); for (k = i; k <= nd2; k++) { sintabinv[k] = costab1q[k - nInt2]; } for (k = 0; k < nInt2; k++) { costab[k + 1] = costab1q[k + 1]; sintab[k + 1] = -costab1q[(nInt2 - k) - 1]; } i = costab1q.size(1); for (k = i; k <= nd2; k++) { costab[k] = -costab1q[nd2 - k]; sintab[k] = -costab1q[k - nInt2]; } } else { nInt2 = costab1q.size(1) - 1; nd2 = (costab1q.size(1) - 1) << 1; costab.set_size(1, nd2 + 1); sintab.set_size(1, nd2 + 1); costab[0] = 1.0; sintab[0] = 0.0; for (k = 0; k < nInt2; k++) { costab[k + 1] = costab1q[k + 1]; sintab[k + 1] = costab1q[(nInt2 - k) - 1]; } i = costab1q.size(1); for (k = i; k <= nd2; k++) { costab[k] = -costab1q[nd2 - k]; sintab[k] = costab1q[k - nInt2]; } sintabinv.set_size(1, 0); } if (useRadix2) { nd2 = x.size(1); wwc = x.reshape(nd2); internal::fun1_FFTImplementationCallback::r2br_r2dit_trig_impl( wwc, x.size(1), costab, sintab, yCol); if (yCol.size(0) > 1) { nt_im = 1.0 / static_cast(yCol.size(0)); nd2 = yCol.size(0); for (i = 0; i < nd2; i++) { yCol[i].re = nt_im * yCol[i].re; yCol[i].im = nt_im * yCol[i].im; } } } else { double nt_re; nd2 = (x.size(1) + x.size(1)) - 1; wwc.set_size(nd2); rt = 0; wwc[x.size(1) - 1].re = 1.0; wwc[x.size(1) - 1].im = 0.0; nInt2 = x.size(1) << 1; i = x.size(1); for (k = 0; k <= i - 2; k++) { int b_y; b_y = ((k + 1) << 1) - 1; if (nInt2 - rt <= b_y) { rt += b_y - nInt2; } else { rt += b_y; } 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); } wwc[(x.size(1) - k) - 2].re = nt_re; wwc[(x.size(1) - k) - 2].im = -nt_im; } i = nd2 - 1; for (k = i; k >= nfft; k--) { wwc[k] = wwc[(nd2 - k) - 1]; } yCol.set_size(x.size(1)); nd2 = x.size(1); for (k = 0; k < nd2; k++) { nt_re = wwc[(nfft + k) - 1].re; nt_im = wwc[(nfft + k) - 1].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; } i = x.size(1) + 1; for (k = i; k <= nfft; k++) { yCol[k - 1].re = 0.0; yCol[k - 1].im = 0.0; } internal::fun1_FFTImplementationCallback::r2br_r2dit_trig_impl( yCol, N2blue, costab, sintab, fv); internal::fun1_FFTImplementationCallback::r2br_r2dit_trig_impl( wwc, N2blue, costab, sintab, b_fv); b_fv.set_size(fv.size(0)); nd2 = fv.size(0); for (i = 0; i < nd2; i++) { nt_im = fv[i].re * b_fv[i].im + fv[i].im * b_fv[i].re; b_fv[i].re = fv[i].re * b_fv[i].re - fv[i].im * b_fv[i].im; b_fv[i].im = nt_im; } internal::fun1_FFTImplementationCallback::r2br_r2dit_trig_impl( b_fv, N2blue, costab, sintabinv, fv); if (fv.size(0) > 1) { nt_im = 1.0 / static_cast(fv.size(0)); nd2 = fv.size(0); for (i = 0; i < nd2; i++) { fv[i].re = nt_im * fv[i].re; fv[i].im = nt_im * fv[i].im; } } nt_re = x.size(1); i = x.size(1); rt = wwc.size(0); for (k = i; k <= rt; k++) { double ai; nt_im = wwc[k - 1].re * fv[k - 1].re + wwc[k - 1].im * fv[k - 1].im; ai = wwc[k - 1].re * fv[k - 1].im - wwc[k - 1].im * fv[k - 1].re; if (ai == 0.0) { nd2 = k - i; yCol[nd2].re = nt_im / nt_re; yCol[nd2].im = 0.0; } else if (nt_im == 0.0) { nd2 = k - i; yCol[nd2].re = 0.0; yCol[nd2].im = ai / nt_re; } else { nd2 = k - i; yCol[nd2].re = nt_im / nt_re; yCol[nd2].im = ai / nt_re; } } } y.set_size(1, x.size(1)); nd2 = x.size(1); for (i = 0; i < nd2; i++) { y[i] = yCol[i]; } } } } // namespace coder // // File trailer for ifft_1.cpp // // [EOF] //