complex_math_functions.h 11 KB

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