complex_math_functions.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /******************************************************************************
  2. * @file complex_math_functions.h
  3. * @brief Public header file for CMSIS DSP Library
  4. * @version V1.9.0
  5. * @date 23 April 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 Q31 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_q31(
  92. const q31_t * pSrc,
  93. q31_t * pDst,
  94. uint32_t numSamples);
  95. /**
  96. * @brief Q15 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_q15(
  102. const q15_t * pSrc,
  103. q15_t * pDst,
  104. uint32_t numSamples);
  105. /**
  106. * @brief Floating-point complex magnitude
  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_f32(
  112. const float32_t * pSrc,
  113. float32_t * pDst,
  114. uint32_t numSamples);
  115. /**
  116. * @brief Q31 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_q31(
  122. const q31_t * pSrc,
  123. q31_t * pDst,
  124. uint32_t numSamples);
  125. /**
  126. * @brief Q15 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_q15(
  132. const q15_t * pSrc,
  133. q15_t * pDst,
  134. uint32_t numSamples);
  135. /**
  136. * @brief Q15 complex dot product
  137. * @param[in] pSrcA points to the first input vector
  138. * @param[in] pSrcB points to the second input vector
  139. * @param[in] numSamples number of complex samples in each vector
  140. * @param[out] realResult real part of the result returned here
  141. * @param[out] imagResult imaginary part of the result returned here
  142. */
  143. void arm_cmplx_dot_prod_q15(
  144. const q15_t * pSrcA,
  145. const q15_t * pSrcB,
  146. uint32_t numSamples,
  147. q31_t * realResult,
  148. q31_t * imagResult);
  149. /**
  150. * @brief Q31 complex dot product
  151. * @param[in] pSrcA points to the first input vector
  152. * @param[in] pSrcB points to the second input vector
  153. * @param[in] numSamples number of complex samples in each vector
  154. * @param[out] realResult real part of the result returned here
  155. * @param[out] imagResult imaginary part of the result returned here
  156. */
  157. void arm_cmplx_dot_prod_q31(
  158. const q31_t * pSrcA,
  159. const q31_t * pSrcB,
  160. uint32_t numSamples,
  161. q63_t * realResult,
  162. q63_t * imagResult);
  163. /**
  164. * @brief Floating-point complex dot product
  165. * @param[in] pSrcA points to the first input vector
  166. * @param[in] pSrcB points to the second input vector
  167. * @param[in] numSamples number of complex samples in each vector
  168. * @param[out] realResult real part of the result returned here
  169. * @param[out] imagResult imaginary part of the result returned here
  170. */
  171. void arm_cmplx_dot_prod_f32(
  172. const float32_t * pSrcA,
  173. const float32_t * pSrcB,
  174. uint32_t numSamples,
  175. float32_t * realResult,
  176. float32_t * imagResult);
  177. /**
  178. * @brief Q15 complex-by-real multiplication
  179. * @param[in] pSrcCmplx points to the complex input vector
  180. * @param[in] pSrcReal points to the real input vector
  181. * @param[out] pCmplxDst points to the complex output vector
  182. * @param[in] numSamples number of samples in each vector
  183. */
  184. void arm_cmplx_mult_real_q15(
  185. const q15_t * pSrcCmplx,
  186. const q15_t * pSrcReal,
  187. q15_t * pCmplxDst,
  188. uint32_t numSamples);
  189. /**
  190. * @brief Q31 complex-by-real multiplication
  191. * @param[in] pSrcCmplx points to the complex input vector
  192. * @param[in] pSrcReal points to the real input vector
  193. * @param[out] pCmplxDst points to the complex output vector
  194. * @param[in] numSamples number of samples in each vector
  195. */
  196. void arm_cmplx_mult_real_q31(
  197. const q31_t * pSrcCmplx,
  198. const q31_t * pSrcReal,
  199. q31_t * pCmplxDst,
  200. uint32_t numSamples);
  201. /**
  202. * @brief Floating-point complex-by-real multiplication
  203. * @param[in] pSrcCmplx points to the complex input vector
  204. * @param[in] pSrcReal points to the real input vector
  205. * @param[out] pCmplxDst points to the complex output vector
  206. * @param[in] numSamples number of samples in each vector
  207. */
  208. void arm_cmplx_mult_real_f32(
  209. const float32_t * pSrcCmplx,
  210. const float32_t * pSrcReal,
  211. float32_t * pCmplxDst,
  212. uint32_t numSamples);
  213. /**
  214. * @brief Q15 complex-by-complex multiplication
  215. * @param[in] pSrcA points to the first input vector
  216. * @param[in] pSrcB points to the second input vector
  217. * @param[out] pDst points to the output vector
  218. * @param[in] numSamples number of complex samples in each vector
  219. */
  220. void arm_cmplx_mult_cmplx_q15(
  221. const q15_t * pSrcA,
  222. const q15_t * pSrcB,
  223. q15_t * pDst,
  224. uint32_t numSamples);
  225. /**
  226. * @brief Q31 complex-by-complex multiplication
  227. * @param[in] pSrcA points to the first input vector
  228. * @param[in] pSrcB points to the second input vector
  229. * @param[out] pDst points to the output vector
  230. * @param[in] numSamples number of complex samples in each vector
  231. */
  232. void arm_cmplx_mult_cmplx_q31(
  233. const q31_t * pSrcA,
  234. const q31_t * pSrcB,
  235. q31_t * pDst,
  236. uint32_t numSamples);
  237. /**
  238. * @brief Floating-point complex-by-complex multiplication
  239. * @param[in] pSrcA points to the first input vector
  240. * @param[in] pSrcB points to the second input vector
  241. * @param[out] pDst points to the output vector
  242. * @param[in] numSamples number of complex samples in each vector
  243. */
  244. void arm_cmplx_mult_cmplx_f32(
  245. const float32_t * pSrcA,
  246. const float32_t * pSrcB,
  247. float32_t * pDst,
  248. uint32_t numSamples);
  249. #ifdef __cplusplus
  250. }
  251. #endif
  252. #endif /* ifndef _COMPLEX_MATH_FUNCTIONS_H_ */