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