arm_vlog_f32.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_vlog_f32.c
  4. * Description: Fast vectorized log
  5. *
  6. * $Date: 15. Octoboer 2019
  7. * $Revision: V1.6.0
  8. *
  9. * Target Processor: Cortex-M cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2019 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 "arm_math.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. void arm_vlog_f32(
  34. const float32_t * pSrc,
  35. float32_t * pDst,
  36. uint32_t blockSize)
  37. {
  38. uint32_t blkCnt;
  39. #if (defined(ARM_MATH_MVEF) || defined(ARM_MATH_HELIUM)) && !defined(ARM_MATH_AUTOVECTORIZE)
  40. f32x4_t src;
  41. f32x4_t dst;
  42. blkCnt = blockSize >> 2;
  43. while (blkCnt > 0U)
  44. {
  45. src = vld1q(pSrc);
  46. dst = vlogq_f32(src);
  47. vst1q(pDst, dst);
  48. pSrc += 4;
  49. pDst += 4;
  50. /* Decrement loop counter */
  51. blkCnt--;
  52. }
  53. blkCnt = blockSize & 3;
  54. #else
  55. #if (defined(ARM_MATH_NEON) || defined(ARM_MATH_NEON_EXPERIMENTAL)) && !defined(ARM_MATH_AUTOVECTORIZE)
  56. f32x4_t src;
  57. f32x4_t dst;
  58. blkCnt = blockSize >> 2;
  59. while (blkCnt > 0U)
  60. {
  61. src = vld1q_f32(pSrc);
  62. dst = vlogq_f32(src);
  63. vst1q_f32(pDst, dst);
  64. pSrc += 4;
  65. pDst += 4;
  66. /* Decrement loop counter */
  67. blkCnt--;
  68. }
  69. blkCnt = blockSize & 3;
  70. #else
  71. blkCnt = blockSize;
  72. #endif
  73. #endif
  74. while (blkCnt > 0U)
  75. {
  76. /* C = log(A) */
  77. /* Calculate log and store result in destination buffer. */
  78. *pDst++ = logf(*pSrc++);
  79. /* Decrement loop counter */
  80. blkCnt--;
  81. }
  82. }