support_functions.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. /******************************************************************************
  2. * @file support_functions.h
  3. * @brief Public header file for CMSIS DSP Library
  4. * @version V1.9.0
  5. * @date 20. July 2020
  6. ******************************************************************************/
  7. /*
  8. * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved.
  9. *
  10. * SPDX-License-Identifier: Apache-2.0
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the License); you may
  13. * not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  20. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. #ifndef _SUPPORT_FUNCTIONS_H_
  25. #define _SUPPORT_FUNCTIONS_H_
  26. #include "arm_math_types.h"
  27. #include "arm_math_memory.h"
  28. #include "dsp/none.h"
  29. #include "dsp/utils.h"
  30. #ifdef __cplusplus
  31. extern "C"
  32. {
  33. #endif
  34. /**
  35. * @defgroup groupSupport Support Functions
  36. */
  37. /**
  38. * @brief Converts the elements of the floating-point vector to Q31 vector.
  39. * @param[in] pSrc points to the floating-point input vector
  40. * @param[out] pDst points to the Q31 output vector
  41. * @param[in] blockSize length of the input vector
  42. */
  43. void arm_float_to_q31(
  44. const float32_t * pSrc,
  45. q31_t * pDst,
  46. uint32_t blockSize);
  47. /**
  48. * @brief Converts the elements of the floating-point vector to Q15 vector.
  49. * @param[in] pSrc points to the floating-point input vector
  50. * @param[out] pDst points to the Q15 output vector
  51. * @param[in] blockSize length of the input vector
  52. */
  53. void arm_float_to_q15(
  54. const float32_t * pSrc,
  55. q15_t * pDst,
  56. uint32_t blockSize);
  57. /**
  58. * @brief Converts the elements of the floating-point vector to Q7 vector.
  59. * @param[in] pSrc points to the floating-point input vector
  60. * @param[out] pDst points to the Q7 output vector
  61. * @param[in] blockSize length of the input vector
  62. */
  63. void arm_float_to_q7(
  64. const float32_t * pSrc,
  65. q7_t * pDst,
  66. uint32_t blockSize);
  67. /**
  68. * @brief Converts the elements of the Q31 vector to floating-point vector.
  69. * @param[in] pSrc is input pointer
  70. * @param[out] pDst is output pointer
  71. * @param[in] blockSize is the number of samples to process
  72. */
  73. void arm_q31_to_float(
  74. const q31_t * pSrc,
  75. float32_t * pDst,
  76. uint32_t blockSize);
  77. /**
  78. * @brief Converts the elements of the Q31 vector to Q15 vector.
  79. * @param[in] pSrc is input pointer
  80. * @param[out] pDst is output pointer
  81. * @param[in] blockSize is the number of samples to process
  82. */
  83. void arm_q31_to_q15(
  84. const q31_t * pSrc,
  85. q15_t * pDst,
  86. uint32_t blockSize);
  87. /**
  88. * @brief Converts the elements of the Q31 vector to Q7 vector.
  89. * @param[in] pSrc is input pointer
  90. * @param[out] pDst is output pointer
  91. * @param[in] blockSize is the number of samples to process
  92. */
  93. void arm_q31_to_q7(
  94. const q31_t * pSrc,
  95. q7_t * pDst,
  96. uint32_t blockSize);
  97. /**
  98. * @brief Converts the elements of the Q15 vector to floating-point vector.
  99. * @param[in] pSrc is input pointer
  100. * @param[out] pDst is output pointer
  101. * @param[in] blockSize is the number of samples to process
  102. */
  103. void arm_q15_to_float(
  104. const q15_t * pSrc,
  105. float32_t * pDst,
  106. uint32_t blockSize);
  107. /**
  108. * @brief Converts the elements of the Q15 vector to Q31 vector.
  109. * @param[in] pSrc is input pointer
  110. * @param[out] pDst is output pointer
  111. * @param[in] blockSize is the number of samples to process
  112. */
  113. void arm_q15_to_q31(
  114. const q15_t * pSrc,
  115. q31_t * pDst,
  116. uint32_t blockSize);
  117. /**
  118. * @brief Converts the elements of the Q15 vector to Q7 vector.
  119. * @param[in] pSrc is input pointer
  120. * @param[out] pDst is output pointer
  121. * @param[in] blockSize is the number of samples to process
  122. */
  123. void arm_q15_to_q7(
  124. const q15_t * pSrc,
  125. q7_t * pDst,
  126. uint32_t blockSize);
  127. /**
  128. * @brief Converts the elements of the Q7 vector to floating-point vector.
  129. * @param[in] pSrc is input pointer
  130. * @param[out] pDst is output pointer
  131. * @param[in] blockSize is the number of samples to process
  132. */
  133. void arm_q7_to_float(
  134. const q7_t * pSrc,
  135. float32_t * pDst,
  136. uint32_t blockSize);
  137. /**
  138. * @brief Converts the elements of the Q7 vector to Q31 vector.
  139. * @param[in] pSrc input pointer
  140. * @param[out] pDst output pointer
  141. * @param[in] blockSize number of samples to process
  142. */
  143. void arm_q7_to_q31(
  144. const q7_t * pSrc,
  145. q31_t * pDst,
  146. uint32_t blockSize);
  147. /**
  148. * @brief Converts the elements of the Q7 vector to Q15 vector.
  149. * @param[in] pSrc input pointer
  150. * @param[out] pDst output pointer
  151. * @param[in] blockSize number of samples to process
  152. */
  153. void arm_q7_to_q15(
  154. const q7_t * pSrc,
  155. q15_t * pDst,
  156. uint32_t blockSize);
  157. /**
  158. * @brief Struct for specifying sorting algorithm
  159. */
  160. typedef enum
  161. {
  162. ARM_SORT_BITONIC = 0,
  163. /**< Bitonic sort */
  164. ARM_SORT_BUBBLE = 1,
  165. /**< Bubble sort */
  166. ARM_SORT_HEAP = 2,
  167. /**< Heap sort */
  168. ARM_SORT_INSERTION = 3,
  169. /**< Insertion sort */
  170. ARM_SORT_QUICK = 4,
  171. /**< Quick sort */
  172. ARM_SORT_SELECTION = 5
  173. /**< Selection sort */
  174. } arm_sort_alg;
  175. /**
  176. * @brief Struct for specifying sorting algorithm
  177. */
  178. typedef enum
  179. {
  180. ARM_SORT_DESCENDING = 0,
  181. /**< Descending order (9 to 0) */
  182. ARM_SORT_ASCENDING = 1
  183. /**< Ascending order (0 to 9) */
  184. } arm_sort_dir;
  185. /**
  186. * @brief Instance structure for the sorting algorithms.
  187. */
  188. typedef struct
  189. {
  190. arm_sort_alg alg; /**< Sorting algorithm selected */
  191. arm_sort_dir dir; /**< Sorting order (direction) */
  192. } arm_sort_instance_f32;
  193. /**
  194. * @param[in] S points to an instance of the sorting structure.
  195. * @param[in] pSrc points to the block of input data.
  196. * @param[out] pDst points to the block of output data.
  197. * @param[in] blockSize number of samples to process.
  198. */
  199. void arm_sort_f32(
  200. const arm_sort_instance_f32 * S,
  201. float32_t * pSrc,
  202. float32_t * pDst,
  203. uint32_t blockSize);
  204. /**
  205. * @param[in,out] S points to an instance of the sorting structure.
  206. * @param[in] alg Selected algorithm.
  207. * @param[in] dir Sorting order.
  208. */
  209. void arm_sort_init_f32(
  210. arm_sort_instance_f32 * S,
  211. arm_sort_alg alg,
  212. arm_sort_dir dir);
  213. /**
  214. * @brief Instance structure for the sorting algorithms.
  215. */
  216. typedef struct
  217. {
  218. arm_sort_dir dir; /**< Sorting order (direction) */
  219. float32_t * buffer; /**< Working buffer */
  220. } arm_merge_sort_instance_f32;
  221. /**
  222. * @param[in] S points to an instance of the sorting structure.
  223. * @param[in,out] pSrc points to the block of input data.
  224. * @param[out] pDst points to the block of output data
  225. * @param[in] blockSize number of samples to process.
  226. */
  227. void arm_merge_sort_f32(
  228. const arm_merge_sort_instance_f32 * S,
  229. float32_t *pSrc,
  230. float32_t *pDst,
  231. uint32_t blockSize);
  232. /**
  233. * @param[in,out] S points to an instance of the sorting structure.
  234. * @param[in] dir Sorting order.
  235. * @param[in] buffer Working buffer.
  236. */
  237. void arm_merge_sort_init_f32(
  238. arm_merge_sort_instance_f32 * S,
  239. arm_sort_dir dir,
  240. float32_t * buffer);
  241. /**
  242. * @brief Copies the elements of a floating-point vector.
  243. * @param[in] pSrc input pointer
  244. * @param[out] pDst output pointer
  245. * @param[in] blockSize number of samples to process
  246. */
  247. void arm_copy_f32(
  248. const float32_t * pSrc,
  249. float32_t * pDst,
  250. uint32_t blockSize);
  251. /**
  252. * @brief Copies the elements of a Q7 vector.
  253. * @param[in] pSrc input pointer
  254. * @param[out] pDst output pointer
  255. * @param[in] blockSize number of samples to process
  256. */
  257. void arm_copy_q7(
  258. const q7_t * pSrc,
  259. q7_t * pDst,
  260. uint32_t blockSize);
  261. /**
  262. * @brief Copies the elements of a Q15 vector.
  263. * @param[in] pSrc input pointer
  264. * @param[out] pDst output pointer
  265. * @param[in] blockSize number of samples to process
  266. */
  267. void arm_copy_q15(
  268. const q15_t * pSrc,
  269. q15_t * pDst,
  270. uint32_t blockSize);
  271. /**
  272. * @brief Copies the elements of a Q31 vector.
  273. * @param[in] pSrc input pointer
  274. * @param[out] pDst output pointer
  275. * @param[in] blockSize number of samples to process
  276. */
  277. void arm_copy_q31(
  278. const q31_t * pSrc,
  279. q31_t * pDst,
  280. uint32_t blockSize);
  281. /**
  282. * @brief Fills a constant value into a floating-point vector.
  283. * @param[in] value input value to be filled
  284. * @param[out] pDst output pointer
  285. * @param[in] blockSize number of samples to process
  286. */
  287. void arm_fill_f32(
  288. float32_t value,
  289. float32_t * pDst,
  290. uint32_t blockSize);
  291. /**
  292. * @brief Fills a constant value into a Q7 vector.
  293. * @param[in] value input value to be filled
  294. * @param[out] pDst output pointer
  295. * @param[in] blockSize number of samples to process
  296. */
  297. void arm_fill_q7(
  298. q7_t value,
  299. q7_t * pDst,
  300. uint32_t blockSize);
  301. /**
  302. * @brief Fills a constant value into a Q15 vector.
  303. * @param[in] value input value to be filled
  304. * @param[out] pDst output pointer
  305. * @param[in] blockSize number of samples to process
  306. */
  307. void arm_fill_q15(
  308. q15_t value,
  309. q15_t * pDst,
  310. uint32_t blockSize);
  311. /**
  312. * @brief Fills a constant value into a Q31 vector.
  313. * @param[in] value input value to be filled
  314. * @param[out] pDst output pointer
  315. * @param[in] blockSize number of samples to process
  316. */
  317. void arm_fill_q31(
  318. q31_t value,
  319. q31_t * pDst,
  320. uint32_t blockSize);
  321. /**
  322. * @brief Weighted sum
  323. *
  324. *
  325. * @param[in] *in Array of input values.
  326. * @param[in] *weigths Weights
  327. * @param[in] blockSize Number of samples in the input array.
  328. * @return Weighted sum
  329. *
  330. */
  331. float32_t arm_weighted_sum_f32(const float32_t *in
  332. , const float32_t *weigths
  333. , uint32_t blockSize);
  334. /**
  335. * @brief Barycenter
  336. *
  337. *
  338. * @param[in] in List of vectors
  339. * @param[in] weights Weights of the vectors
  340. * @param[out] out Barycenter
  341. * @param[in] nbVectors Number of vectors
  342. * @param[in] vecDim Dimension of space (vector dimension)
  343. * @return None
  344. *
  345. */
  346. void arm_barycenter_f32(const float32_t *in
  347. , const float32_t *weights
  348. , float32_t *out
  349. , uint32_t nbVectors
  350. , uint32_t vecDim);
  351. #ifdef __cplusplus
  352. }
  353. #endif
  354. #endif /* ifndef _SUPPORT_FUNCTIONS_H_ */