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 RealFFT
34 */
35
36 /**
37 @addtogroup RealFFTF64
38 @{
39 */
40
41
42 /**
43 @brief Initialization function for the 32pt double precision floating-point real FFT.
44 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
45 @return execution status
46 - \ref ARM_MATH_SUCCESS : Operation successful
47 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
48 */
49
arm_rfft_fast_init_32_f64(arm_rfft_fast_instance_f64 * S)50 arm_status arm_rfft_fast_init_32_f64( arm_rfft_fast_instance_f64 * S ) {
51
52 arm_cfft_instance_f64 * Sint;
53
54 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
55
56 Sint = &(S->Sint);
57 Sint->fftLen = 16U;
58 S->fftLenRFFT = 32U;
59
60 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_16_TABLE_LENGTH;
61 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_16;
62 Sint->pTwiddle = (float64_t *) twiddleCoefF64_16;
63 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_32;
64
65 return ARM_MATH_SUCCESS;
66 }
67
68
69 /**
70 @brief Initialization function for the 64pt Double Precision floating-point real FFT.
71 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
72 @return execution status
73 - \ref ARM_MATH_SUCCESS : Operation successful
74 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
75 */
76
arm_rfft_fast_init_64_f64(arm_rfft_fast_instance_f64 * S)77 arm_status arm_rfft_fast_init_64_f64( arm_rfft_fast_instance_f64 * S ) {
78
79 arm_cfft_instance_f64 * Sint;
80
81 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
82
83 Sint = &(S->Sint);
84 Sint->fftLen = 32U;
85 S->fftLenRFFT = 64U;
86
87 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_32_TABLE_LENGTH;
88 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_32;
89 Sint->pTwiddle = (float64_t *) twiddleCoefF64_32;
90 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_64;
91
92 return ARM_MATH_SUCCESS;
93 }
94
95
96 /**
97 @brief Initialization function for the 128pt Double Precision floating-point real FFT.
98 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
99 @return execution status
100 - \ref ARM_MATH_SUCCESS : Operation successful
101 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
102 */
103
arm_rfft_fast_init_128_f64(arm_rfft_fast_instance_f64 * S)104 arm_status arm_rfft_fast_init_128_f64( arm_rfft_fast_instance_f64 * S ) {
105
106 arm_cfft_instance_f64 * Sint;
107
108 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
109
110 Sint = &(S->Sint);
111 Sint->fftLen = 64U;
112 S->fftLenRFFT = 128U;
113
114 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_64_TABLE_LENGTH;
115 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_64;
116 Sint->pTwiddle = (float64_t *) twiddleCoefF64_64;
117 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_128;
118
119 return ARM_MATH_SUCCESS;
120 }
121
122
123 /**
124 @brief Initialization function for the 256pt Double Precision floating-point real FFT.
125 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
126 @return execution status
127 - \ref ARM_MATH_SUCCESS : Operation successful
128 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
129 */
130
arm_rfft_fast_init_256_f64(arm_rfft_fast_instance_f64 * S)131 arm_status arm_rfft_fast_init_256_f64( arm_rfft_fast_instance_f64 * S ) {
132
133 arm_cfft_instance_f64 * Sint;
134
135 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
136
137 Sint = &(S->Sint);
138 Sint->fftLen = 128U;
139 S->fftLenRFFT = 256U;
140
141 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_128_TABLE_LENGTH;
142 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_128;
143 Sint->pTwiddle = (float64_t *) twiddleCoefF64_128;
144 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_256;
145
146 return ARM_MATH_SUCCESS;
147 }
148
149
150 /**
151 @brief Initialization function for the 512pt Double Precision floating-point real FFT.
152 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
153 @return execution status
154 - \ref ARM_MATH_SUCCESS : Operation successful
155 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
156 */
157
arm_rfft_fast_init_512_f64(arm_rfft_fast_instance_f64 * S)158 arm_status arm_rfft_fast_init_512_f64( arm_rfft_fast_instance_f64 * S ) {
159
160 arm_cfft_instance_f64 * Sint;
161
162 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
163
164 Sint = &(S->Sint);
165 Sint->fftLen = 256U;
166 S->fftLenRFFT = 512U;
167
168 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_256_TABLE_LENGTH;
169 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_256;
170 Sint->pTwiddle = (float64_t *) twiddleCoefF64_256;
171 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_512;
172
173 return ARM_MATH_SUCCESS;
174 }
175
176 /**
177 @brief Initialization function for the 1024pt Double Precision floating-point real FFT.
178 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
179 @return execution status
180 - \ref ARM_MATH_SUCCESS : Operation successful
181 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
182 */
183
arm_rfft_fast_init_1024_f64(arm_rfft_fast_instance_f64 * S)184 arm_status arm_rfft_fast_init_1024_f64( arm_rfft_fast_instance_f64 * S ) {
185
186 arm_cfft_instance_f64 * Sint;
187
188 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
189
190 Sint = &(S->Sint);
191 Sint->fftLen = 512U;
192 S->fftLenRFFT = 1024U;
193
194 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_512_TABLE_LENGTH;
195 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_512;
196 Sint->pTwiddle = (float64_t *) twiddleCoefF64_512;
197 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_1024;
198
199 return ARM_MATH_SUCCESS;
200 }
201
202 /**
203 @brief Initialization function for the 2048pt Double Precision floating-point real FFT.
204 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
205 @return execution status
206 - \ref ARM_MATH_SUCCESS : Operation successful
207 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
208 */
arm_rfft_fast_init_2048_f64(arm_rfft_fast_instance_f64 * S)209 arm_status arm_rfft_fast_init_2048_f64( arm_rfft_fast_instance_f64 * S ) {
210
211 arm_cfft_instance_f64 * Sint;
212
213 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
214
215 Sint = &(S->Sint);
216 Sint->fftLen = 1024U;
217 S->fftLenRFFT = 2048U;
218
219 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_1024_TABLE_LENGTH;
220 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_1024;
221 Sint->pTwiddle = (float64_t *) twiddleCoefF64_1024;
222 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_2048;
223
224 return ARM_MATH_SUCCESS;
225 }
226
227 /**
228 * @brief Initialization function for the 4096pt Double Precision floating-point real FFT.
229 * @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
230 @return execution status
231 - \ref ARM_MATH_SUCCESS : Operation successful
232 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
233 */
234
arm_rfft_fast_init_4096_f64(arm_rfft_fast_instance_f64 * S)235 arm_status arm_rfft_fast_init_4096_f64( arm_rfft_fast_instance_f64 * S ) {
236
237 arm_cfft_instance_f64 * Sint;
238
239 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
240
241 Sint = &(S->Sint);
242 Sint->fftLen = 2048U;
243 S->fftLenRFFT = 4096U;
244
245 Sint->bitRevLength = ARMBITREVINDEXTABLEF64_2048_TABLE_LENGTH;
246 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTableF64_2048;
247 Sint->pTwiddle = (float64_t *) twiddleCoefF64_2048;
248 S->pTwiddleRFFT = (float64_t *) twiddleCoefF64_rfft_4096;
249
250 return ARM_MATH_SUCCESS;
251 }
252
253 /**
254 @brief Generic initialization function for the Double Precision floating-point real FFT.
255 @param[in,out] S points to an arm_rfft_fast_instance_f64 structure
256 @param[in] fftLen length of the Real Sequence
257 @return execution status
258 - \ref ARM_MATH_SUCCESS : Operation successful
259 - \ref ARM_MATH_ARGUMENT_ERROR : <code>fftLen</code> is not a supported length
260
261 @par Description
262 The parameter <code>fftLen</code> specifies the length of RFFT/CIFFT process.
263 Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096.
264 @par
265 This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
266
267 @par
268 This function should be used only if you don't know the FFT sizes that
269 you'll need at build time. The use of this function will prevent the
270 linker from removing the FFT tables that are not needed and the library
271 code size will be bigger than needed.
272
273 @par
274 If you use CMSIS-DSP as a library, and if you know the FFT sizes
275 that you need at build time, then it is better to use the initialization
276 functions defined for each FFT size.
277
278 */
279
arm_rfft_fast_init_f64(arm_rfft_fast_instance_f64 * S,uint16_t fftLen)280 arm_status arm_rfft_fast_init_f64(
281 arm_rfft_fast_instance_f64 * S,
282 uint16_t fftLen)
283 {
284 arm_status status;
285
286
287 switch (fftLen)
288 {
289 case 4096U:
290 status = arm_rfft_fast_init_4096_f64(S);
291 break;
292 case 2048U:
293 status = arm_rfft_fast_init_2048_f64(S);
294 break;
295 case 1024U:
296 status = arm_rfft_fast_init_1024_f64(S);
297 break;
298 case 512U:
299 status = arm_rfft_fast_init_512_f64(S);
300 break;
301 case 256U:
302 status = arm_rfft_fast_init_256_f64(S);
303 break;
304 case 128U:
305 status = arm_rfft_fast_init_128_f64(S);
306 break;
307 case 64U:
308 status = arm_rfft_fast_init_64_f64(S);
309 break;
310 case 32U:
311 status = arm_rfft_fast_init_32_f64(S);
312 break;
313 default:
314 return(ARM_MATH_ARGUMENT_ERROR);
315 break;
316 }
317
318 return(status);
319
320 }
321
322 /**
323 @} end of RealFFTF64 group
324 */
325