statistics_functions_f16.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /******************************************************************************
  2. * @file statistics_functions_f16.h
  3. * @brief Public header file for NMSIS DSP Library
  4. * @version V1.10.1
  5. * @date 14 July 2022
  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 STATISTICS_FUNCTIONS_F16_H_
  27. #define STATISTICS_FUNCTIONS_F16_H_
  28. #include "riscv_math_types_f16.h"
  29. #include "riscv_math_memory.h"
  30. #include "dsp/none.h"
  31. #include "dsp/utils.h"
  32. #include "dsp/basic_math_functions_f16.h"
  33. #include "dsp/fast_math_functions_f16.h"
  34. #ifdef __cplusplus
  35. extern "C"
  36. {
  37. #endif
  38. #if defined(RISCV_FLOAT16_SUPPORTED)
  39. /**
  40. * @brief Sum of the squares of the elements of a floating-point vector.
  41. * @param[in] pSrc is input pointer
  42. * @param[in] blockSize is the number of samples to process
  43. * @param[out] pResult is output value.
  44. */
  45. void riscv_power_f16(
  46. const float16_t * pSrc,
  47. uint32_t blockSize,
  48. float16_t * pResult);
  49. /**
  50. * @brief Mean value of a floating-point vector.
  51. * @param[in] pSrc is input pointer
  52. * @param[in] blockSize is the number of samples to process
  53. * @param[out] pResult is output value.
  54. */
  55. void riscv_mean_f16(
  56. const float16_t * pSrc,
  57. uint32_t blockSize,
  58. float16_t * pResult);
  59. /**
  60. * @brief Variance of the elements of a floating-point vector.
  61. * @param[in] pSrc is input pointer
  62. * @param[in] blockSize is the number of samples to process
  63. * @param[out] pResult is output value.
  64. */
  65. void riscv_var_f16(
  66. const float16_t * pSrc,
  67. uint32_t blockSize,
  68. float16_t * pResult);
  69. /**
  70. * @brief Root Mean Square of the elements of a floating-point vector.
  71. * @param[in] pSrc is input pointer
  72. * @param[in] blockSize is the number of samples to process
  73. * @param[out] pResult is output value.
  74. */
  75. void riscv_rms_f16(
  76. const float16_t * pSrc,
  77. uint32_t blockSize,
  78. float16_t * pResult);
  79. /**
  80. * @brief Standard deviation of the elements of a floating-point vector.
  81. * @param[in] pSrc is input pointer
  82. * @param[in] blockSize is the number of samples to process
  83. * @param[out] pResult is output value.
  84. */
  85. void riscv_std_f16(
  86. const float16_t * pSrc,
  87. uint32_t blockSize,
  88. float16_t * pResult);
  89. /**
  90. * @brief Minimum value of a floating-point vector.
  91. * @param[in] pSrc is input pointer
  92. * @param[in] blockSize is the number of samples to process
  93. * @param[out] pResult is output pointer
  94. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  95. */
  96. void riscv_min_f16(
  97. const float16_t * pSrc,
  98. uint32_t blockSize,
  99. float16_t * pResult,
  100. uint32_t * pIndex);
  101. /**
  102. * @brief Minimum value of absolute values of a floating-point vector.
  103. * @param[in] pSrc is input pointer
  104. * @param[in] blockSize is the number of samples to process
  105. * @param[out] pResult is output pointer
  106. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  107. */
  108. void riscv_absmin_f16(
  109. const float16_t * pSrc,
  110. uint32_t blockSize,
  111. float16_t * pResult,
  112. uint32_t * pIndex);
  113. /**
  114. * @brief Maximum value of a floating-point vector.
  115. * @param[in] pSrc points to the input buffer
  116. * @param[in] blockSize length of the input vector
  117. * @param[out] pResult maximum value returned here
  118. * @param[out] pIndex index of maximum value returned here
  119. */
  120. void riscv_max_f16(
  121. const float16_t * pSrc,
  122. uint32_t blockSize,
  123. float16_t * pResult,
  124. uint32_t * pIndex);
  125. /**
  126. * @brief Maximum value of absolute values of a floating-point vector.
  127. * @param[in] pSrc points to the input buffer
  128. * @param[in] blockSize length of the input vector
  129. * @param[out] pResult maximum value returned here
  130. * @param[out] pIndex index of maximum value returned here
  131. */
  132. void riscv_absmax_f16(
  133. const float16_t * pSrc,
  134. uint32_t blockSize,
  135. float16_t * pResult,
  136. uint32_t * pIndex);
  137. /**
  138. * @brief Minimum value of absolute values of a floating-point vector.
  139. * @param[in] pSrc is input pointer
  140. * @param[in] blockSize is the number of samples to process
  141. * @param[out] pResult is output pointer
  142. */
  143. void riscv_absmin_no_idx_f16(
  144. const float16_t * pSrc,
  145. uint32_t blockSize,
  146. float16_t * pResult);
  147. /**
  148. * @brief Maximum value of a floating-point vector.
  149. * @param[in] pSrc points to the input buffer
  150. * @param[in] blockSize length of the input vector
  151. * @param[out] pResult maximum value returned here
  152. */
  153. void riscv_absmax_no_idx_f16(
  154. const float16_t * pSrc,
  155. uint32_t blockSize,
  156. float16_t * pResult);
  157. /**
  158. * @brief Entropy
  159. *
  160. * @param[in] pSrcA Array of input values.
  161. * @param[in] blockSize Number of samples in the input array.
  162. * @return Entropy -Sum(p ln p)
  163. */
  164. float16_t riscv_entropy_f16(const float16_t * pSrcA,uint32_t blockSize);
  165. float16_t riscv_logsumexp_f16(const float16_t *in, uint32_t blockSize);
  166. /**
  167. * @brief Dot product with log arithmetic
  168. *
  169. * Vectors are containing the log of the samples
  170. *
  171. * @param[in] pSrcA points to the first input vector
  172. * @param[in] pSrcB points to the second input vector
  173. * @param[in] blockSize number of samples in each vector
  174. * @param[in] pTmpBuffer temporary buffer of length blockSize
  175. * @return The log of the dot product .
  176. */
  177. float16_t riscv_logsumexp_dot_prod_f16(const float16_t * pSrcA,
  178. const float16_t * pSrcB,
  179. uint32_t blockSize,
  180. float16_t *pTmpBuffer);
  181. /**
  182. * @brief Kullback-Leibler
  183. *
  184. * @param[in] pSrcA Pointer to an array of input values for probability distribution A.
  185. * @param[in] pSrcB Pointer to an array of input values for probability distribution B.
  186. * @param[in] blockSize Number of samples in the input array.
  187. * @return Kullback-Leibler Divergence D(A || B)
  188. */
  189. float16_t riscv_kullback_leibler_f16(const float16_t * pSrcA
  190. ,const float16_t * pSrcB
  191. ,uint32_t blockSize);
  192. /**
  193. @brief Maximum value of a floating-point vector.
  194. @param[in] pSrc points to the input vector
  195. @param[in] blockSize number of samples in input vector
  196. @param[out] pResult maximum value returned here
  197. */
  198. void riscv_max_no_idx_f16(
  199. const float16_t *pSrc,
  200. uint32_t blockSize,
  201. float16_t *pResult);
  202. /**
  203. @brief Minimum value of a floating-point vector.
  204. @param[in] pSrc points to the input vector
  205. @param[in] blockSize number of samples in input vector
  206. @param[out] pResult minimum value returned here
  207. */
  208. void riscv_min_no_idx_f16(
  209. const float16_t *pSrc,
  210. uint32_t blockSize,
  211. float16_t *pResult);
  212. /**
  213. @brief Mean square error between two half precision float vectors.
  214. @param[in] pSrcA points to the first input vector
  215. @param[in] pSrcB points to the second input vector
  216. @param[in] blockSize number of samples in input vector
  217. @param[out] pResult mean square error
  218. */
  219. void riscv_mse_f16(
  220. const float16_t * pSrcA,
  221. const float16_t * pSrcB,
  222. uint32_t blockSize,
  223. float16_t * pResult);
  224. /**
  225. * @brief Sum value of a floating-point vector.
  226. * @param[in] pSrc is input pointer
  227. * @param[in] blockSize is the number of samples to process
  228. * @param[out] pResult is output value.
  229. */
  230. void riscv_accumulate_f16(
  231. const float16_t * pSrc,
  232. uint32_t blockSize,
  233. float16_t * pResult);
  234. #endif /*defined(RISCV_FLOAT16_SUPPORTED)*/
  235. #ifdef __cplusplus
  236. }
  237. #endif
  238. #endif /* ifndef _STATISTICS_FUNCTIONS_F16_H_ */