arm_vlog_f32.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. /**
  31. @ingroup groupFastMath
  32. */
  33. /**
  34. @defgroup vlog Vector Log
  35. Compute the log values of a vector of samples.
  36. */
  37. /**
  38. @addtogroup vlog
  39. @{
  40. */
  41. #if (defined(ARM_MATH_MVEF) || defined(ARM_MATH_HELIUM) || defined(ARM_MATH_NEON) || defined(ARM_MATH_NEON_EXPERIMENTAL)) && !defined(ARM_MATH_AUTOVECTORIZE)
  42. #include "arm_vec_math.h"
  43. #endif
  44. void arm_vlog_f32(
  45. const float32_t * pSrc,
  46. float32_t * pDst,
  47. uint32_t blockSize)
  48. {
  49. uint32_t blkCnt;
  50. #if (defined(ARM_MATH_MVEF) || defined(ARM_MATH_HELIUM)) && !defined(ARM_MATH_AUTOVECTORIZE)
  51. f32x4_t src;
  52. f32x4_t dst;
  53. blkCnt = blockSize >> 2;
  54. while (blkCnt > 0U)
  55. {
  56. src = vld1q(pSrc);
  57. dst = vlogq_f32(src);
  58. vst1q(pDst, dst);
  59. pSrc += 4;
  60. pDst += 4;
  61. /* Decrement loop counter */
  62. blkCnt--;
  63. }
  64. blkCnt = blockSize & 3;
  65. #else
  66. #if (defined(ARM_MATH_NEON) || defined(ARM_MATH_NEON_EXPERIMENTAL)) && !defined(ARM_MATH_AUTOVECTORIZE)
  67. f32x4_t src;
  68. f32x4_t dst;
  69. blkCnt = blockSize >> 2;
  70. while (blkCnt > 0U)
  71. {
  72. src = vld1q_f32(pSrc);
  73. dst = vlogq_f32(src);
  74. vst1q_f32(pDst, dst);
  75. pSrc += 4;
  76. pDst += 4;
  77. /* Decrement loop counter */
  78. blkCnt--;
  79. }
  80. blkCnt = blockSize & 3;
  81. #else
  82. blkCnt = blockSize;
  83. #endif
  84. #endif
  85. while (blkCnt > 0U)
  86. {
  87. /* C = log(A) */
  88. /* Calculate log and store result in destination buffer. */
  89. *pDst++ = logf(*pSrc++);
  90. /* Decrement loop counter */
  91. blkCnt--;
  92. }
  93. }
  94. /**
  95. @} end of vlog group
  96. */