basic_math_functions_f16.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /******************************************************************************
  2. * @file basic_math_functions_f16.h
  3. * @brief Public header file for NMSIS DSP Library
  4. * @version V1.10.0
  5. * @date 08 July 2021
  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 BASIC_MATH_FUNCTIONS_F16_H_
  27. #define BASIC_MATH_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. #ifdef __cplusplus
  33. extern "C"
  34. {
  35. #endif
  36. #if defined(RISCV_FLOAT16_SUPPORTED)
  37. /**
  38. * @brief Floating-point vector addition.
  39. * @param[in] pSrcA points to the first input vector
  40. * @param[in] pSrcB points to the second input vector
  41. * @param[out] pDst points to the output vector
  42. * @param[in] blockSize number of samples in each vector
  43. */
  44. void riscv_add_f16(
  45. const float16_t * pSrcA,
  46. const float16_t * pSrcB,
  47. float16_t * pDst,
  48. uint32_t blockSize);
  49. /**
  50. * @brief Floating-point vector subtraction.
  51. * @param[in] pSrcA points to the first input vector
  52. * @param[in] pSrcB points to the second input vector
  53. * @param[out] pDst points to the output vector
  54. * @param[in] blockSize number of samples in each vector
  55. */
  56. void riscv_sub_f16(
  57. const float16_t * pSrcA,
  58. const float16_t * pSrcB,
  59. float16_t * pDst,
  60. uint32_t blockSize);
  61. /**
  62. * @brief Multiplies a floating-point vector by a scalar.
  63. * @param[in] pSrc points to the input vector
  64. * @param[in] scale scale factor to be applied
  65. * @param[out] pDst points to the output vector
  66. * @param[in] blockSize number of samples in the vector
  67. */
  68. void riscv_scale_f16(
  69. const float16_t * pSrc,
  70. float16_t scale,
  71. float16_t * pDst,
  72. uint32_t blockSize);
  73. /**
  74. * @brief Floating-point vector absolute value.
  75. * @param[in] pSrc points to the input buffer
  76. * @param[out] pDst points to the output buffer
  77. * @param[in] blockSize number of samples in each vector
  78. */
  79. void riscv_abs_f16(
  80. const float16_t * pSrc,
  81. float16_t * pDst,
  82. uint32_t blockSize);
  83. /**
  84. * @brief Adds a constant offset to a floating-point vector.
  85. * @param[in] pSrc points to the input vector
  86. * @param[in] offset is the offset to be added
  87. * @param[out] pDst points to the output vector
  88. * @param[in] blockSize number of samples in the vector
  89. */
  90. void riscv_offset_f16(
  91. const float16_t * pSrc,
  92. float16_t offset,
  93. float16_t * pDst,
  94. uint32_t blockSize);
  95. /**
  96. * @brief Dot product of floating-point vectors.
  97. * @param[in] pSrcA points to the first input vector
  98. * @param[in] pSrcB points to the second input vector
  99. * @param[in] blockSize number of samples in each vector
  100. * @param[out] result output result returned here
  101. */
  102. void riscv_dot_prod_f16(
  103. const float16_t * pSrcA,
  104. const float16_t * pSrcB,
  105. uint32_t blockSize,
  106. float16_t * result);
  107. /**
  108. * @brief Floating-point vector multiplication.
  109. * @param[in] pSrcA points to the first input vector
  110. * @param[in] pSrcB points to the second input vector
  111. * @param[out] pDst points to the output vector
  112. * @param[in] blockSize number of samples in each vector
  113. */
  114. void riscv_mult_f16(
  115. const float16_t * pSrcA,
  116. const float16_t * pSrcB,
  117. float16_t * pDst,
  118. uint32_t blockSize);
  119. /**
  120. * @brief Negates the elements of a floating-point vector.
  121. * @param[in] pSrc points to the input vector
  122. * @param[out] pDst points to the output vector
  123. * @param[in] blockSize number of samples in the vector
  124. */
  125. void riscv_negate_f16(
  126. const float16_t * pSrc,
  127. float16_t * pDst,
  128. uint32_t blockSize);
  129. /**
  130. @brief Elementwise floating-point clipping
  131. @param[in] pSrc points to input values
  132. @param[out] pDst points to output clipped values
  133. @param[in] low lower bound
  134. @param[in] high higher bound
  135. @param[in] numSamples number of samples to clip
  136. */
  137. void riscv_clip_f16(const float16_t * pSrc,
  138. float16_t * pDst,
  139. float16_t low,
  140. float16_t high,
  141. uint32_t numSamples);
  142. #endif /* defined(RISCV_FLOAT16_SUPPORTED)*/
  143. #ifdef __cplusplus
  144. }
  145. #endif
  146. #endif /* ifndef _BASIC_MATH_FUNCTIONS_F16_H_ */