arm_rfft_fast_init_f64.c 10.0 KB

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