complex_math_functions.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. /******************************************************************************
  2. * @file complex_math_functions.h
  3. * @brief Public header file for CMSIS DSP Library
  4. * @version V1.10.0
  5. * @date 08 July 2021
  6. * Target Processor: Cortex-M and Cortex-A cores
  7. ******************************************************************************/
  8. /*
  9. * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved.
  10. *
  11. * SPDX-License-Identifier: Apache-2.0
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the License); you may
  14. * not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  21. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. */
  25. #ifndef _COMPLEX_MATH_FUNCTIONS_H_
  26. #define _COMPLEX_MATH_FUNCTIONS_H_
  27. #include "arm_math_types.h"
  28. #include "arm_math_memory.h"
  29. #include "dsp/none.h"
  30. #include "dsp/utils.h"
  31. #include "dsp/fast_math_functions.h"
  32. #ifdef __cplusplus
  33. extern "C"
  34. {
  35. #endif
  36. /**
  37. * @defgroup groupCmplxMath Complex Math Functions
  38. * This set of functions operates on complex data vectors.
  39. * The data in the complex arrays is stored in an interleaved fashion
  40. * (real, imag, real, imag, ...).
  41. * In the API functions, the number of samples in a complex array refers
  42. * to the number of complex values; the array contains twice this number of
  43. * real values.
  44. */
  45. /**
  46. * @brief Floating-point complex conjugate.
  47. * @param[in] pSrc points to the input vector
  48. * @param[out] pDst points to the output vector
  49. * @param[in] numSamples number of complex samples in each vector
  50. */
  51. void arm_cmplx_conj_f32(
  52. const float32_t * pSrc,
  53. float32_t * pDst,
  54. uint32_t numSamples);
  55. /**
  56. * @brief Q31 complex conjugate.
  57. * @param[in] pSrc points to the input vector
  58. * @param[out] pDst points to the output vector
  59. * @param[in] numSamples number of complex samples in each vector
  60. */
  61. void arm_cmplx_conj_q31(
  62. const q31_t * pSrc,
  63. q31_t * pDst,
  64. uint32_t numSamples);
  65. /**
  66. * @brief Q15 complex conjugate.
  67. * @param[in] pSrc points to the input vector
  68. * @param[out] pDst points to the output vector
  69. * @param[in] numSamples number of complex samples in each vector
  70. */
  71. void arm_cmplx_conj_q15(
  72. const q15_t * pSrc,
  73. q15_t * pDst,
  74. uint32_t numSamples);
  75. /**
  76. * @brief Floating-point complex magnitude squared
  77. * @param[in] pSrc points to the complex input vector
  78. * @param[out] pDst points to the real output vector
  79. * @param[in] numSamples number of complex samples in the input vector
  80. */
  81. void arm_cmplx_mag_squared_f32(
  82. const float32_t * pSrc,
  83. float32_t * pDst,
  84. uint32_t numSamples);
  85. /**
  86. * @brief Floating-point complex magnitude squared
  87. * @param[in] pSrc points to the complex input vector
  88. * @param[out] pDst points to the real output vector
  89. * @param[in] numSamples number of complex samples in the input vector
  90. */
  91. void arm_cmplx_mag_squared_f64(
  92. const float64_t * pSrc,
  93. float64_t * pDst,
  94. uint32_t numSamples);
  95. /**
  96. * @brief Q31 complex magnitude squared
  97. * @param[in] pSrc points to the complex input vector
  98. * @param[out] pDst points to the real output vector
  99. * @param[in] numSamples number of complex samples in the input vector
  100. */
  101. void arm_cmplx_mag_squared_q31(
  102. const q31_t * pSrc,
  103. q31_t * pDst,
  104. uint32_t numSamples);
  105. /**
  106. * @brief Q15 complex magnitude squared
  107. * @param[in] pSrc points to the complex input vector
  108. * @param[out] pDst points to the real output vector
  109. * @param[in] numSamples number of complex samples in the input vector
  110. */
  111. void arm_cmplx_mag_squared_q15(
  112. const q15_t * pSrc,
  113. q15_t * pDst,
  114. uint32_t numSamples);
  115. /**
  116. * @brief Floating-point complex magnitude
  117. * @param[in] pSrc points to the complex input vector
  118. * @param[out] pDst points to the real output vector
  119. * @param[in] numSamples number of complex samples in the input vector
  120. */
  121. void arm_cmplx_mag_f32(
  122. const float32_t * pSrc,
  123. float32_t * pDst,
  124. uint32_t numSamples);
  125. /**
  126. * @brief Floating-point complex magnitude
  127. * @param[in] pSrc points to the complex input vector
  128. * @param[out] pDst points to the real output vector
  129. * @param[in] numSamples number of complex samples in the input vector
  130. */
  131. void arm_cmplx_mag_f64(
  132. const float64_t * pSrc,
  133. float64_t * pDst,
  134. uint32_t numSamples);
  135. /**
  136. * @brief Q31 complex magnitude
  137. * @param[in] pSrc points to the complex input vector
  138. * @param[out] pDst points to the real output vector
  139. * @param[in] numSamples number of complex samples in the input vector
  140. */
  141. void arm_cmplx_mag_q31(
  142. const q31_t * pSrc,
  143. q31_t * pDst,
  144. uint32_t numSamples);
  145. /**
  146. * @brief Q15 complex magnitude
  147. * @param[in] pSrc points to the complex input vector
  148. * @param[out] pDst points to the real output vector
  149. * @param[in] numSamples number of complex samples in the input vector
  150. */
  151. void arm_cmplx_mag_q15(
  152. const q15_t * pSrc,
  153. q15_t * pDst,
  154. uint32_t numSamples);
  155. /**
  156. * @brief Q15 complex magnitude
  157. * @param[in] pSrc points to the complex input vector
  158. * @param[out] pDst points to the real output vector
  159. * @param[in] numSamples number of complex samples in the input vector
  160. */
  161. void arm_cmplx_mag_fast_q15(
  162. const q15_t * pSrc,
  163. q15_t * pDst,
  164. uint32_t numSamples);
  165. /**
  166. * @brief Q15 complex dot product
  167. * @param[in] pSrcA points to the first input vector
  168. * @param[in] pSrcB points to the second input vector
  169. * @param[in] numSamples number of complex samples in each vector
  170. * @param[out] realResult real part of the result returned here
  171. * @param[out] imagResult imaginary part of the result returned here
  172. */
  173. void arm_cmplx_dot_prod_q15(
  174. const q15_t * pSrcA,
  175. const q15_t * pSrcB,
  176. uint32_t numSamples,
  177. q31_t * realResult,
  178. q31_t * imagResult);
  179. /**
  180. * @brief Q31 complex dot product
  181. * @param[in] pSrcA points to the first input vector
  182. * @param[in] pSrcB points to the second input vector
  183. * @param[in] numSamples number of complex samples in each vector
  184. * @param[out] realResult real part of the result returned here
  185. * @param[out] imagResult imaginary part of the result returned here
  186. */
  187. void arm_cmplx_dot_prod_q31(
  188. const q31_t * pSrcA,
  189. const q31_t * pSrcB,
  190. uint32_t numSamples,
  191. q63_t * realResult,
  192. q63_t * imagResult);
  193. /**
  194. * @brief Floating-point complex dot product
  195. * @param[in] pSrcA points to the first input vector
  196. * @param[in] pSrcB points to the second input vector
  197. * @param[in] numSamples number of complex samples in each vector
  198. * @param[out] realResult real part of the result returned here
  199. * @param[out] imagResult imaginary part of the result returned here
  200. */
  201. void arm_cmplx_dot_prod_f32(
  202. const float32_t * pSrcA,
  203. const float32_t * pSrcB,
  204. uint32_t numSamples,
  205. float32_t * realResult,
  206. float32_t * imagResult);
  207. /**
  208. * @brief Q15 complex-by-real multiplication
  209. * @param[in] pSrcCmplx points to the complex input vector
  210. * @param[in] pSrcReal points to the real input vector
  211. * @param[out] pCmplxDst points to the complex output vector
  212. * @param[in] numSamples number of samples in each vector
  213. */
  214. void arm_cmplx_mult_real_q15(
  215. const q15_t * pSrcCmplx,
  216. const q15_t * pSrcReal,
  217. q15_t * pCmplxDst,
  218. uint32_t numSamples);
  219. /**
  220. * @brief Q31 complex-by-real multiplication
  221. * @param[in] pSrcCmplx points to the complex input vector
  222. * @param[in] pSrcReal points to the real input vector
  223. * @param[out] pCmplxDst points to the complex output vector
  224. * @param[in] numSamples number of samples in each vector
  225. */
  226. void arm_cmplx_mult_real_q31(
  227. const q31_t * pSrcCmplx,
  228. const q31_t * pSrcReal,
  229. q31_t * pCmplxDst,
  230. uint32_t numSamples);
  231. /**
  232. * @brief Floating-point complex-by-real multiplication
  233. * @param[in] pSrcCmplx points to the complex input vector
  234. * @param[in] pSrcReal points to the real input vector
  235. * @param[out] pCmplxDst points to the complex output vector
  236. * @param[in] numSamples number of samples in each vector
  237. */
  238. void arm_cmplx_mult_real_f32(
  239. const float32_t * pSrcCmplx,
  240. const float32_t * pSrcReal,
  241. float32_t * pCmplxDst,
  242. uint32_t numSamples);
  243. /**
  244. * @brief Q15 complex-by-complex multiplication
  245. * @param[in] pSrcA points to the first input vector
  246. * @param[in] pSrcB points to the second input vector
  247. * @param[out] pDst points to the output vector
  248. * @param[in] numSamples number of complex samples in each vector
  249. */
  250. void arm_cmplx_mult_cmplx_q15(
  251. const q15_t * pSrcA,
  252. const q15_t * pSrcB,
  253. q15_t * pDst,
  254. uint32_t numSamples);
  255. /**
  256. * @brief Q31 complex-by-complex multiplication
  257. * @param[in] pSrcA points to the first input vector
  258. * @param[in] pSrcB points to the second input vector
  259. * @param[out] pDst points to the output vector
  260. * @param[in] numSamples number of complex samples in each vector
  261. */
  262. void arm_cmplx_mult_cmplx_q31(
  263. const q31_t * pSrcA,
  264. const q31_t * pSrcB,
  265. q31_t * pDst,
  266. uint32_t numSamples);
  267. /**
  268. * @brief Floating-point complex-by-complex multiplication
  269. * @param[in] pSrcA points to the first input vector
  270. * @param[in] pSrcB points to the second input vector
  271. * @param[out] pDst points to the output vector
  272. * @param[in] numSamples number of complex samples in each vector
  273. */
  274. void arm_cmplx_mult_cmplx_f32(
  275. const float32_t * pSrcA,
  276. const float32_t * pSrcB,
  277. float32_t * pDst,
  278. uint32_t numSamples);
  279. /**
  280. * @brief Floating-point complex-by-complex multiplication
  281. * @param[in] pSrcA points to the first input vector
  282. * @param[in] pSrcB points to the second input vector
  283. * @param[out] pDst points to the output vector
  284. * @param[in] numSamples number of complex samples in each vector
  285. */
  286. void arm_cmplx_mult_cmplx_f64(
  287. const float64_t * pSrcA,
  288. const float64_t * pSrcB,
  289. float64_t * pDst,
  290. uint32_t numSamples);
  291. #ifdef __cplusplus
  292. }
  293. #endif
  294. #endif /* ifndef _COMPLEX_MATH_FUNCTIONS_H_ */