123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710 |
- //
- // File: fun1_FFTImplementationCallback.cpp
- //
- // MATLAB Coder version : 5.2
- // C/C++ source code generated on : 11-Mar-2023 10:38:07
- //
- // Include Files
- #include "fun1_FFTImplementationCallback.h"
- #include "rt_nonfinite.h"
- #include "coder_array.h"
- #include <cmath>
- // Function Definitions
- //
- // Arguments : const ::coder::array<double, 1U> &x
- // ::coder::array<creal_T, 1U> &y
- // int nrowsx
- // int nRows
- // int nfft
- // const ::coder::array<creal_T, 1U> &wwc
- // const ::coder::array<double, 2U> &costab
- // const ::coder::array<double, 2U> &sintab
- // const ::coder::array<double, 2U> &costabinv
- // const ::coder::array<double, 2U> &sintabinv
- // Return Type : void
- //
- namespace coder {
- namespace internal {
- void fun1_FFTImplementationCallback::doHalfLengthBluestein(
- const ::coder::array<double, 1U> &x, ::coder::array<creal_T, 1U> &y,
- int nrowsx, int nRows, int nfft, const ::coder::array<creal_T, 1U> &wwc,
- const ::coder::array<double, 2U> &costab,
- const ::coder::array<double, 2U> &sintab,
- const ::coder::array<double, 2U> &costabinv,
- const ::coder::array<double, 2U> &sintabinv)
- {
- array<creal_T, 1U> fv;
- array<creal_T, 1U> fy;
- array<creal_T, 1U> reconVar1;
- array<creal_T, 1U> reconVar2;
- array<creal_T, 1U> ytmp;
- array<double, 2U> b_costab;
- array<double, 2U> b_sintab;
- array<double, 2U> costab1q;
- array<double, 2U> hcostabinv;
- array<double, 2U> hsintab;
- array<double, 2U> hsintabinv;
- array<int, 2U> wrapIndex;
- double temp_im;
- double temp_re;
- double twid_im;
- double twid_re;
- double z_tmp;
- int hnRows;
- int i;
- int iDelta2;
- int ihi;
- int istart;
- int j;
- int ju;
- int k;
- int nRowsD2;
- int nd2;
- int temp_re_tmp;
- boolean_T tst;
- hnRows = nRows / 2;
- ytmp.set_size(hnRows);
- if (hnRows > nrowsx) {
- ytmp.set_size(hnRows);
- for (iDelta2 = 0; iDelta2 < hnRows; iDelta2++) {
- ytmp[iDelta2].re = 0.0;
- ytmp[iDelta2].im = 0.0;
- }
- }
- if ((x.size(0) & 1) == 0) {
- tst = true;
- ihi = x.size(0);
- } else if (x.size(0) >= nRows) {
- tst = true;
- ihi = nRows;
- } else {
- tst = false;
- ihi = x.size(0) - 1;
- }
- if (ihi >= nRows) {
- ihi = nRows;
- }
- nd2 = nRows << 1;
- twid_re = 6.2831853071795862 / static_cast<double>(nd2);
- j = nd2 / 2 / 2;
- costab1q.set_size(1, j + 1);
- costab1q[0] = 1.0;
- nd2 = j / 2 - 1;
- for (k = 0; k <= nd2; k++) {
- costab1q[k + 1] = std::cos(twid_re * (static_cast<double>(k) + 1.0));
- }
- iDelta2 = nd2 + 2;
- nd2 = j - 1;
- for (k = iDelta2; k <= nd2; k++) {
- costab1q[k] = std::sin(twid_re * static_cast<double>(j - k));
- }
- costab1q[j] = 0.0;
- j = costab1q.size(1) - 1;
- nd2 = (costab1q.size(1) - 1) << 1;
- b_costab.set_size(1, nd2 + 1);
- b_sintab.set_size(1, nd2 + 1);
- b_costab[0] = 1.0;
- b_sintab[0] = 0.0;
- for (k = 0; k < j; k++) {
- b_costab[k + 1] = costab1q[k + 1];
- b_sintab[k + 1] = -costab1q[(j - k) - 1];
- }
- iDelta2 = costab1q.size(1);
- for (k = iDelta2; k <= nd2; k++) {
- b_costab[k] = -costab1q[nd2 - k];
- b_sintab[k] = -costab1q[k - j];
- }
- nd2 = costab.size(1) / 2;
- costab1q.set_size(1, nd2);
- hsintab.set_size(1, nd2);
- hcostabinv.set_size(1, nd2);
- hsintabinv.set_size(1, nd2);
- for (i = 0; i < nd2; i++) {
- iDelta2 = ((i + 1) << 1) - 2;
- costab1q[i] = costab[iDelta2];
- hsintab[i] = sintab[iDelta2];
- hcostabinv[i] = costabinv[iDelta2];
- hsintabinv[i] = sintabinv[iDelta2];
- }
- reconVar1.set_size(hnRows);
- reconVar2.set_size(hnRows);
- wrapIndex.set_size(1, hnRows);
- for (i = 0; i < hnRows; i++) {
- iDelta2 = i << 1;
- twid_re = b_sintab[iDelta2];
- twid_im = b_costab[iDelta2];
- reconVar1[i].re = twid_re + 1.0;
- reconVar1[i].im = -twid_im;
- reconVar2[i].re = 1.0 - twid_re;
- reconVar2[i].im = twid_im;
- if (i + 1 != 1) {
- wrapIndex[i] = (hnRows - i) + 1;
- } else {
- wrapIndex[0] = 1;
- }
- }
- z_tmp = static_cast<double>(ihi) / 2.0;
- iDelta2 = static_cast<int>(z_tmp);
- for (ju = 0; ju < iDelta2; ju++) {
- temp_re_tmp = (hnRows + ju) - 1;
- temp_re = wwc[temp_re_tmp].re;
- temp_im = wwc[temp_re_tmp].im;
- nd2 = ju << 1;
- twid_re = x[nd2];
- twid_im = x[nd2 + 1];
- ytmp[ju].re = temp_re * twid_re + temp_im * twid_im;
- ytmp[ju].im = temp_re * twid_im - temp_im * twid_re;
- }
- if (!tst) {
- temp_re_tmp = (hnRows + static_cast<int>(z_tmp)) - 1;
- temp_re = wwc[temp_re_tmp].re;
- temp_im = wwc[temp_re_tmp].im;
- twid_re = x[static_cast<int>(z_tmp) << 1];
- ytmp[static_cast<int>(z_tmp)].re = temp_re * twid_re + temp_im * 0.0;
- ytmp[static_cast<int>(z_tmp)].im = temp_re * 0.0 - temp_im * twid_re;
- if (static_cast<int>(z_tmp) + 2 <= hnRows) {
- iDelta2 = static_cast<int>(static_cast<double>(ihi) / 2.0) + 2;
- for (i = iDelta2; i <= hnRows; i++) {
- ytmp[i - 1].re = 0.0;
- ytmp[i - 1].im = 0.0;
- }
- }
- } else if (static_cast<int>(z_tmp) + 1 <= hnRows) {
- iDelta2 = static_cast<int>(static_cast<double>(ihi) / 2.0) + 1;
- for (i = iDelta2; i <= hnRows; i++) {
- ytmp[i - 1].re = 0.0;
- ytmp[i - 1].im = 0.0;
- }
- }
- z_tmp = static_cast<double>(nfft) / 2.0;
- nd2 = static_cast<int>(z_tmp);
- fy.set_size(nd2);
- if (static_cast<int>(z_tmp) > ytmp.size(0)) {
- fy.set_size(nd2);
- for (iDelta2 = 0; iDelta2 < nd2; iDelta2++) {
- fy[iDelta2].re = 0.0;
- fy[iDelta2].im = 0.0;
- }
- }
- ihi = ytmp.size(0);
- istart = static_cast<int>(z_tmp);
- if (ihi < istart) {
- istart = ihi;
- }
- iDelta2 = static_cast<int>(z_tmp) - 2;
- nRowsD2 = static_cast<int>(z_tmp) / 2;
- k = nRowsD2 / 2;
- nd2 = 0;
- ju = 0;
- for (i = 0; i <= istart - 2; i++) {
- fy[nd2] = ytmp[i];
- j = static_cast<int>(z_tmp);
- tst = true;
- while (tst) {
- j >>= 1;
- ju ^= j;
- tst = ((ju & j) == 0);
- }
- nd2 = ju;
- }
- fy[nd2] = ytmp[istart - 1];
- if (static_cast<int>(z_tmp) > 1) {
- for (i = 0; i <= iDelta2; i += 2) {
- temp_re = fy[i + 1].re;
- temp_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 += temp_re;
- twid_im += temp_im;
- fy[i].re = twid_re;
- fy[i].im = twid_im;
- }
- }
- nd2 = 2;
- iDelta2 = 4;
- ju = ((k - 1) << 2) + 1;
- while (k > 0) {
- for (i = 0; i < ju; i += iDelta2) {
- temp_re_tmp = i + nd2;
- temp_re = fy[temp_re_tmp].re;
- temp_im = fy[temp_re_tmp].im;
- fy[temp_re_tmp].re = fy[i].re - temp_re;
- fy[temp_re_tmp].im = fy[i].im - temp_im;
- fy[i].re = fy[i].re + temp_re;
- fy[i].im = fy[i].im + temp_im;
- }
- istart = 1;
- for (j = k; j < nRowsD2; j += k) {
- twid_re = costab1q[j];
- twid_im = hsintab[j];
- i = istart;
- ihi = istart + ju;
- while (i < ihi) {
- temp_re_tmp = i + nd2;
- temp_re = twid_re * fy[temp_re_tmp].re - twid_im * fy[temp_re_tmp].im;
- temp_im = twid_re * fy[temp_re_tmp].im + twid_im * fy[temp_re_tmp].re;
- fy[temp_re_tmp].re = fy[i].re - temp_re;
- fy[temp_re_tmp].im = fy[i].im - temp_im;
- fy[i].re = fy[i].re + temp_re;
- fy[i].im = fy[i].im + temp_im;
- i += iDelta2;
- }
- istart++;
- }
- k /= 2;
- nd2 = iDelta2;
- iDelta2 += iDelta2;
- ju -= nd2;
- }
- fun1_FFTImplementationCallback::r2br_r2dit_trig_impl(wwc, static_cast<int>(z_tmp),
- costab1q, hsintab, fv);
- nd2 = fy.size(0);
- for (iDelta2 = 0; iDelta2 < nd2; iDelta2++) {
- twid_im = fy[iDelta2].re * fv[iDelta2].im + fy[iDelta2].im * fv[iDelta2].re;
- fy[iDelta2].re =
- fy[iDelta2].re * fv[iDelta2].re - fy[iDelta2].im * fv[iDelta2].im;
- fy[iDelta2].im = twid_im;
- }
- fun1_FFTImplementationCallback::r2br_r2dit_trig_impl(fy, static_cast<int>(z_tmp),
- hcostabinv, hsintabinv, fv);
- if (fv.size(0) > 1) {
- twid_re = 1.0 / static_cast<double>(fv.size(0));
- nd2 = fv.size(0);
- for (iDelta2 = 0; iDelta2 < nd2; iDelta2++) {
- fv[iDelta2].re = twid_re * fv[iDelta2].re;
- fv[iDelta2].im = twid_re * fv[iDelta2].im;
- }
- }
- iDelta2 = wwc.size(0);
- for (k = hnRows; k <= iDelta2; k++) {
- nd2 = k - hnRows;
- ytmp[nd2].re = wwc[k - 1].re * fv[k - 1].re + wwc[k - 1].im * fv[k - 1].im;
- ytmp[nd2].im = wwc[k - 1].re * fv[k - 1].im - wwc[k - 1].im * fv[k - 1].re;
- }
- for (i = 0; i < hnRows; i++) {
- iDelta2 = wrapIndex[i];
- twid_re = ytmp[iDelta2 - 1].re;
- twid_im = -ytmp[iDelta2 - 1].im;
- y[i].re =
- 0.5 * ((ytmp[i].re * reconVar1[i].re - ytmp[i].im * reconVar1[i].im) +
- (twid_re * reconVar2[i].re - twid_im * reconVar2[i].im));
- y[i].im =
- 0.5 * ((ytmp[i].re * reconVar1[i].im + ytmp[i].im * reconVar1[i].re) +
- (twid_re * reconVar2[i].im + twid_im * reconVar2[i].re));
- iDelta2 = hnRows + i;
- y[iDelta2].re =
- 0.5 * ((ytmp[i].re * reconVar2[i].re - ytmp[i].im * reconVar2[i].im) +
- (twid_re * reconVar1[i].re - twid_im * reconVar1[i].im));
- y[iDelta2].im =
- 0.5 * ((ytmp[i].re * reconVar2[i].im + ytmp[i].im * reconVar2[i].re) +
- (twid_re * reconVar1[i].im + twid_im * reconVar1[i].re));
- }
- }
- //
- // Arguments : const ::coder::array<double, 1U> &x
- // ::coder::array<creal_T, 1U> &y
- // int unsigned_nRows
- // const ::coder::array<double, 2U> &costab
- // const ::coder::array<double, 2U> &sintab
- // Return Type : void
- //
- void fun1_FFTImplementationCallback::doHalfLengthRadix2(
- const ::coder::array<double, 1U> &x, ::coder::array<creal_T, 1U> &y,
- int unsigned_nRows, const ::coder::array<double, 2U> &costab,
- const ::coder::array<double, 2U> &sintab)
- {
- array<creal_T, 1U> reconVar1;
- array<creal_T, 1U> reconVar2;
- array<double, 2U> hcostab;
- array<double, 2U> hsintab;
- array<int, 2U> wrapIndex;
- array<int, 1U> bitrevIndex;
- double b_y_im;
- double temp2_im;
- double temp2_re;
- double temp_im;
- double temp_re;
- double y_im;
- double y_im_tmp;
- double z_tmp;
- int hszCostab;
- int i;
- int istart;
- int iy;
- int j;
- int ju;
- int k;
- int nRows;
- int nRowsD2;
- int nRowsM2;
- boolean_T tst;
- nRows = unsigned_nRows / 2;
- j = y.size(0);
- if (j >= nRows) {
- j = nRows;
- }
- nRowsM2 = nRows - 2;
- nRowsD2 = nRows / 2;
- k = nRowsD2 / 2;
- hszCostab = costab.size(1) / 2;
- hcostab.set_size(1, hszCostab);
- hsintab.set_size(1, hszCostab);
- for (i = 0; i < hszCostab; i++) {
- iy = ((i + 1) << 1) - 2;
- hcostab[i] = costab[iy];
- hsintab[i] = sintab[iy];
- }
- reconVar1.set_size(nRows);
- reconVar2.set_size(nRows);
- wrapIndex.set_size(1, nRows);
- for (i = 0; i < nRows; i++) {
- temp2_re = sintab[i];
- y_im = costab[i];
- reconVar1[i].re = temp2_re + 1.0;
- reconVar1[i].im = -y_im;
- reconVar2[i].re = 1.0 - temp2_re;
- reconVar2[i].im = y_im;
- if (i + 1 != 1) {
- wrapIndex[i] = (nRows - i) + 1;
- } else {
- wrapIndex[0] = 1;
- }
- }
- z_tmp = static_cast<double>(unsigned_nRows) / 2.0;
- ju = 0;
- iy = 1;
- hszCostab = static_cast<int>(z_tmp);
- bitrevIndex.set_size(hszCostab);
- for (istart = 0; istart < hszCostab; istart++) {
- bitrevIndex[istart] = 0;
- }
- for (istart = 0; istart <= j - 2; istart++) {
- bitrevIndex[istart] = iy;
- hszCostab = static_cast<int>(z_tmp);
- tst = true;
- while (tst) {
- hszCostab >>= 1;
- ju ^= hszCostab;
- tst = ((ju & hszCostab) == 0);
- }
- iy = ju + 1;
- }
- bitrevIndex[j - 1] = iy;
- if ((x.size(0) & 1) == 0) {
- tst = true;
- j = x.size(0);
- } else if (x.size(0) >= unsigned_nRows) {
- tst = true;
- j = unsigned_nRows;
- } else {
- tst = false;
- j = x.size(0) - 1;
- }
- if (j >= unsigned_nRows) {
- j = unsigned_nRows;
- }
- temp2_re = static_cast<double>(j) / 2.0;
- istart = static_cast<int>(temp2_re);
- for (i = 0; i < istart; i++) {
- iy = i << 1;
- y[bitrevIndex[i] - 1].re = x[iy];
- y[bitrevIndex[i] - 1].im = x[iy + 1];
- }
- if (!tst) {
- istart = bitrevIndex[static_cast<int>(temp2_re)] - 1;
- y[istart].re = x[static_cast<int>(temp2_re) << 1];
- y[istart].im = 0.0;
- }
- if (nRows > 1) {
- for (i = 0; i <= nRowsM2; i += 2) {
- temp_re = y[i + 1].re;
- temp_im = y[i + 1].im;
- y[i + 1].re = y[i].re - y[i + 1].re;
- y[i + 1].im = y[i].im - y[i + 1].im;
- y[i].re = y[i].re + temp_re;
- y[i].im = y[i].im + temp_im;
- }
- }
- hszCostab = 2;
- iy = 4;
- ju = ((k - 1) << 2) + 1;
- while (k > 0) {
- for (i = 0; i < ju; i += iy) {
- nRowsM2 = i + hszCostab;
- temp_re = y[nRowsM2].re;
- temp_im = y[nRowsM2].im;
- y[nRowsM2].re = y[i].re - temp_re;
- y[nRowsM2].im = y[i].im - temp_im;
- y[i].re = y[i].re + temp_re;
- y[i].im = y[i].im + temp_im;
- }
- istart = 1;
- for (j = k; j < nRowsD2; j += k) {
- temp2_re = hcostab[j];
- temp2_im = hsintab[j];
- i = istart;
- nRows = istart + ju;
- while (i < nRows) {
- nRowsM2 = i + hszCostab;
- temp_re = temp2_re * y[nRowsM2].re - temp2_im * y[nRowsM2].im;
- temp_im = temp2_re * y[nRowsM2].im + temp2_im * y[nRowsM2].re;
- y[nRowsM2].re = y[i].re - temp_re;
- y[nRowsM2].im = y[i].im - temp_im;
- y[i].re = y[i].re + temp_re;
- y[i].im = y[i].im + temp_im;
- i += iy;
- }
- istart++;
- }
- k /= 2;
- hszCostab = iy;
- iy += iy;
- ju -= hszCostab;
- }
- hszCostab = static_cast<int>(z_tmp) / 2;
- temp2_re = y[0].re;
- temp_im = y[0].im;
- b_y_im = y[0].re * reconVar1[0].im + y[0].im * reconVar1[0].re;
- y_im = -y[0].im;
- y[0].re = 0.5 * ((y[0].re * reconVar1[0].re - y[0].im * reconVar1[0].im) +
- (temp2_re * reconVar2[0].re - y_im * reconVar2[0].im));
- y[0].im =
- 0.5 * (b_y_im + (temp2_re * reconVar2[0].im + y_im * reconVar2[0].re));
- y[static_cast<int>(z_tmp)].re =
- 0.5 * ((temp2_re * reconVar2[0].re - temp_im * reconVar2[0].im) +
- (temp2_re * reconVar1[0].re - -temp_im * reconVar1[0].im));
- y[static_cast<int>(z_tmp)].im =
- 0.5 * ((temp2_re * reconVar2[0].im + temp_im * reconVar2[0].re) +
- (temp2_re * reconVar1[0].im + -temp_im * reconVar1[0].re));
- for (i = 2; i <= hszCostab; i++) {
- temp_re = y[i - 1].re;
- temp_im = y[i - 1].im;
- istart = wrapIndex[i - 1];
- y_im = y[istart - 1].re;
- temp2_im = y[istart - 1].im;
- b_y_im =
- y[i - 1].re * reconVar1[i - 1].im + y[i - 1].im * reconVar1[i - 1].re;
- y_im_tmp = -y[istart - 1].im;
- y[i - 1].re =
- 0.5 * ((y[i - 1].re * reconVar1[i - 1].re -
- y[i - 1].im * reconVar1[i - 1].im) +
- (y_im * reconVar2[i - 1].re - y_im_tmp * reconVar2[i - 1].im));
- y[i - 1].im = 0.5 * (b_y_im + (y_im * reconVar2[i - 1].im +
- y_im_tmp * reconVar2[i - 1].re));
- iy = (static_cast<int>(z_tmp) + i) - 1;
- y[iy].re =
- 0.5 * ((temp_re * reconVar2[i - 1].re - temp_im * reconVar2[i - 1].im) +
- (y_im * reconVar1[i - 1].re - -temp2_im * reconVar1[i - 1].im));
- y[iy].im =
- 0.5 * ((temp_re * reconVar2[i - 1].im + temp_im * reconVar2[i - 1].re) +
- (y_im * reconVar1[i - 1].im + -temp2_im * reconVar1[i - 1].re));
- y[istart - 1].re = 0.5 * ((y_im * reconVar1[istart - 1].re -
- temp2_im * reconVar1[istart - 1].im) +
- (temp_re * reconVar2[istart - 1].re -
- -temp_im * reconVar2[istart - 1].im));
- y[istart - 1].im = 0.5 * ((y_im * reconVar1[istart - 1].im +
- temp2_im * reconVar1[istart - 1].re) +
- (temp_re * reconVar2[istart - 1].im +
- -temp_im * reconVar2[istart - 1].re));
- iy = (istart + static_cast<int>(z_tmp)) - 1;
- y[iy].re = 0.5 * ((y_im * reconVar2[istart - 1].re -
- temp2_im * reconVar2[istart - 1].im) +
- (temp_re * reconVar1[istart - 1].re -
- -temp_im * reconVar1[istart - 1].im));
- y[iy].im = 0.5 * ((y_im * reconVar2[istart - 1].im +
- temp2_im * reconVar2[istart - 1].re) +
- (temp_re * reconVar1[istart - 1].im +
- -temp_im * reconVar1[istart - 1].re));
- }
- if (hszCostab != 0) {
- temp2_re = y[hszCostab].re;
- temp_im = y[hszCostab].im;
- b_y_im = y[hszCostab].re * reconVar1[hszCostab].im +
- y[hszCostab].im * reconVar1[hszCostab].re;
- y_im_tmp = -y[hszCostab].im;
- y[hszCostab].re = 0.5 * ((y[hszCostab].re * reconVar1[hszCostab].re -
- y[hszCostab].im * reconVar1[hszCostab].im) +
- (temp2_re * reconVar2[hszCostab].re -
- y_im_tmp * reconVar2[hszCostab].im));
- y[hszCostab].im = 0.5 * (b_y_im + (temp2_re * reconVar2[hszCostab].im +
- y_im_tmp * reconVar2[hszCostab].re));
- istart = static_cast<int>(z_tmp) + hszCostab;
- y[istart].re = 0.5 * ((temp2_re * reconVar2[hszCostab].re -
- temp_im * reconVar2[hszCostab].im) +
- (temp2_re * reconVar1[hszCostab].re -
- -temp_im * reconVar1[hszCostab].im));
- y[istart].im = 0.5 * ((temp2_re * reconVar2[hszCostab].im +
- temp_im * reconVar2[hszCostab].re) +
- (temp2_re * reconVar1[hszCostab].im +
- -temp_im * reconVar1[hszCostab].re));
- }
- }
- //
- // Arguments : int nfft
- // boolean_T useRadix2
- // int *n2blue
- // int *nRows
- // Return Type : void
- //
- void fun1_FFTImplementationCallback::get_algo_sizes(int nfft, boolean_T useRadix2,
- int *n2blue, int *nRows)
- {
- *n2blue = 1;
- if (useRadix2) {
- *nRows = nfft;
- } else {
- if (nfft > 0) {
- int n;
- int pmax;
- n = (nfft + nfft) - 1;
- pmax = 31;
- if (n <= 1) {
- pmax = 0;
- } else {
- int pmin;
- boolean_T exitg1;
- pmin = 0;
- exitg1 = false;
- while ((!exitg1) && (pmax - pmin > 1)) {
- int k;
- int pow2p;
- k = (pmin + pmax) >> 1;
- pow2p = 1 << k;
- if (pow2p == n) {
- pmax = k;
- exitg1 = true;
- } else if (pow2p > n) {
- pmax = k;
- } else {
- pmin = k;
- }
- }
- }
- *n2blue = 1 << pmax;
- }
- *nRows = *n2blue;
- }
- }
- //
- // Arguments : const ::coder::array<creal_T, 1U> &x
- // int unsigned_nRows
- // const ::coder::array<double, 2U> &costab
- // const ::coder::array<double, 2U> &sintab
- // ::coder::array<creal_T, 1U> &y
- // Return Type : void
- //
- void fun1_FFTImplementationCallback::r2br_r2dit_trig_impl(
- const ::coder::array<creal_T, 1U> &x, int unsigned_nRows,
- const ::coder::array<double, 2U> &costab,
- const ::coder::array<double, 2U> &sintab, ::coder::array<creal_T, 1U> &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 internal
- } // namespace coder
- //
- // File trailer for fun1_FFTImplementationCallback.cpp
- //
- // [EOF]
- //
|