fast_math_functions_f16.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /******************************************************************************
  2. * @file fast_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 FAST_MATH_FUNCTIONS_F16_H_
  27. #define FAST_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. /* For sqrt_f32 */
  33. #include "dsp/fast_math_functions.h"
  34. #ifdef __cplusplus
  35. extern "C"
  36. {
  37. #endif
  38. #if defined(RISCV_FLOAT16_SUPPORTED)
  39. /**
  40. * @addtogroup SQRT
  41. * @{
  42. */
  43. /**
  44. @brief Floating-point square root function.
  45. @param[in] in input value
  46. @param[out] pOut square root of input value
  47. @return execution status
  48. - \ref RISCV_MATH_SUCCESS : input value is positive
  49. - \ref RISCV_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0
  50. */
  51. __STATIC_FORCEINLINE riscv_status riscv_sqrt_f16(
  52. float16_t in,
  53. float16_t * pOut)
  54. {
  55. float32_t r;
  56. riscv_status status;
  57. status=riscv_sqrt_f32((float32_t)in,&r);
  58. *pOut=(float16_t)r;
  59. return(status);
  60. }
  61. /**
  62. @} end of SQRT group
  63. */
  64. /**
  65. @brief Floating-point vector of log values.
  66. @param[in] pSrc points to the input vector
  67. @param[out] pDst points to the output vector
  68. @param[in] blockSize number of samples in each vector
  69. */
  70. void riscv_vlog_f16(
  71. const float16_t * pSrc,
  72. float16_t * pDst,
  73. uint32_t blockSize);
  74. /**
  75. @brief Floating-point vector of exp values.
  76. @param[in] pSrc points to the input vector
  77. @param[out] pDst points to the output vector
  78. @param[in] blockSize number of samples in each vector
  79. */
  80. void riscv_vexp_f16(
  81. const float16_t * pSrc,
  82. float16_t * pDst,
  83. uint32_t blockSize);
  84. /**
  85. @brief Floating-point vector of inverse values.
  86. @param[in] pSrc points to the input vector
  87. @param[out] pDst points to the output vector
  88. @param[in] blockSize number of samples in each vector
  89. */
  90. void riscv_vinverse_f16(
  91. const float16_t * pSrc,
  92. float16_t * pDst,
  93. uint32_t blockSize);
  94. /**
  95. @brief Arc tangent in radian of y/x using sign of x and y to determine right quadrant.
  96. @param[in] y y coordinate
  97. @param[in] x x coordinate
  98. @param[out] result Result
  99. @return error status.
  100. */
  101. riscv_status riscv_atan2_f16(float16_t y,float16_t x,float16_t *result);
  102. #endif /*defined(RISCV_FLOAT16_SUPPORTED)*/
  103. #ifdef __cplusplus
  104. }
  105. #endif
  106. #endif /* ifndef _FAST_MATH_FUNCTIONS_F16_H_ */