arm_vexp_f32.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_vlog_f32.c
  4. * Description: Fast vectorized log
  5. *
  6. * $Date: 23 April 2021
  7. * $Revision: V1.9.0
  8. *
  9. * Target Processor: Cortex-M and Cortex-A cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
  13. *
  14. * SPDX-License-Identifier: Apache-2.0
  15. *
  16. * Licensed under the Apache License, Version 2.0 (the License); you may
  17. * not use this file except in compliance with the License.
  18. * You may obtain a copy of the License at
  19. *
  20. * www.apache.org/licenses/LICENSE-2.0
  21. *
  22. * Unless required by applicable law or agreed to in writing, software
  23. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  24. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  25. * See the License for the specific language governing permissions and
  26. * limitations under the License.
  27. */
  28. #include "dsp/fast_math_functions.h"
  29. #include "arm_common_tables.h"
  30. #if (defined(ARM_MATH_MVEF) || defined(ARM_MATH_HELIUM) || defined(ARM_MATH_NEON) || defined(ARM_MATH_NEON_EXPERIMENTAL)) && !defined(ARM_MATH_AUTOVECTORIZE)
  31. #include "arm_vec_math.h"
  32. #endif
  33. /**
  34. @ingroup groupFastMath
  35. */
  36. /**
  37. @defgroup vexp Vector Exponential
  38. Compute the exp values of a vector of samples.
  39. */
  40. /**
  41. @addtogroup vexp
  42. @{
  43. */
  44. /**
  45. @brief Floating-point vector of exp values.
  46. @param[in] pSrc points to the input vector
  47. @param[out] pDst points to the output vector
  48. @param[in] blockSize number of samples in each vector
  49. */
  50. void arm_vexp_f32(
  51. const float32_t * pSrc,
  52. float32_t * pDst,
  53. uint32_t blockSize)
  54. {
  55. uint32_t blkCnt;
  56. #if (defined(ARM_MATH_MVEF) || defined(ARM_MATH_HELIUM)) && !defined(ARM_MATH_AUTOVECTORIZE)
  57. f32x4_t src;
  58. f32x4_t dst;
  59. blkCnt = blockSize >> 2;
  60. while (blkCnt > 0U)
  61. {
  62. src = vld1q(pSrc);
  63. dst = vexpq_f32(src);
  64. vst1q(pDst, dst);
  65. pSrc += 4;
  66. pDst += 4;
  67. /* Decrement loop counter */
  68. blkCnt--;
  69. }
  70. blkCnt = blockSize & 3;
  71. #else
  72. #if (defined(ARM_MATH_NEON) || defined(ARM_MATH_NEON_EXPERIMENTAL)) && !defined(ARM_MATH_AUTOVECTORIZE)
  73. f32x4_t src;
  74. f32x4_t dst;
  75. blkCnt = blockSize >> 2;
  76. while (blkCnt > 0U)
  77. {
  78. src = vld1q_f32(pSrc);
  79. dst = vexpq_f32(src);
  80. vst1q_f32(pDst, dst);
  81. pSrc += 4;
  82. pDst += 4;
  83. /* Decrement loop counter */
  84. blkCnt--;
  85. }
  86. blkCnt = blockSize & 3;
  87. #else
  88. blkCnt = blockSize;
  89. #endif
  90. #endif
  91. while (blkCnt > 0U)
  92. {
  93. /* C = log(A) */
  94. /* Calculate log and store result in destination buffer. */
  95. *pDst++ = expf(*pSrc++);
  96. /* Decrement loop counter */
  97. blkCnt--;
  98. }
  99. }
  100. /**
  101. @} end of vexp group
  102. */