arm_rfft_fast_f32.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_rfft_fast_f32.c
  4. * Description: RFFT & RIFFT Floating point process function
  5. *
  6. * $Date: 23 April 2021
  7. * $Revision: V1.9.0
  8. *
  9. * Target Processor: Cortex-M and Cortex-A cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
  13. *
  14. * SPDX-License-Identifier: Apache-2.0
  15. *
  16. * Licensed under the Apache License, Version 2.0 (the License); you may
  17. * not use this file except in compliance with the License.
  18. * You may obtain a copy of the License at
  19. *
  20. * www.apache.org/licenses/LICENSE-2.0
  21. *
  22. * Unless required by applicable law or agreed to in writing, software
  23. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  24. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  25. * See the License for the specific language governing permissions and
  26. * limitations under the License.
  27. */
  28. #include "dsp/transform_functions.h"
  29. #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
  30. void stage_rfft_f32(
  31. const arm_rfft_fast_instance_f32 * S,
  32. float32_t * p,
  33. float32_t * pOut)
  34. {
  35. int32_t k; /* Loop Counter */
  36. float32_t twR, twI; /* RFFT Twiddle coefficients */
  37. const float32_t * pCoeff = S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */
  38. float32_t *pA = p; /* increasing pointer */
  39. float32_t *pB = p; /* decreasing pointer */
  40. float32_t xAR, xAI, xBR, xBI; /* temporary variables */
  41. float32_t t1a, t1b; /* temporary variables */
  42. float32_t p0, p1, p2, p3; /* temporary variables */
  43. float32x4x2_t tw,xA,xB;
  44. float32x4x2_t tmp1, tmp2, res;
  45. uint32x4_t vecStridesFwd, vecStridesBkwd;
  46. vecStridesFwd = vidupq_u32((uint32_t)0, 2);
  47. vecStridesBkwd = -vecStridesFwd;
  48. int blockCnt;
  49. k = (S->Sint).fftLen - 1;
  50. /* Pack first and last sample of the frequency domain together */
  51. xBR = pB[0];
  52. xBI = pB[1];
  53. xAR = pA[0];
  54. xAI = pA[1];
  55. twR = *pCoeff++ ;
  56. twI = *pCoeff++ ;
  57. // U1 = XA(1) + XB(1); % It is real
  58. t1a = xBR + xAR ;
  59. // U2 = XB(1) - XA(1); % It is imaginary
  60. t1b = xBI + xAI ;
  61. // real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI);
  62. // imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI);
  63. *pOut++ = 0.5f * ( t1a + t1b );
  64. *pOut++ = 0.5f * ( t1a - t1b );
  65. // XA(1) = 1/2*( U1 - imag(U2) + i*( U1 +imag(U2) ));
  66. pB = p + 2*k;
  67. pA += 2;
  68. blockCnt = k >> 2;
  69. while (blockCnt > 0)
  70. {
  71. /*
  72. function X = my_split_rfft(X, ifftFlag)
  73. % X is a series of real numbers
  74. L = length(X);
  75. XC = X(1:2:end) +i*X(2:2:end);
  76. XA = fft(XC);
  77. XB = conj(XA([1 end:-1:2]));
  78. TW = i*exp(-2*pi*i*[0:L/2-1]/L).';
  79. for l = 2:L/2
  80. XA(l) = 1/2 * (XA(l) + XB(l) + TW(l) * (XB(l) - XA(l)));
  81. end
  82. XA(1) = 1/2* (XA(1) + XB(1) + TW(1) * (XB(1) - XA(1))) + i*( 1/2*( XA(1) + XB(1) + i*( XA(1) - XB(1))));
  83. X = XA;
  84. */
  85. xA = vld2q_f32(pA);
  86. pA += 8;
  87. xB = vld2q_f32(pB);
  88. xB.val[0] = vldrwq_gather_shifted_offset_f32(pB, vecStridesBkwd);
  89. xB.val[1] = vldrwq_gather_shifted_offset_f32(&pB[1], vecStridesBkwd);
  90. xB.val[1] = vnegq_f32(xB.val[1]);
  91. pB -= 8;
  92. tw = vld2q_f32(pCoeff);
  93. pCoeff += 8;
  94. tmp1.val[0] = vaddq_f32(xA.val[0],xB.val[0]);
  95. tmp1.val[1] = vaddq_f32(xA.val[1],xB.val[1]);
  96. tmp2.val[0] = vsubq_f32(xB.val[0],xA.val[0]);
  97. tmp2.val[1] = vsubq_f32(xB.val[1],xA.val[1]);
  98. res.val[0] = vmulq(tw.val[0], tmp2.val[0]);
  99. res.val[0] = vfmsq(res.val[0],tw.val[1], tmp2.val[1]);
  100. res.val[1] = vmulq(tw.val[0], tmp2.val[1]);
  101. res.val[1] = vfmaq(res.val[1], tw.val[1], tmp2.val[0]);
  102. res.val[0] = vaddq_f32(res.val[0],tmp1.val[0] );
  103. res.val[1] = vaddq_f32(res.val[1],tmp1.val[1] );
  104. res.val[0] = vmulq_n_f32(res.val[0], 0.5f);
  105. res.val[1] = vmulq_n_f32(res.val[1], 0.5f);
  106. vst2q_f32(pOut, res);
  107. pOut += 8;
  108. blockCnt--;
  109. }
  110. blockCnt = k & 3;
  111. while (blockCnt > 0)
  112. {
  113. /*
  114. function X = my_split_rfft(X, ifftFlag)
  115. % X is a series of real numbers
  116. L = length(X);
  117. XC = X(1:2:end) +i*X(2:2:end);
  118. XA = fft(XC);
  119. XB = conj(XA([1 end:-1:2]));
  120. TW = i*exp(-2*pi*i*[0:L/2-1]/L).';
  121. for l = 2:L/2
  122. XA(l) = 1/2 * (XA(l) + XB(l) + TW(l) * (XB(l) - XA(l)));
  123. end
  124. XA(1) = 1/2* (XA(1) + XB(1) + TW(1) * (XB(1) - XA(1))) + i*( 1/2*( XA(1) + XB(1) + i*( XA(1) - XB(1))));
  125. X = XA;
  126. */
  127. xBI = pB[1];
  128. xBR = pB[0];
  129. xAR = pA[0];
  130. xAI = pA[1];
  131. twR = *pCoeff++;
  132. twI = *pCoeff++;
  133. t1a = xBR - xAR ;
  134. t1b = xBI + xAI ;
  135. // real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI);
  136. // imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI);
  137. p0 = twR * t1a;
  138. p1 = twI * t1a;
  139. p2 = twR * t1b;
  140. p3 = twI * t1b;
  141. *pOut++ = 0.5f * (xAR + xBR + p0 + p3 ); //xAR
  142. *pOut++ = 0.5f * (xAI - xBI + p1 - p2 ); //xAI
  143. pA += 2;
  144. pB -= 2;
  145. blockCnt--;
  146. }
  147. }
  148. /* Prepares data for inverse cfft */
  149. void merge_rfft_f32(
  150. const arm_rfft_fast_instance_f32 * S,
  151. float32_t * p,
  152. float32_t * pOut)
  153. {
  154. int32_t k; /* Loop Counter */
  155. float32_t twR, twI; /* RFFT Twiddle coefficients */
  156. const float32_t *pCoeff = S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */
  157. float32_t *pA = p; /* increasing pointer */
  158. float32_t *pB = p; /* decreasing pointer */
  159. float32_t xAR, xAI, xBR, xBI; /* temporary variables */
  160. float32_t t1a, t1b, r, s, t, u; /* temporary variables */
  161. float32x4x2_t tw,xA,xB;
  162. float32x4x2_t tmp1, tmp2, res;
  163. uint32x4_t vecStridesFwd, vecStridesBkwd;
  164. vecStridesFwd = vidupq_u32((uint32_t)0, 2);
  165. vecStridesBkwd = -vecStridesFwd;
  166. int blockCnt;
  167. k = (S->Sint).fftLen - 1;
  168. xAR = pA[0];
  169. xAI = pA[1];
  170. pCoeff += 2 ;
  171. *pOut++ = 0.5f * ( xAR + xAI );
  172. *pOut++ = 0.5f * ( xAR - xAI );
  173. pB = p + 2*k ;
  174. pA += 2 ;
  175. blockCnt = k >> 2;
  176. while (blockCnt > 0)
  177. {
  178. /* G is half of the frequency complex spectrum */
  179. //for k = 2:N
  180. // Xk(k) = 1/2 * (G(k) + conj(G(N-k+2)) + Tw(k)*( G(k) - conj(G(N-k+2))));
  181. xA = vld2q_f32(pA);
  182. pA += 8;
  183. xB = vld2q_f32(pB);
  184. xB.val[0] = vldrwq_gather_shifted_offset_f32(pB, vecStridesBkwd);
  185. xB.val[1] = vldrwq_gather_shifted_offset_f32(&pB[1], vecStridesBkwd);
  186. xB.val[1] = vnegq_f32(xB.val[1]);
  187. pB -= 8;
  188. tw = vld2q_f32(pCoeff);
  189. tw.val[1] = vnegq_f32(tw.val[1]);
  190. pCoeff += 8;
  191. tmp1.val[0] = vaddq_f32(xA.val[0],xB.val[0]);
  192. tmp1.val[1] = vaddq_f32(xA.val[1],xB.val[1]);
  193. tmp2.val[0] = vsubq_f32(xB.val[0],xA.val[0]);
  194. tmp2.val[1] = vsubq_f32(xB.val[1],xA.val[1]);
  195. res.val[0] = vmulq(tw.val[0], tmp2.val[0]);
  196. res.val[0] = vfmsq(res.val[0],tw.val[1], tmp2.val[1]);
  197. res.val[1] = vmulq(tw.val[0], tmp2.val[1]);
  198. res.val[1] = vfmaq(res.val[1], tw.val[1], tmp2.val[0]);
  199. res.val[0] = vaddq_f32(res.val[0],tmp1.val[0] );
  200. res.val[1] = vaddq_f32(res.val[1],tmp1.val[1] );
  201. res.val[0] = vmulq_n_f32(res.val[0], 0.5f);
  202. res.val[1] = vmulq_n_f32(res.val[1], 0.5f);
  203. vst2q_f32(pOut, res);
  204. pOut += 8;
  205. blockCnt--;
  206. }
  207. blockCnt = k & 3;
  208. while (blockCnt > 0)
  209. {
  210. /* G is half of the frequency complex spectrum */
  211. //for k = 2:N
  212. // Xk(k) = 1/2 * (G(k) + conj(G(N-k+2)) + Tw(k)*( G(k) - conj(G(N-k+2))));
  213. xBI = pB[1] ;
  214. xBR = pB[0] ;
  215. xAR = pA[0];
  216. xAI = pA[1];
  217. twR = *pCoeff++;
  218. twI = *pCoeff++;
  219. t1a = xAR - xBR ;
  220. t1b = xAI + xBI ;
  221. r = twR * t1a;
  222. s = twI * t1b;
  223. t = twI * t1a;
  224. u = twR * t1b;
  225. // real(tw * (xA - xB)) = twR * (xAR - xBR) - twI * (xAI - xBI);
  226. // imag(tw * (xA - xB)) = twI * (xAR - xBR) + twR * (xAI - xBI);
  227. *pOut++ = 0.5f * (xAR + xBR - r - s ); //xAR
  228. *pOut++ = 0.5f * (xAI - xBI + t - u ); //xAI
  229. pA += 2;
  230. pB -= 2;
  231. blockCnt--;
  232. }
  233. }
  234. #else
  235. void stage_rfft_f32(
  236. const arm_rfft_fast_instance_f32 * S,
  237. float32_t * p,
  238. float32_t * pOut)
  239. {
  240. int32_t k; /* Loop Counter */
  241. float32_t twR, twI; /* RFFT Twiddle coefficients */
  242. const float32_t * pCoeff = S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */
  243. float32_t *pA = p; /* increasing pointer */
  244. float32_t *pB = p; /* decreasing pointer */
  245. float32_t xAR, xAI, xBR, xBI; /* temporary variables */
  246. float32_t t1a, t1b; /* temporary variables */
  247. float32_t p0, p1, p2, p3; /* temporary variables */
  248. k = (S->Sint).fftLen - 1;
  249. /* Pack first and last sample of the frequency domain together */
  250. xBR = pB[0];
  251. xBI = pB[1];
  252. xAR = pA[0];
  253. xAI = pA[1];
  254. twR = *pCoeff++ ;
  255. twI = *pCoeff++ ;
  256. // U1 = XA(1) + XB(1); % It is real
  257. t1a = xBR + xAR ;
  258. // U2 = XB(1) - XA(1); % It is imaginary
  259. t1b = xBI + xAI ;
  260. // real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI);
  261. // imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI);
  262. *pOut++ = 0.5f * ( t1a + t1b );
  263. *pOut++ = 0.5f * ( t1a - t1b );
  264. // XA(1) = 1/2*( U1 - imag(U2) + i*( U1 +imag(U2) ));
  265. pB = p + 2*k;
  266. pA += 2;
  267. do
  268. {
  269. /*
  270. function X = my_split_rfft(X, ifftFlag)
  271. % X is a series of real numbers
  272. L = length(X);
  273. XC = X(1:2:end) +i*X(2:2:end);
  274. XA = fft(XC);
  275. XB = conj(XA([1 end:-1:2]));
  276. TW = i*exp(-2*pi*i*[0:L/2-1]/L).';
  277. for l = 2:L/2
  278. XA(l) = 1/2 * (XA(l) + XB(l) + TW(l) * (XB(l) - XA(l)));
  279. end
  280. XA(1) = 1/2* (XA(1) + XB(1) + TW(1) * (XB(1) - XA(1))) + i*( 1/2*( XA(1) + XB(1) + i*( XA(1) - XB(1))));
  281. X = XA;
  282. */
  283. xBI = pB[1];
  284. xBR = pB[0];
  285. xAR = pA[0];
  286. xAI = pA[1];
  287. twR = *pCoeff++;
  288. twI = *pCoeff++;
  289. t1a = xBR - xAR ;
  290. t1b = xBI + xAI ;
  291. // real(tw * (xB - xA)) = twR * (xBR - xAR) - twI * (xBI - xAI);
  292. // imag(tw * (xB - xA)) = twI * (xBR - xAR) + twR * (xBI - xAI);
  293. p0 = twR * t1a;
  294. p1 = twI * t1a;
  295. p2 = twR * t1b;
  296. p3 = twI * t1b;
  297. *pOut++ = 0.5f * (xAR + xBR + p0 + p3 ); //xAR
  298. *pOut++ = 0.5f * (xAI - xBI + p1 - p2 ); //xAI
  299. pA += 2;
  300. pB -= 2;
  301. k--;
  302. } while (k > 0);
  303. }
  304. /* Prepares data for inverse cfft */
  305. void merge_rfft_f32(
  306. const arm_rfft_fast_instance_f32 * S,
  307. float32_t * p,
  308. float32_t * pOut)
  309. {
  310. int32_t k; /* Loop Counter */
  311. float32_t twR, twI; /* RFFT Twiddle coefficients */
  312. const float32_t *pCoeff = S->pTwiddleRFFT; /* Points to RFFT Twiddle factors */
  313. float32_t *pA = p; /* increasing pointer */
  314. float32_t *pB = p; /* decreasing pointer */
  315. float32_t xAR, xAI, xBR, xBI; /* temporary variables */
  316. float32_t t1a, t1b, r, s, t, u; /* temporary variables */
  317. k = (S->Sint).fftLen - 1;
  318. xAR = pA[0];
  319. xAI = pA[1];
  320. pCoeff += 2 ;
  321. *pOut++ = 0.5f * ( xAR + xAI );
  322. *pOut++ = 0.5f * ( xAR - xAI );
  323. pB = p + 2*k ;
  324. pA += 2 ;
  325. while (k > 0)
  326. {
  327. /* G is half of the frequency complex spectrum */
  328. //for k = 2:N
  329. // Xk(k) = 1/2 * (G(k) + conj(G(N-k+2)) + Tw(k)*( G(k) - conj(G(N-k+2))));
  330. xBI = pB[1] ;
  331. xBR = pB[0] ;
  332. xAR = pA[0];
  333. xAI = pA[1];
  334. twR = *pCoeff++;
  335. twI = *pCoeff++;
  336. t1a = xAR - xBR ;
  337. t1b = xAI + xBI ;
  338. r = twR * t1a;
  339. s = twI * t1b;
  340. t = twI * t1a;
  341. u = twR * t1b;
  342. // real(tw * (xA - xB)) = twR * (xAR - xBR) - twI * (xAI - xBI);
  343. // imag(tw * (xA - xB)) = twI * (xAR - xBR) + twR * (xAI - xBI);
  344. *pOut++ = 0.5f * (xAR + xBR - r - s ); //xAR
  345. *pOut++ = 0.5f * (xAI - xBI + t - u ); //xAI
  346. pA += 2;
  347. pB -= 2;
  348. k--;
  349. }
  350. }
  351. #endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */
  352. /**
  353. @ingroup groupTransforms
  354. */
  355. /**
  356. @defgroup RealFFT Real FFT Functions
  357. @par
  358. The CMSIS DSP library includes specialized algorithms for computing the
  359. FFT of real data sequences. The FFT is defined over complex data but
  360. in many applications the input is real. Real FFT algorithms take advantage
  361. of the symmetry properties of the FFT and have a speed advantage over complex
  362. algorithms of the same length.
  363. @par
  364. The Fast RFFT algorithm relays on the mixed radix CFFT that save processor usage.
  365. @par
  366. The real length N forward FFT of a sequence is computed using the steps shown below.
  367. @par
  368. \image html RFFT.gif "Real Fast Fourier Transform"
  369. @par
  370. The real sequence is initially treated as if it were complex to perform a CFFT.
  371. Later, a processing stage reshapes the data to obtain half of the frequency spectrum
  372. in complex format.
  373. @par
  374. The input for the inverse RFFT should keep the same format as the output of the
  375. forward RFFT. A first processing stage pre-process the data to later perform an
  376. inverse CFFT.
  377. @par
  378. \image html RIFFT.gif "Real Inverse Fast Fourier Transform"
  379. @par
  380. The algorithms for floating-point, Q15, and Q31 data are slightly different
  381. and we describe each algorithm in turn.
  382. @par Floating-point
  383. The main functions are \ref arm_rfft_fast_f32() and \ref arm_rfft_fast_init_f32().
  384. The older functions \ref arm_rfft_f32() and \ref arm_rfft_init_f32() have been deprecated
  385. but are still documented.
  386. For f16, the functions are \ref arm_rfft_fast_f16() and \ref arm_rfft_fast_init_f16().
  387. For f64, the functions are \ref arm_rfft_fast_f64() and \ref arm_rfft_fast_init_f64().
  388. @par
  389. The FFT of a real N-point sequence has even symmetry in the frequency domain.
  390. The second half of the data equals the conjugate of the first half flipped in frequency.
  391. This conjugate part is not computed by the float RFFT. As consequence, the output of
  392. a N point real FFT should be a N//2 + 1 complex numbers so N + 2 floats.
  393. @par
  394. It happens that the first complex of number of the RFFT output is actually
  395. all real. Its real part represents the DC offset.
  396. The value at Nyquist frequency is also real.
  397. @par
  398. Those two complex numbers can be encoded with 2 floats rather than using two numbers
  399. with an imaginary part set to zero.
  400. @par
  401. The implementation is using a trick so that the output buffer can be N float :
  402. the last real is packaged in the imaginary part of the first complex (since
  403. this imaginary part is not used and is zero).
  404. @par
  405. The real FFT functions pack the frequency domain data in this fashion.
  406. The forward transform outputs the data in this form and the inverse
  407. transform expects input data in this form. The function always performs
  408. the needed bitreversal so that the input and output data is always in
  409. normal order. The functions support lengths of [32, 64, 128, ..., 4096]
  410. samples.
  411. @par Q15 and Q31
  412. The real algorithms are defined in a similar manner and utilize N/2 complex
  413. transforms behind the scenes.
  414. @par
  415. But warning, contrary to the float version, the fixed point implementation
  416. RFFT is also computing the conjugate part (except for MVE version) so the
  417. output buffer must be bigger.
  418. Also the fixed point RFFTs are not using any trick to pack the DC and Nyquist
  419. frequency in the same complex number.
  420. The RIFFT is not using the conjugate part but it is still using the Nyquist
  421. frequency value. The details are given in the documentation for the functions.
  422. @par
  423. The complex transforms used internally include scaling to prevent fixed-point
  424. overflows. The overall scaling equals 1/(fftLen/2).
  425. Due to the use of complex transform internally, the source buffer is
  426. modified by the rfft.
  427. @par
  428. A separate instance structure must be defined for each transform used but
  429. twiddle factor and bit reversal tables can be reused.
  430. @par
  431. There is also an associated initialization function for each data type.
  432. The initialization function performs the following operations:
  433. - Sets the values of the internal structure fields.
  434. - Initializes twiddle factor table and bit reversal table pointers.
  435. - Initializes the internal complex FFT data structure.
  436. @par
  437. Use of the initialization function is optional **except for MVE versions where it is mandatory**.
  438. If you don't use the initialization functions, then the structures should be initialized with code
  439. similar to the one below:
  440. <pre>
  441. arm_rfft_instance_q31 S = {fftLenReal, fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal, pCfft};
  442. arm_rfft_instance_q15 S = {fftLenReal, fftLenBy2, ifftFlagR, bitReverseFlagR, twidCoefRModifier, pTwiddleAReal, pTwiddleBReal, pCfft};
  443. </pre>
  444. where <code>fftLenReal</code> is the length of the real transform;
  445. <code>fftLenBy2</code> length of the internal complex transform (fftLenReal/2).
  446. <code>ifftFlagR</code> Selects forward (=0) or inverse (=1) transform.
  447. <code>bitReverseFlagR</code> Selects bit reversed output (=0) or normal order
  448. output (=1).
  449. <code>twidCoefRModifier</code> stride modifier for the twiddle factor table.
  450. The value is based on the FFT length;
  451. <code>pTwiddleAReal</code>points to the A array of twiddle coefficients;
  452. <code>pTwiddleBReal</code>points to the B array of twiddle coefficients;
  453. <code>pCfft</code> points to the CFFT Instance structure. The CFFT structure
  454. must also be initialized.
  455. @par
  456. Note that with MVE versions you can't initialize instance structures directly and **must
  457. use the initialization function**.
  458. */
  459. /**
  460. @defgroup DeprecatedRealFFT Deprecated Real FFT Functions
  461. */
  462. /**
  463. @defgroup RealFFTF32 Real FFT F32 Functions
  464. */
  465. /**
  466. @addtogroup RealFFTF32
  467. @{
  468. */
  469. /**
  470. @brief Processing function for the floating-point real FFT.
  471. @param[in] S points to an arm_rfft_fast_instance_f32 structure
  472. @param[in] p points to input buffer (Source buffer is modified by this function.)
  473. @param[in] pOut points to output buffer
  474. @param[in] ifftFlag
  475. - value = 0: RFFT
  476. - value = 1: RIFFT
  477. */
  478. void arm_rfft_fast_f32(
  479. const arm_rfft_fast_instance_f32 * S,
  480. float32_t * p,
  481. float32_t * pOut,
  482. uint8_t ifftFlag)
  483. {
  484. const arm_cfft_instance_f32 * Sint = &(S->Sint);
  485. /* Calculation of Real FFT */
  486. if (ifftFlag)
  487. {
  488. /* Real FFT compression */
  489. merge_rfft_f32(S, p, pOut);
  490. /* Complex radix-4 IFFT process */
  491. arm_cfft_f32( Sint, pOut, ifftFlag, 1);
  492. }
  493. else
  494. {
  495. /* Calculation of RFFT of input */
  496. arm_cfft_f32( Sint, p, ifftFlag, 1);
  497. /* Real FFT extraction */
  498. stage_rfft_f32(S, p, pOut);
  499. }
  500. }
  501. /**
  502. * @} end of RRealFFTF16ealFFT group
  503. */