1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_rfft_fast_init_f64.c
4 * Description: Split Radix Decimation in Frequency CFFT Double Precision Floating point processing 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
29 #include "dsp/transform_functions.h"
30 #include "arm_common_tables.h"
31
32 /**
33 @ingroup groupTransforms
34 */
35
36 /**
37 @addtogroup RealFFT
38 @{
39 */
40
41 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_16) && defined(ARM_TABLE_BITREVIDX_FLT64_16) && defined(ARM_TABLE_TWIDDLECOEF_F64_16) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_32))
42
43 /**
44 @brief Initialization function for the 32pt double precision floating-point real FFT.
45 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
46 @return execution status
47 - \ref ARM_MATH_SUCCESS : Operation successful
48 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
49 */
50
arm_rfft_32_fast_init_f64(arm_rfft_fast_instance_f64 * S)51 static arm_status arm_rfft_32_fast_init_f64( arm_rfft_fast_instance_f64 * S ) {
52
53 arm_cfft_instance_f64 * Sint;
54
55 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
56
57 Sint = &(S->Sint);
58 Sint->fftLen = 16U;
59 S->fftLenRFFT = 32U;
60
61 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_16_TABLE_LENGTH;
62 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_16;
63 Sint->pTwiddle = (float64_t *) twiddleCoefF64_16;
64 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_32;
65
66 return ARM_MATH_SUCCESS;
67 }
68 #endif
69
70 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_32) && defined(ARM_TABLE_BITREVIDX_FLT64_32) && defined(ARM_TABLE_TWIDDLECOEF_F64_32) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_64))
71
72 /**
73 @brief Initialization function for the 64pt Double Precision floating-point real FFT.
74 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
75 @return execution status
76 - \ref ARM_MATH_SUCCESS : Operation successful
77 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
78 */
79
arm_rfft_64_fast_init_f64(arm_rfft_fast_instance_f64 * S)80 static arm_status arm_rfft_64_fast_init_f64( arm_rfft_fast_instance_f64 * S ) {
81
82 arm_cfft_instance_f64 * Sint;
83
84 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
85
86 Sint = &(S->Sint);
87 Sint->fftLen = 32U;
88 S->fftLenRFFT = 64U;
89
90 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_32_TABLE_LENGTH;
91 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_32;
92 Sint->pTwiddle = (float64_t *) twiddleCoefF64_32;
93 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_64;
94
95 return ARM_MATH_SUCCESS;
96 }
97 #endif
98
99 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_64) && defined(ARM_TABLE_BITREVIDX_FLT64_64) && defined(ARM_TABLE_TWIDDLECOEF_F64_64) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_128))
100
101 /**
102 @brief Initialization function for the 128pt Double Precision floating-point real FFT.
103 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
104 @return execution status
105 - \ref ARM_MATH_SUCCESS : Operation successful
106 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
107 */
108
arm_rfft_128_fast_init_f64(arm_rfft_fast_instance_f64 * S)109 static arm_status arm_rfft_128_fast_init_f64( arm_rfft_fast_instance_f64 * S ) {
110
111 arm_cfft_instance_f64 * Sint;
112
113 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
114
115 Sint = &(S->Sint);
116 Sint->fftLen = 64U;
117 S->fftLenRFFT = 128U;
118
119 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_64_TABLE_LENGTH;
120 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_64;
121 Sint->pTwiddle = (float64_t *) twiddleCoefF64_64;
122 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_128;
123
124 return ARM_MATH_SUCCESS;
125 }
126 #endif
127
128 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_128) && defined(ARM_TABLE_BITREVIDX_FLT64_128) && defined(ARM_TABLE_TWIDDLECOEF_F64_128) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_256))
129
130 /**
131 @brief Initialization function for the 256pt Double Precision floating-point real FFT.
132 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
133 @return execution status
134 - \ref ARM_MATH_SUCCESS : Operation successful
135 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
136 */
137
arm_rfft_256_fast_init_f64(arm_rfft_fast_instance_f64 * S)138 static arm_status arm_rfft_256_fast_init_f64( arm_rfft_fast_instance_f64 * S ) {
139
140 arm_cfft_instance_f64 * Sint;
141
142 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
143
144 Sint = &(S->Sint);
145 Sint->fftLen = 128U;
146 S->fftLenRFFT = 256U;
147
148 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_128_TABLE_LENGTH;
149 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_128;
150 Sint->pTwiddle = (float64_t *) twiddleCoefF64_128;
151 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_256;
152
153 return ARM_MATH_SUCCESS;
154 }
155 #endif
156
157 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_256) && defined(ARM_TABLE_BITREVIDX_FLT64_256) && defined(ARM_TABLE_TWIDDLECOEF_F64_256) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_512))
158
159 /**
160 @brief Initialization function for the 512pt Double Precision floating-point real FFT.
161 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
162 @return execution status
163 - \ref ARM_MATH_SUCCESS : Operation successful
164 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
165 */
166
arm_rfft_512_fast_init_f64(arm_rfft_fast_instance_f64 * S)167 static arm_status arm_rfft_512_fast_init_f64( arm_rfft_fast_instance_f64 * S ) {
168
169 arm_cfft_instance_f64 * Sint;
170
171 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
172
173 Sint = &(S->Sint);
174 Sint->fftLen = 256U;
175 S->fftLenRFFT = 512U;
176
177 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_256_TABLE_LENGTH;
178 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_256;
179 Sint->pTwiddle = (float64_t *) twiddleCoefF64_256;
180 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_512;
181
182 return ARM_MATH_SUCCESS;
183 }
184 #endif
185
186 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_512) && defined(ARM_TABLE_BITREVIDX_FLT64_512) && defined(ARM_TABLE_TWIDDLECOEF_F64_512) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_1024))
187 /**
188 @brief Initialization function for the 1024pt Double Precision floating-point real FFT.
189 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
190 @return execution status
191 - \ref ARM_MATH_SUCCESS : Operation successful
192 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
193 */
194
arm_rfft_1024_fast_init_f64(arm_rfft_fast_instance_f64 * S)195 static arm_status arm_rfft_1024_fast_init_f64( arm_rfft_fast_instance_f64 * S ) {
196
197 arm_cfft_instance_f64 * Sint;
198
199 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
200
201 Sint = &(S->Sint);
202 Sint->fftLen = 512U;
203 S->fftLenRFFT = 1024U;
204
205 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_512_TABLE_LENGTH;
206 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_512;
207 Sint->pTwiddle = (float64_t *) twiddleCoefF64_512;
208 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_1024;
209
210 return ARM_MATH_SUCCESS;
211 }
212 #endif
213
214 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_1024) && defined(ARM_TABLE_BITREVIDX_FLT64_1024) && defined(ARM_TABLE_TWIDDLECOEF_F64_1024) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_2048))
215 /**
216 @brief Initialization function for the 2048pt Double Precision floating-point real FFT.
217 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
218 @return execution status
219 - \ref ARM_MATH_SUCCESS : Operation successful
220 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
221 */
arm_rfft_2048_fast_init_f64(arm_rfft_fast_instance_f64 * S)222 static arm_status arm_rfft_2048_fast_init_f64( arm_rfft_fast_instance_f64 * S ) {
223
224 arm_cfft_instance_f64 * Sint;
225
226 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
227
228 Sint = &(S->Sint);
229 Sint->fftLen = 1024U;
230 S->fftLenRFFT = 2048U;
231
232 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_1024_TABLE_LENGTH;
233 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_1024;
234 Sint->pTwiddle = (float64_t *) twiddleCoefF64_1024;
235 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_2048;
236
237 return ARM_MATH_SUCCESS;
238 }
239 #endif
240
241 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_2048) && defined(ARM_TABLE_BITREVIDX_FLT64_2048) && defined(ARM_TABLE_TWIDDLECOEF_F64_2048) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_4096))
242 /**
243 * @brief Initialization function for the 4096pt Double Precision floating-point real FFT.
244 * @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
245 @return execution status
246 - \ref ARM_MATH_SUCCESS : Operation successful
247 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
248 */
249
arm_rfft_4096_fast_init_f64(arm_rfft_fast_instance_f64 * S)250 static arm_status arm_rfft_4096_fast_init_f64( arm_rfft_fast_instance_f64 * S ) {
251
252 arm_cfft_instance_f64 * Sint;
253
254 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
255
256 Sint = &(S->Sint);
257 Sint->fftLen = 2048U;
258 S->fftLenRFFT = 4096U;
259
260 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_2048_TABLE_LENGTH;
261 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_2048;
262 Sint->pTwiddle = (float64_t *) twiddleCoefF64_2048;
263 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_4096;
264
265 return ARM_MATH_SUCCESS;
266 }
267 #endif
268
269 /**
270 @brief Initialization function for the Double Precision floating-point real FFT.
271 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
272 @param[in] fftLen length of the Real Sequence
273 @return execution status
274 - \ref ARM_MATH_SUCCESS : Operation successful
275 - \ref ARM_MATH_ARGUMENT_ERROR : <code>fftLen</code> is not a supported length
276
277 @par Description
278 The parameter <code>fftLen</code> specifies the length of RFFT/CIFFT process.
279 Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096.
280 @par
281 This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
282 */
283
arm_rfft_fast_init_f64(arm_rfft_fast_instance_f64 * S,uint16_t fftLen)284 arm_status arm_rfft_fast_init_f64(
285 arm_rfft_fast_instance_f64 * S,
286 uint16_t fftLen)
287 {
288 typedef arm_status(*fft_init_ptr)( arm_rfft_fast_instance_f64 *);
289 fft_init_ptr fptr = 0x0;
290
291 switch (fftLen)
292 {
293 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_2048) && defined(ARM_TABLE_BITREVIDX_FLT64_2048) && defined(ARM_TABLE_TWIDDLECOEF_F64_2048) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_4096))
294 case 4096U:
295 fptr = arm_rfft_4096_fast_init_f64;
296 break;
297 #endif
298 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_1024) && defined(ARM_TABLE_BITREVIDX_FLT64_1024) && defined(ARM_TABLE_TWIDDLECOEF_F64_1024) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_2048))
299 case 2048U:
300 fptr = arm_rfft_2048_fast_init_f64;
301 break;
302 #endif
303 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_512) && defined(ARM_TABLE_BITREVIDX_FLT64_512) && defined(ARM_TABLE_TWIDDLECOEF_F64_512) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_1024))
304 case 1024U:
305 fptr = arm_rfft_1024_fast_init_f64;
306 break;
307 #endif
308 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_256) && defined(ARM_TABLE_BITREVIDX_FLT64_256) && defined(ARM_TABLE_TWIDDLECOEF_F64_256) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_512))
309 case 512U:
310 fptr = arm_rfft_512_fast_init_f64;
311 break;
312 #endif
313 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_128) && defined(ARM_TABLE_BITREVIDX_FLT64_128) && defined(ARM_TABLE_TWIDDLECOEF_F64_128) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_256))
314 case 256U:
315 fptr = arm_rfft_256_fast_init_f64;
316 break;
317 #endif
318 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_64) && defined(ARM_TABLE_BITREVIDX_FLT64_64) && defined(ARM_TABLE_TWIDDLECOEF_F64_64) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_128))
319 case 128U:
320 fptr = arm_rfft_128_fast_init_f64;
321 break;
322 #endif
323 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_32) && defined(ARM_TABLE_BITREVIDX_FLT64_32) && defined(ARM_TABLE_TWIDDLECOEF_F64_32) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_64))
324 case 64U:
325 fptr = arm_rfft_64_fast_init_f64;
326 break;
327 #endif
328 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F64_16) && defined(ARM_TABLE_BITREVIDX_FLT64_16) && defined(ARM_TABLE_TWIDDLECOEF_F64_16) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_32))
329 case 32U:
330 fptr = arm_rfft_32_fast_init_f64;
331 break;
332 #endif
333 default:
334 return ARM_MATH_ARGUMENT_ERROR;
335 }
336
337 if( ! fptr ) return ARM_MATH_ARGUMENT_ERROR;
338 return fptr( S );
339
340 }
341
342 /**
343 @} end of RealFFT group
344 */
345