123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- //
- // 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 <cmath>
- // Function Definitions
- //
- // Arguments : const ::coder::array<creal_T, 2U> &x
- // ::coder::array<creal_T, 2U> &y
- // Return Type : void
- //
- namespace coder {
- void ifft_8_3(const ::coder::array<creal_T, 2U> &x, ::coder::array<creal_T, 2U> &y)
- {
- array<creal_T, 1U> fv;
- array<creal_T, 1U> fy;
- array<creal_T, 1U> wwc;
- array<creal_T, 1U> yCol;
- array<double, 2U> costab;
- array<double, 2U> costab1q;
- array<double, 2U> sintab;
- array<double, 2U> 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<double>(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<double>(k) + 1.0));
- }
- j = pmax + 2;
- pmax = ihi - 1;
- for (k = j; k <= pmax; k++) {
- costab1q[k] = std::sin(twid_re * static_cast<double>(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<double>(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<double>(pmin) /
- static_cast<double>(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<double>(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]
- //
|