statistics_functions.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. /******************************************************************************
  2. * @file statistics_functions.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_H_
  27. #define STATISTICS_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/basic_math_functions.h"
  33. #include "dsp/fast_math_functions.h"
  34. #ifdef __cplusplus
  35. extern "C"
  36. {
  37. #endif
  38. /**
  39. * @defgroup groupStats Statistics Functions
  40. */
  41. /**
  42. * @brief Computation of the LogSumExp
  43. *
  44. * In probabilistic computations, the dynamic of the probability values can be very
  45. * wide because they come from gaussian functions.
  46. * To avoid underflow and overflow issues, the values are represented by their log.
  47. * In this representation, multiplying the original exp values is easy : their logs are added.
  48. * But adding the original exp values is requiring some special handling and it is the
  49. * goal of the LogSumExp function.
  50. *
  51. * If the values are x1...xn, the function is computing:
  52. *
  53. * ln(exp(x1) + ... + exp(xn)) and the computation is done in such a way that
  54. * rounding issues are minimised.
  55. *
  56. * The max xm of the values is extracted and the function is computing:
  57. * xm + ln(exp(x1 - xm) + ... + exp(xn - xm))
  58. *
  59. * @param[in] *in Pointer to an array of input values.
  60. * @param[in] blockSize Number of samples in the input array.
  61. * @return LogSumExp
  62. *
  63. */
  64. float32_t riscv_logsumexp_f32(const float32_t *in, uint32_t blockSize);
  65. /**
  66. * @brief Dot product with log arithmetic
  67. *
  68. * Vectors are containing the log of the samples
  69. *
  70. * @param[in] pSrcA points to the first input vector
  71. * @param[in] pSrcB points to the second input vector
  72. * @param[in] blockSize number of samples in each vector
  73. * @param[in] pTmpBuffer temporary buffer of length blockSize
  74. * @return The log of the dot product .
  75. *
  76. */
  77. float32_t riscv_logsumexp_dot_prod_f32(const float32_t * pSrcA,
  78. const float32_t * pSrcB,
  79. uint32_t blockSize,
  80. float32_t *pTmpBuffer);
  81. /**
  82. * @brief Entropy
  83. *
  84. * @param[in] pSrcA Array of input values.
  85. * @param[in] blockSize Number of samples in the input array.
  86. * @return Entropy -Sum(p ln p)
  87. *
  88. */
  89. float32_t riscv_entropy_f32(const float32_t * pSrcA,uint32_t blockSize);
  90. /**
  91. * @brief Entropy
  92. *
  93. * @param[in] pSrcA Array of input values.
  94. * @param[in] blockSize Number of samples in the input array.
  95. * @return Entropy -Sum(p ln p)
  96. *
  97. */
  98. float64_t riscv_entropy_f64(const float64_t * pSrcA, uint32_t blockSize);
  99. /**
  100. * @brief Kullback-Leibler
  101. *
  102. * @param[in] pSrcA Pointer to an array of input values for probability distribution A.
  103. * @param[in] pSrcB Pointer to an array of input values for probability distribution B.
  104. * @param[in] blockSize Number of samples in the input array.
  105. * @return Kullback-Leibler Divergence D(A || B)
  106. *
  107. */
  108. float32_t riscv_kullback_leibler_f32(const float32_t * pSrcA
  109. ,const float32_t * pSrcB
  110. ,uint32_t blockSize);
  111. /**
  112. * @brief Kullback-Leibler
  113. *
  114. * @param[in] pSrcA Pointer to an array of input values for probability distribution A.
  115. * @param[in] pSrcB Pointer to an array of input values for probability distribution B.
  116. * @param[in] blockSize Number of samples in the input array.
  117. * @return Kullback-Leibler Divergence D(A || B)
  118. *
  119. */
  120. float64_t riscv_kullback_leibler_f64(const float64_t * pSrcA,
  121. const float64_t * pSrcB,
  122. uint32_t blockSize);
  123. /**
  124. * @brief Sum of the squares of the elements of a Q31 vector.
  125. * @param[in] pSrc is input pointer
  126. * @param[in] blockSize is the number of samples to process
  127. * @param[out] pResult is output value.
  128. */
  129. void riscv_power_q31(
  130. const q31_t * pSrc,
  131. uint32_t blockSize,
  132. q63_t * pResult);
  133. /**
  134. * @brief Sum of the squares of the elements of a floating-point vector.
  135. * @param[in] pSrc is input pointer
  136. * @param[in] blockSize is the number of samples to process
  137. * @param[out] pResult is output value.
  138. */
  139. void riscv_power_f32(
  140. const float32_t * pSrc,
  141. uint32_t blockSize,
  142. float32_t * pResult);
  143. /**
  144. * @brief Sum of the squares of the elements of a floating-point vector.
  145. * @param[in] pSrc is input pointer
  146. * @param[in] blockSize is the number of samples to process
  147. * @param[out] pResult is output value.
  148. */
  149. void riscv_power_f64(
  150. const float64_t * pSrc,
  151. uint32_t blockSize,
  152. float64_t * pResult);
  153. /**
  154. * @brief Sum of the squares of the elements of a Q15 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 value.
  158. */
  159. void riscv_power_q15(
  160. const q15_t * pSrc,
  161. uint32_t blockSize,
  162. q63_t * pResult);
  163. /**
  164. * @brief Sum of the squares of the elements of a Q7 vector.
  165. * @param[in] pSrc is input pointer
  166. * @param[in] blockSize is the number of samples to process
  167. * @param[out] pResult is output value.
  168. */
  169. void riscv_power_q7(
  170. const q7_t * pSrc,
  171. uint32_t blockSize,
  172. q31_t * pResult);
  173. /**
  174. * @brief Mean value of a Q7 vector.
  175. * @param[in] pSrc is input pointer
  176. * @param[in] blockSize is the number of samples to process
  177. * @param[out] pResult is output value.
  178. */
  179. void riscv_mean_q7(
  180. const q7_t * pSrc,
  181. uint32_t blockSize,
  182. q7_t * pResult);
  183. /**
  184. * @brief Mean value of a Q15 vector.
  185. * @param[in] pSrc is input pointer
  186. * @param[in] blockSize is the number of samples to process
  187. * @param[out] pResult is output value.
  188. */
  189. void riscv_mean_q15(
  190. const q15_t * pSrc,
  191. uint32_t blockSize,
  192. q15_t * pResult);
  193. /**
  194. * @brief Mean value of a Q31 vector.
  195. * @param[in] pSrc is input pointer
  196. * @param[in] blockSize is the number of samples to process
  197. * @param[out] pResult is output value.
  198. */
  199. void riscv_mean_q31(
  200. const q31_t * pSrc,
  201. uint32_t blockSize,
  202. q31_t * pResult);
  203. /**
  204. * @brief Mean value of a floating-point vector.
  205. * @param[in] pSrc is input pointer
  206. * @param[in] blockSize is the number of samples to process
  207. * @param[out] pResult is output value.
  208. */
  209. void riscv_mean_f32(
  210. const float32_t * pSrc,
  211. uint32_t blockSize,
  212. float32_t * pResult);
  213. /**
  214. * @brief Mean value of a floating-point vector.
  215. * @param[in] pSrc is input pointer
  216. * @param[in] blockSize is the number of samples to process
  217. * @param[out] pResult is output value.
  218. */
  219. void riscv_mean_f64(
  220. const float64_t * pSrc,
  221. uint32_t blockSize,
  222. float64_t * pResult);
  223. /**
  224. * @brief Variance of the elements of a floating-point vector.
  225. * @param[in] pSrc is input pointer
  226. * @param[in] blockSize is the number of samples to process
  227. * @param[out] pResult is output value.
  228. */
  229. void riscv_var_f32(
  230. const float32_t * pSrc,
  231. uint32_t blockSize,
  232. float32_t * pResult);
  233. /**
  234. * @brief Variance of the elements of a floating-point vector.
  235. * @param[in] pSrc is input pointer
  236. * @param[in] blockSize is the number of samples to process
  237. * @param[out] pResult is output value.
  238. */
  239. void riscv_var_f64(
  240. const float64_t * pSrc,
  241. uint32_t blockSize,
  242. float64_t * pResult);
  243. /**
  244. * @brief Variance of the elements of a Q31 vector.
  245. * @param[in] pSrc is input pointer
  246. * @param[in] blockSize is the number of samples to process
  247. * @param[out] pResult is output value.
  248. */
  249. void riscv_var_q31(
  250. const q31_t * pSrc,
  251. uint32_t blockSize,
  252. q31_t * pResult);
  253. /**
  254. * @brief Variance of the elements of a Q15 vector.
  255. * @param[in] pSrc is input pointer
  256. * @param[in] blockSize is the number of samples to process
  257. * @param[out] pResult is output value.
  258. */
  259. void riscv_var_q15(
  260. const q15_t * pSrc,
  261. uint32_t blockSize,
  262. q15_t * pResult);
  263. /**
  264. * @brief Root Mean Square of the elements of a floating-point vector.
  265. * @param[in] pSrc is input pointer
  266. * @param[in] blockSize is the number of samples to process
  267. * @param[out] pResult is output value.
  268. */
  269. void riscv_rms_f32(
  270. const float32_t * pSrc,
  271. uint32_t blockSize,
  272. float32_t * pResult);
  273. /**
  274. * @brief Root Mean Square of the elements of a Q31 vector.
  275. * @param[in] pSrc is input pointer
  276. * @param[in] blockSize is the number of samples to process
  277. * @param[out] pResult is output value.
  278. */
  279. void riscv_rms_q31(
  280. const q31_t * pSrc,
  281. uint32_t blockSize,
  282. q31_t * pResult);
  283. /**
  284. * @brief Root Mean Square of the elements of a Q15 vector.
  285. * @param[in] pSrc is input pointer
  286. * @param[in] blockSize is the number of samples to process
  287. * @param[out] pResult is output value.
  288. */
  289. void riscv_rms_q15(
  290. const q15_t * pSrc,
  291. uint32_t blockSize,
  292. q15_t * pResult);
  293. /**
  294. * @brief Standard deviation of the elements of a floating-point vector.
  295. * @param[in] pSrc is input pointer
  296. * @param[in] blockSize is the number of samples to process
  297. * @param[out] pResult is output value.
  298. */
  299. void riscv_std_f32(
  300. const float32_t * pSrc,
  301. uint32_t blockSize,
  302. float32_t * pResult);
  303. /**
  304. * @brief Standard deviation of the elements of a floating-point vector.
  305. * @param[in] pSrc is input pointer
  306. * @param[in] blockSize is the number of samples to process
  307. * @param[out] pResult is output value.
  308. */
  309. void riscv_std_f64(
  310. const float64_t * pSrc,
  311. uint32_t blockSize,
  312. float64_t * pResult);
  313. /**
  314. * @brief Standard deviation of the elements of a Q31 vector.
  315. * @param[in] pSrc is input pointer
  316. * @param[in] blockSize is the number of samples to process
  317. * @param[out] pResult is output value.
  318. */
  319. void riscv_std_q31(
  320. const q31_t * pSrc,
  321. uint32_t blockSize,
  322. q31_t * pResult);
  323. /**
  324. * @brief Standard deviation of the elements of a Q15 vector.
  325. * @param[in] pSrc is input pointer
  326. * @param[in] blockSize is the number of samples to process
  327. * @param[out] pResult is output value.
  328. */
  329. void riscv_std_q15(
  330. const q15_t * pSrc,
  331. uint32_t blockSize,
  332. q15_t * pResult);
  333. /**
  334. * @brief Minimum value of a Q7 vector.
  335. * @param[in] pSrc is input pointer
  336. * @param[in] blockSize is the number of samples to process
  337. * @param[out] pResult is output pointer
  338. * @param[in] pIndex is the array index of the minimum value in the input buffer.
  339. */
  340. void riscv_min_q7(
  341. const q7_t * pSrc,
  342. uint32_t blockSize,
  343. q7_t * pResult,
  344. uint32_t * pIndex);
  345. /**
  346. * @brief Minimum value of absolute values of a Q7 vector.
  347. * @param[in] pSrc is input pointer
  348. * @param[in] blockSize is the number of samples to process
  349. * @param[out] pResult is output pointer
  350. * @param[in] pIndex is the array index of the minimum value in the input buffer.
  351. */
  352. void riscv_absmin_q7(
  353. const q7_t * pSrc,
  354. uint32_t blockSize,
  355. q7_t * pResult,
  356. uint32_t * pIndex);
  357. /**
  358. * @brief Minimum value of absolute values of a Q7 vector.
  359. * @param[in] pSrc is input pointer
  360. * @param[in] blockSize is the number of samples to process
  361. * @param[out] pResult is output pointer
  362. */
  363. void riscv_absmin_no_idx_q7(
  364. const q7_t * pSrc,
  365. uint32_t blockSize,
  366. q7_t * pResult);
  367. /**
  368. * @brief Minimum value of a Q15 vector.
  369. * @param[in] pSrc is input pointer
  370. * @param[in] blockSize is the number of samples to process
  371. * @param[out] pResult is output pointer
  372. * @param[in] pIndex is the array index of the minimum value in the input buffer.
  373. */
  374. void riscv_min_q15(
  375. const q15_t * pSrc,
  376. uint32_t blockSize,
  377. q15_t * pResult,
  378. uint32_t * pIndex);
  379. /**
  380. * @brief Minimum value of absolute values of a Q15 vector.
  381. * @param[in] pSrc is input pointer
  382. * @param[in] blockSize is the number of samples to process
  383. * @param[out] pResult is output pointer
  384. * @param[in] pIndex is the array index of the minimum value in the input buffer.
  385. */
  386. void riscv_absmin_q15(
  387. const q15_t * pSrc,
  388. uint32_t blockSize,
  389. q15_t * pResult,
  390. uint32_t * pIndex);
  391. /**
  392. * @brief Minimum value of absolute values of a Q15 vector.
  393. * @param[in] pSrc is input pointer
  394. * @param[in] blockSize is the number of samples to process
  395. * @param[out] pResult is output pointer
  396. */
  397. void riscv_absmin_no_idx_q15(
  398. const q15_t * pSrc,
  399. uint32_t blockSize,
  400. q15_t * pResult);
  401. /**
  402. * @brief Minimum value of a Q31 vector.
  403. * @param[in] pSrc is input pointer
  404. * @param[in] blockSize is the number of samples to process
  405. * @param[out] pResult is output pointer
  406. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  407. */
  408. void riscv_min_q31(
  409. const q31_t * pSrc,
  410. uint32_t blockSize,
  411. q31_t * pResult,
  412. uint32_t * pIndex);
  413. /**
  414. * @brief Minimum value of absolute values of a Q31 vector.
  415. * @param[in] pSrc is input pointer
  416. * @param[in] blockSize is the number of samples to process
  417. * @param[out] pResult is output pointer
  418. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  419. */
  420. void riscv_absmin_q31(
  421. const q31_t * pSrc,
  422. uint32_t blockSize,
  423. q31_t * pResult,
  424. uint32_t * pIndex);
  425. /**
  426. * @brief Minimum value of absolute values of a Q31 vector.
  427. * @param[in] pSrc is input pointer
  428. * @param[in] blockSize is the number of samples to process
  429. * @param[out] pResult is output pointer
  430. */
  431. void riscv_absmin_no_idx_q31(
  432. const q31_t * pSrc,
  433. uint32_t blockSize,
  434. q31_t * pResult);
  435. /**
  436. * @brief Minimum value of a floating-point vector.
  437. * @param[in] pSrc is input pointer
  438. * @param[in] blockSize is the number of samples to process
  439. * @param[out] pResult is output pointer
  440. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  441. */
  442. void riscv_min_f32(
  443. const float32_t * pSrc,
  444. uint32_t blockSize,
  445. float32_t * pResult,
  446. uint32_t * pIndex);
  447. /**
  448. * @brief Minimum value of absolute values of a floating-point vector.
  449. * @param[in] pSrc is input pointer
  450. * @param[in] blockSize is the number of samples to process
  451. * @param[out] pResult is output pointer
  452. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  453. */
  454. void riscv_absmin_f32(
  455. const float32_t * pSrc,
  456. uint32_t blockSize,
  457. float32_t * pResult,
  458. uint32_t * pIndex);
  459. /**
  460. * @brief Minimum value of absolute values of a floating-point vector.
  461. * @param[in] pSrc is input pointer
  462. * @param[in] blockSize is the number of samples to process
  463. * @param[out] pResult is output pointer
  464. */
  465. void riscv_absmin_no_idx_f32(
  466. const float32_t * pSrc,
  467. uint32_t blockSize,
  468. float32_t * pResult);
  469. /**
  470. * @brief Minimum value of a floating-point vector.
  471. * @param[in] pSrc is input pointer
  472. * @param[in] blockSize is the number of samples to process
  473. * @param[out] pResult is output pointer
  474. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  475. */
  476. void riscv_min_f64(
  477. const float64_t * pSrc,
  478. uint32_t blockSize,
  479. float64_t * pResult,
  480. uint32_t * pIndex);
  481. /**
  482. * @brief Minimum value of absolute values of a floating-point vector.
  483. * @param[in] pSrc is input pointer
  484. * @param[in] blockSize is the number of samples to process
  485. * @param[out] pResult is output pointer
  486. * @param[out] pIndex is the array index of the minimum value in the input buffer.
  487. */
  488. void riscv_absmin_f64(
  489. const float64_t * pSrc,
  490. uint32_t blockSize,
  491. float64_t * pResult,
  492. uint32_t * pIndex);
  493. /**
  494. * @brief Minimum value of absolute values of a floating-point vector.
  495. * @param[in] pSrc is input pointer
  496. * @param[in] blockSize is the number of samples to process
  497. * @param[out] pResult is output pointer
  498. */
  499. void riscv_absmin_no_idx_f64(
  500. const float64_t * pSrc,
  501. uint32_t blockSize,
  502. float64_t * pResult);
  503. /**
  504. * @brief Maximum value of a Q7 vector.
  505. * @param[in] pSrc points to the input buffer
  506. * @param[in] blockSize length of the input vector
  507. * @param[out] pResult maximum value returned here
  508. * @param[out] pIndex index of maximum value returned here
  509. */
  510. void riscv_max_q7(
  511. const q7_t * pSrc,
  512. uint32_t blockSize,
  513. q7_t * pResult,
  514. uint32_t * pIndex);
  515. /**
  516. * @brief Maximum value of absolute values of a Q7 vector.
  517. * @param[in] pSrc points to the input buffer
  518. * @param[in] blockSize length of the input vector
  519. * @param[out] pResult maximum value returned here
  520. * @param[out] pIndex index of maximum value returned here
  521. */
  522. void riscv_absmax_q7(
  523. const q7_t * pSrc,
  524. uint32_t blockSize,
  525. q7_t * pResult,
  526. uint32_t * pIndex);
  527. /**
  528. * @brief Maximum value of absolute values of a Q7 vector.
  529. * @param[in] pSrc points to the input buffer
  530. * @param[in] blockSize length of the input vector
  531. * @param[out] pResult maximum value returned here
  532. */
  533. void riscv_absmax_no_idx_q7(
  534. const q7_t * pSrc,
  535. uint32_t blockSize,
  536. q7_t * pResult);
  537. /**
  538. * @brief Maximum value of a Q15 vector.
  539. * @param[in] pSrc points to the input buffer
  540. * @param[in] blockSize length of the input vector
  541. * @param[out] pResult maximum value returned here
  542. * @param[out] pIndex index of maximum value returned here
  543. */
  544. void riscv_max_q15(
  545. const q15_t * pSrc,
  546. uint32_t blockSize,
  547. q15_t * pResult,
  548. uint32_t * pIndex);
  549. /**
  550. * @brief Maximum value of absolute values of a Q15 vector.
  551. * @param[in] pSrc points to the input buffer
  552. * @param[in] blockSize length of the input vector
  553. * @param[out] pResult maximum value returned here
  554. * @param[out] pIndex index of maximum value returned here
  555. */
  556. void riscv_absmax_q15(
  557. const q15_t * pSrc,
  558. uint32_t blockSize,
  559. q15_t * pResult,
  560. uint32_t * pIndex);
  561. /**
  562. * @brief Maximum value of absolute values of a Q15 vector.
  563. * @param[in] pSrc points to the input buffer
  564. * @param[in] blockSize length of the input vector
  565. * @param[out] pResult maximum value returned here
  566. */
  567. void riscv_absmax_no_idx_q15(
  568. const q15_t * pSrc,
  569. uint32_t blockSize,
  570. q15_t * pResult);
  571. /**
  572. * @brief Maximum value of a Q31 vector.
  573. * @param[in] pSrc points to the input buffer
  574. * @param[in] blockSize length of the input vector
  575. * @param[out] pResult maximum value returned here
  576. * @param[out] pIndex index of maximum value returned here
  577. */
  578. void riscv_max_q31(
  579. const q31_t * pSrc,
  580. uint32_t blockSize,
  581. q31_t * pResult,
  582. uint32_t * pIndex);
  583. /**
  584. * @brief Maximum value of absolute values of a Q31 vector.
  585. * @param[in] pSrc points to the input buffer
  586. * @param[in] blockSize length of the input vector
  587. * @param[out] pResult maximum value returned here
  588. * @param[out] pIndex index of maximum value returned here
  589. */
  590. void riscv_absmax_q31(
  591. const q31_t * pSrc,
  592. uint32_t blockSize,
  593. q31_t * pResult,
  594. uint32_t * pIndex);
  595. /**
  596. * @brief Maximum value of absolute values of a Q31 vector.
  597. * @param[in] pSrc points to the input buffer
  598. * @param[in] blockSize length of the input vector
  599. * @param[out] pResult maximum value returned here
  600. */
  601. void riscv_absmax_no_idx_q31(
  602. const q31_t * pSrc,
  603. uint32_t blockSize,
  604. q31_t * pResult);
  605. /**
  606. * @brief Maximum value of a floating-point vector.
  607. * @param[in] pSrc points to the input buffer
  608. * @param[in] blockSize length of the input vector
  609. * @param[out] pResult maximum value returned here
  610. * @param[out] pIndex index of maximum value returned here
  611. */
  612. void riscv_max_f32(
  613. const float32_t * pSrc,
  614. uint32_t blockSize,
  615. float32_t * pResult,
  616. uint32_t * pIndex);
  617. /**
  618. * @brief Maximum value of absolute values of a floating-point vector.
  619. * @param[in] pSrc points to the input buffer
  620. * @param[in] blockSize length of the input vector
  621. * @param[out] pResult maximum value returned here
  622. * @param[out] pIndex index of maximum value returned here
  623. */
  624. void riscv_absmax_f32(
  625. const float32_t * pSrc,
  626. uint32_t blockSize,
  627. float32_t * pResult,
  628. uint32_t * pIndex);
  629. /**
  630. * @brief Maximum value of absolute values of a floating-point vector.
  631. * @param[in] pSrc points to the input buffer
  632. * @param[in] blockSize length of the input vector
  633. * @param[out] pResult maximum value returned here
  634. */
  635. void riscv_absmax_no_idx_f32(
  636. const float32_t * pSrc,
  637. uint32_t blockSize,
  638. float32_t * pResult);
  639. /**
  640. * @brief Maximum value of a floating-point vector.
  641. * @param[in] pSrc points to the input buffer
  642. * @param[in] blockSize length of the input vector
  643. * @param[out] pResult maximum value returned here
  644. * @param[out] pIndex index of maximum value returned here
  645. */
  646. void riscv_max_f64(
  647. const float64_t * pSrc,
  648. uint32_t blockSize,
  649. float64_t * pResult,
  650. uint32_t * pIndex);
  651. /**
  652. * @brief Maximum value of absolute values of a floating-point vector.
  653. * @param[in] pSrc points to the input buffer
  654. * @param[in] blockSize length of the input vector
  655. * @param[out] pResult maximum value returned here
  656. * @param[out] pIndex index of maximum value returned here
  657. */
  658. void riscv_absmax_f64(
  659. const float64_t * pSrc,
  660. uint32_t blockSize,
  661. float64_t * pResult,
  662. uint32_t * pIndex);
  663. /**
  664. * @brief Maximum value of absolute values of a floating-point vector.
  665. * @param[in] pSrc points to the input buffer
  666. * @param[in] blockSize length of the input vector
  667. * @param[out] pResult maximum value returned here
  668. */
  669. void riscv_absmax_no_idx_f64(
  670. const float64_t * pSrc,
  671. uint32_t blockSize,
  672. float64_t * pResult);
  673. /**
  674. @brief Maximum value of a floating-point vector.
  675. @param[in] pSrc points to the input vector
  676. @param[in] blockSize number of samples in input vector
  677. @param[out] pResult maximum value returned here
  678. */
  679. void riscv_max_no_idx_f32(
  680. const float32_t *pSrc,
  681. uint32_t blockSize,
  682. float32_t *pResult);
  683. /**
  684. @brief Minimum value of a floating-point vector.
  685. @param[in] pSrc points to the input vector
  686. @param[in] blockSize number of samples in input vector
  687. @param[out] pResult minimum value returned here
  688. */
  689. void riscv_min_no_idx_f32(
  690. const float32_t *pSrc,
  691. uint32_t blockSize,
  692. float32_t *pResult);
  693. /**
  694. @brief Maximum value of a floating-point vector.
  695. @param[in] pSrc points to the input vector
  696. @param[in] blockSize number of samples in input vector
  697. @param[out] pResult maximum value returned here
  698. */
  699. void riscv_max_no_idx_f64(
  700. const float64_t *pSrc,
  701. uint32_t blockSize,
  702. float64_t *pResult);
  703. /**
  704. @brief Maximum value of a q31 vector.
  705. @param[in] pSrc points to the input vector
  706. @param[in] blockSize number of samples in input vector
  707. @param[out] pResult maximum value returned here
  708. */
  709. void riscv_max_no_idx_q31(
  710. const q31_t *pSrc,
  711. uint32_t blockSize,
  712. q31_t *pResult);
  713. /**
  714. @brief Maximum value of a q15 vector.
  715. @param[in] pSrc points to the input vector
  716. @param[in] blockSize number of samples in input vector
  717. @param[out] pResult maximum value returned here
  718. */
  719. void riscv_max_no_idx_q15(
  720. const q15_t *pSrc,
  721. uint32_t blockSize,
  722. q15_t *pResult);
  723. /**
  724. @brief Maximum value of a q7 vector.
  725. @param[in] pSrc points to the input vector
  726. @param[in] blockSize number of samples in input vector
  727. @param[out] pResult maximum value returned here
  728. */
  729. void riscv_max_no_idx_q7(
  730. const q7_t *pSrc,
  731. uint32_t blockSize,
  732. q7_t *pResult);
  733. /**
  734. @brief Minimum value of a floating-point vector.
  735. @param[in] pSrc points to the input vector
  736. @param[in] blockSize number of samples in input vector
  737. @param[out] pResult minimum value returned here
  738. */
  739. void riscv_min_no_idx_f64(
  740. const float64_t *pSrc,
  741. uint32_t blockSize,
  742. float64_t *pResult);
  743. /**
  744. @brief Minimum value of a q31 vector.
  745. @param[in] pSrc points to the input vector
  746. @param[in] blockSize number of samples in input vector
  747. @param[out] pResult minimum value returned here
  748. */
  749. void riscv_min_no_idx_q31(
  750. const q31_t *pSrc,
  751. uint32_t blockSize,
  752. q31_t *pResult);
  753. /**
  754. @brief Minimum value of a q15 vector.
  755. @param[in] pSrc points to the input vector
  756. @param[in] blockSize number of samples in input vector
  757. @param[out] pResult minimum value returned here
  758. */
  759. void riscv_min_no_idx_q15(
  760. const q15_t *pSrc,
  761. uint32_t blockSize,
  762. q15_t *pResult);
  763. /**
  764. @brief Minimum value of a q7 vector.
  765. @param[in] pSrc points to the input vector
  766. @param[in] blockSize number of samples in input vector
  767. @param[out] pResult minimum value returned here
  768. */
  769. void riscv_min_no_idx_q7(
  770. const q7_t *pSrc,
  771. uint32_t blockSize,
  772. q7_t *pResult);
  773. /**
  774. @brief Mean square error between two Q7 vectors.
  775. @param[in] pSrcA points to the first input vector
  776. @param[in] pSrcB points to the second input vector
  777. @param[in] blockSize number of samples in input vector
  778. @param[out] pResult mean square error
  779. */
  780. void riscv_mse_q7(
  781. const q7_t * pSrcA,
  782. const q7_t * pSrcB,
  783. uint32_t blockSize,
  784. q7_t * pResult);
  785. /**
  786. @brief Mean square error between two Q15 vectors.
  787. @param[in] pSrcA points to the first input vector
  788. @param[in] pSrcB points to the second input vector
  789. @param[in] blockSize number of samples in input vector
  790. @param[out] pResult mean square error
  791. */
  792. void riscv_mse_q15(
  793. const q15_t * pSrcA,
  794. const q15_t * pSrcB,
  795. uint32_t blockSize,
  796. q15_t * pResult);
  797. /**
  798. @brief Mean square error between two Q31 vectors.
  799. @param[in] pSrcA points to the first input vector
  800. @param[in] pSrcB points to the second input vector
  801. @param[in] blockSize number of samples in input vector
  802. @param[out] pResult mean square error
  803. */
  804. void riscv_mse_q31(
  805. const q31_t * pSrcA,
  806. const q31_t * pSrcB,
  807. uint32_t blockSize,
  808. q31_t * pResult);
  809. /**
  810. @brief Mean square error between two single precision float vectors.
  811. @param[in] pSrcA points to the first input vector
  812. @param[in] pSrcB points to the second input vector
  813. @param[in] blockSize number of samples in input vector
  814. @param[out] pResult mean square error
  815. */
  816. void riscv_mse_f32(
  817. const float32_t * pSrcA,
  818. const float32_t * pSrcB,
  819. uint32_t blockSize,
  820. float32_t * pResult);
  821. /**
  822. @brief Mean square error between two double precision float vectors.
  823. @param[in] pSrcA points to the first input vector
  824. @param[in] pSrcB points to the second input vector
  825. @param[in] blockSize number of samples in input vector
  826. @param[out] pResult mean square error
  827. */
  828. void riscv_mse_f64(
  829. const float64_t * pSrcA,
  830. const float64_t * pSrcB,
  831. uint32_t blockSize,
  832. float64_t * pResult);
  833. /**
  834. * @brief Accumulation value of a floating-point vector.
  835. * @param[in] pSrc is input pointer
  836. * @param[in] blockSize is the number of samples to process
  837. * @param[out] pResult is output value.
  838. */
  839. void riscv_accumulate_f32(
  840. const float32_t * pSrc,
  841. uint32_t blockSize,
  842. float32_t * pResult);
  843. /**
  844. * @brief Accumulation value of a floating-point vector.
  845. * @param[in] pSrc is input pointer
  846. * @param[in] blockSize is the number of samples to process
  847. * @param[out] pResult is output value.
  848. */
  849. void riscv_accumulate_f64(
  850. const float64_t * pSrc,
  851. uint32_t blockSize,
  852. float64_t * pResult);
  853. #ifdef __cplusplus
  854. }
  855. #endif
  856. #endif /* ifndef _STATISTICS_FUNCTIONS_H_ */