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