1 /******************************************************************************
2  * @file     statistics_functions_f16.h
3  * @brief    Public header file for CMSIS DSP Library
4  * @version  V1.10.1
5  * @date     14 July 2022
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 
26 
27 #ifndef STATISTICS_FUNCTIONS_F16_H_
28 #define STATISTICS_FUNCTIONS_F16_H_
29 
30 #include "arm_math_types_f16.h"
31 #include "arm_math_memory.h"
32 
33 #include "dsp/none.h"
34 #include "dsp/utils.h"
35 
36 #include "dsp/basic_math_functions_f16.h"
37 #include "dsp/fast_math_functions_f16.h"
38 
39 #ifdef   __cplusplus
40 extern "C"
41 {
42 #endif
43 
44 #if defined(ARM_FLOAT16_SUPPORTED)
45 
46  /**
47    * @brief  Sum of the squares of the elements of a floating-point vector.
48    * @param[in]  pSrc       is input pointer
49    * @param[in]  blockSize  is the number of samples to process
50    * @param[out] pResult    is output value.
51    */
52   void arm_power_f16(
53   const float16_t * pSrc,
54         uint32_t blockSize,
55         float16_t * pResult);
56 
57  /**
58    * @brief  Mean value of a floating-point vector.
59    * @param[in]  pSrc       is input pointer
60    * @param[in]  blockSize  is the number of samples to process
61    * @param[out] pResult    is output value.
62    */
63   void arm_mean_f16(
64   const float16_t * pSrc,
65         uint32_t blockSize,
66         float16_t * pResult);
67 
68   /**
69    * @brief  Variance of the elements of a floating-point vector.
70    * @param[in]  pSrc       is input pointer
71    * @param[in]  blockSize  is the number of samples to process
72    * @param[out] pResult    is output value.
73    */
74   void arm_var_f16(
75   const float16_t * pSrc,
76         uint32_t blockSize,
77         float16_t * pResult);
78 
79  /**
80    * @brief  Root Mean Square 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 arm_rms_f16(
86   const float16_t * pSrc,
87         uint32_t blockSize,
88         float16_t * pResult);
89 
90  /**
91    * @brief  Standard deviation of the elements of a floating-point vector.
92    * @param[in]  pSrc       is input pointer
93    * @param[in]  blockSize  is the number of samples to process
94    * @param[out] pResult    is output value.
95    */
96   void arm_std_f16(
97   const float16_t * pSrc,
98         uint32_t blockSize,
99         float16_t * pResult);
100 
101  /**
102    * @brief  Minimum value 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 arm_min_f16(
109   const float16_t * pSrc,
110         uint32_t blockSize,
111         float16_t * pResult,
112         uint32_t * pIndex);
113 
114  /**
115    * @brief  Minimum value of absolute values of a floating-point vector.
116    * @param[in]  pSrc       is input pointer
117    * @param[in]  blockSize  is the number of samples to process
118    * @param[out] pResult    is output pointer
119    * @param[out] pIndex     is the array index of the minimum value in the input buffer.
120    */
121   void arm_absmin_f16(
122   const float16_t * pSrc,
123         uint32_t blockSize,
124         float16_t * pResult,
125         uint32_t * pIndex);
126 
127 /**
128  * @brief Maximum value of a floating-point vector.
129  * @param[in]  pSrc       points to the input buffer
130  * @param[in]  blockSize  length of the input vector
131  * @param[out] pResult    maximum value returned here
132  * @param[out] pIndex     index of maximum value returned here
133  */
134   void arm_max_f16(
135   const float16_t * pSrc,
136         uint32_t blockSize,
137         float16_t * pResult,
138         uint32_t * pIndex);
139 
140 /**
141  * @brief Maximum value of absolute values of a floating-point vector.
142  * @param[in]  pSrc       points to the input buffer
143  * @param[in]  blockSize  length of the input vector
144  * @param[out] pResult    maximum value returned here
145  * @param[out] pIndex     index of maximum value returned here
146  */
147   void arm_absmax_f16(
148   const float16_t * pSrc,
149         uint32_t blockSize,
150         float16_t * pResult,
151         uint32_t * pIndex);
152 
153     /**
154    * @brief  Minimum value of absolute values of a floating-point vector.
155    * @param[in]  pSrc       is input pointer
156    * @param[in]  blockSize  is the number of samples to process
157    * @param[out] pResult    is output pointer
158    */
159   void arm_absmin_no_idx_f16(
160   const float16_t * pSrc,
161         uint32_t blockSize,
162         float16_t * pResult);
163 
164 /**
165  * @brief Maximum value of a floating-point vector.
166  * @param[in]  pSrc       points to the input buffer
167  * @param[in]  blockSize  length of the input vector
168  * @param[out] pResult    maximum value returned here
169  */
170   void arm_absmax_no_idx_f16(
171   const float16_t * pSrc,
172         uint32_t blockSize,
173         float16_t * pResult);
174 
175 
176 /**
177  * @brief Entropy
178  *
179  * @param[in]  pSrcA        Array of input values.
180  * @param[in]  blockSize    Number of samples in the input array.
181  * @return     Entropy      -Sum(p ln p)
182  */
183 float16_t arm_entropy_f16(const float16_t * pSrcA,uint32_t blockSize);
184 
185 
186 float16_t arm_logsumexp_f16(const float16_t *in, uint32_t blockSize);
187 
188 
189 /**
190  * @brief Dot product with log arithmetic
191  *
192  * Vectors are containing the log of the samples
193  *
194  * @param[in]       pSrcA points to the first input vector
195  * @param[in]       pSrcB points to the second input vector
196  * @param[in]       blockSize number of samples in each vector
197  * @param[in]       pTmpBuffer temporary buffer of length blockSize
198  * @return The log of the dot product .
199  */
200 float16_t arm_logsumexp_dot_prod_f16(const float16_t * pSrcA,
201   const float16_t * pSrcB,
202   uint32_t blockSize,
203   float16_t *pTmpBuffer);
204 
205 
206 /**
207  * @brief Kullback-Leibler
208  *
209  * @param[in]  pSrcA         Pointer to an array of input values for probability distribution A.
210  * @param[in]  pSrcB         Pointer to an array of input values for probability distribution B.
211  * @param[in]  blockSize     Number of samples in the input array.
212  * @return Kullback-Leibler  Divergence D(A || B)
213  */
214 float16_t arm_kullback_leibler_f16(const float16_t * pSrcA
215   ,const float16_t * pSrcB
216   ,uint32_t blockSize);
217 
218 
219 /**
220     @brief         Maximum value of a floating-point vector.
221     @param[in]     pSrc       points to the input vector
222     @param[in]     blockSize  number of samples in input vector
223     @param[out]    pResult    maximum value returned here
224    */
225   void arm_max_no_idx_f16(
226       const float16_t *pSrc,
227       uint32_t   blockSize,
228       float16_t *pResult);
229 
230 
231 /**
232     @brief         Minimum value of a floating-point vector.
233     @param[in]     pSrc       points to the input vector
234     @param[in]     blockSize  number of samples in input vector
235     @param[out]    pResult    minimum value returned here
236    */
237   void arm_min_no_idx_f16(
238       const float16_t *pSrc,
239       uint32_t   blockSize,
240       float16_t *pResult);
241 
242 
243 /**
244   @brief         Mean square error between two half precision float vectors.
245   @param[in]     pSrcA       points to the first input vector
246   @param[in]     pSrcB       points to the second input vector
247   @param[in]     blockSize  number of samples in input vector
248   @param[out]    pResult    mean square error
249 */
250 void arm_mse_f16(
251   const float16_t * pSrcA,
252   const float16_t * pSrcB,
253         uint32_t blockSize,
254         float16_t * pResult);
255 
256 
257 /**
258   * @brief  Sum value of a floating-point vector.
259   * @param[in]  pSrc       is input pointer
260   * @param[in]  blockSize  is the number of samples to process
261   * @param[out] pResult    is output value.
262   */
263  void arm_accumulate_f16(
264  const float16_t * pSrc,
265        uint32_t blockSize,
266        float16_t * pResult);
267 
268 
269 #endif /*defined(ARM_FLOAT16_SUPPORTED)*/
270 #ifdef   __cplusplus
271 }
272 #endif
273 
274 #endif /* ifndef _STATISTICS_FUNCTIONS_F16_H_ */
275