distance_functions_f16.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /******************************************************************************
  2. * @file distance_functions_f16.h
  3. * @brief Public header file for CMSIS DSP Library
  4. * @version V1.10.0
  5. * @date 08 July 2021
  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. #ifndef _DISTANCE_FUNCTIONS_F16_H_
  26. #define _DISTANCE_FUNCTIONS_F16_H_
  27. #include "arm_math_types_f16.h"
  28. #include "arm_math_memory.h"
  29. #include "dsp/none.h"
  30. #include "dsp/utils.h"
  31. /* 6.14 bug */
  32. #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) && (__ARMCC_VERSION < 6150001)
  33. /* Defined in minkowski_f32 */
  34. __attribute__((weak)) float __powisf2(float a, int b);
  35. #endif
  36. #include "dsp/statistics_functions_f16.h"
  37. #include "dsp/basic_math_functions_f16.h"
  38. #include "dsp/fast_math_functions_f16.h"
  39. #ifdef __cplusplus
  40. extern "C"
  41. {
  42. #endif
  43. #if defined(ARM_FLOAT16_SUPPORTED)
  44. /**
  45. * @brief Euclidean distance between two vectors
  46. * @param[in] pA First vector
  47. * @param[in] pB Second vector
  48. * @param[in] blockSize vector length
  49. * @return distance
  50. *
  51. */
  52. float16_t arm_euclidean_distance_f16(const float16_t *pA,const float16_t *pB, uint32_t blockSize);
  53. /**
  54. * @brief Bray-Curtis distance between two vectors
  55. * @param[in] pA First vector
  56. * @param[in] pB Second vector
  57. * @param[in] blockSize vector length
  58. * @return distance
  59. *
  60. */
  61. float16_t arm_braycurtis_distance_f16(const float16_t *pA,const float16_t *pB, uint32_t blockSize);
  62. /**
  63. * @brief Canberra distance between two vectors
  64. *
  65. * This function may divide by zero when samples pA[i] and pB[i] are both zero.
  66. * The result of the computation will be correct. So the division per zero may be
  67. * ignored.
  68. *
  69. * @param[in] pA First vector
  70. * @param[in] pB Second vector
  71. * @param[in] blockSize vector length
  72. * @return distance
  73. *
  74. */
  75. float16_t arm_canberra_distance_f16(const float16_t *pA,const float16_t *pB, uint32_t blockSize);
  76. /**
  77. * @brief Chebyshev distance between two vectors
  78. * @param[in] pA First vector
  79. * @param[in] pB Second vector
  80. * @param[in] blockSize vector length
  81. * @return distance
  82. *
  83. */
  84. float16_t arm_chebyshev_distance_f16(const float16_t *pA,const float16_t *pB, uint32_t blockSize);
  85. /**
  86. * @brief Cityblock (Manhattan) distance between two vectors
  87. * @param[in] pA First vector
  88. * @param[in] pB Second vector
  89. * @param[in] blockSize vector length
  90. * @return distance
  91. *
  92. */
  93. float16_t arm_cityblock_distance_f16(const float16_t *pA,const float16_t *pB, uint32_t blockSize);
  94. /**
  95. * @brief Correlation distance between two vectors
  96. *
  97. * The input vectors are modified in place !
  98. *
  99. * @param[in] pA First vector
  100. * @param[in] pB Second vector
  101. * @param[in] blockSize vector length
  102. * @return distance
  103. *
  104. */
  105. float16_t arm_correlation_distance_f16(float16_t *pA,float16_t *pB, uint32_t blockSize);
  106. /**
  107. * @brief Cosine distance between two vectors
  108. *
  109. * @param[in] pA First vector
  110. * @param[in] pB Second vector
  111. * @param[in] blockSize vector length
  112. * @return distance
  113. *
  114. */
  115. float16_t arm_cosine_distance_f16(const float16_t *pA,const float16_t *pB, uint32_t blockSize);
  116. /**
  117. * @brief Jensen-Shannon distance between two vectors
  118. *
  119. * This function is assuming that elements of second vector are > 0
  120. * and 0 only when the corresponding element of first vector is 0.
  121. * Otherwise the result of the computation does not make sense
  122. * and for speed reasons, the cases returning NaN or Infinity are not
  123. * managed.
  124. *
  125. * When the function is computing x log (x / y) with x 0 and y 0,
  126. * it will compute the right value (0) but a division per zero will occur
  127. * and shoudl be ignored in client code.
  128. *
  129. * @param[in] pA First vector
  130. * @param[in] pB Second vector
  131. * @param[in] blockSize vector length
  132. * @return distance
  133. *
  134. */
  135. float16_t arm_jensenshannon_distance_f16(const float16_t *pA,const float16_t *pB,uint32_t blockSize);
  136. /**
  137. * @brief Minkowski distance between two vectors
  138. *
  139. * @param[in] pA First vector
  140. * @param[in] pB Second vector
  141. * @param[in] n Norm order (>= 2)
  142. * @param[in] blockSize vector length
  143. * @return distance
  144. *
  145. */
  146. float16_t arm_minkowski_distance_f16(const float16_t *pA,const float16_t *pB, int32_t order, uint32_t blockSize);
  147. #endif /*defined(ARM_FLOAT16_SUPPORTED)*/
  148. #ifdef __cplusplus
  149. }
  150. #endif
  151. #endif /* ifndef _DISTANCE_FUNCTIONS_F16_H_ */