arm_vexp_f32.c
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 void arm_vexp_f32( 37 const float32_t * pSrc, 38 float32_t * pDst, 39 uint32_t blockSize) 40 { 41 uint32_t blkCnt; 42 43 #if (defined(ARM_MATH_MVEF) || defined(ARM_MATH_HELIUM)) && !defined(ARM_MATH_AUTOVECTORIZE) 44 f32x4_t src; 45 f32x4_t dst; 46 47 blkCnt = blockSize >> 2; 48 49 while (blkCnt > 0U) 50 { 51 src = vld1q(pSrc); 52 dst = vexpq_f32(src); 53 vst1q(pDst, dst); 54 55 pSrc += 4; 56 pDst += 4; 57 /* Decrement loop counter */ 58 blkCnt--; 59 } 60 61 blkCnt = blockSize & 3; 62 #else 63 #if (defined(ARM_MATH_NEON) || defined(ARM_MATH_NEON_EXPERIMENTAL)) && !defined(ARM_MATH_AUTOVECTORIZE) 64 f32x4_t src; 65 f32x4_t dst; 66 67 blkCnt = blockSize >> 2; 68 69 while (blkCnt > 0U) 70 { 71 src = vld1q_f32(pSrc); 72 dst = vexpq_f32(src); 73 vst1q_f32(pDst, dst); 74 75 pSrc += 4; 76 pDst += 4; 77 /* Decrement loop counter */ 78 blkCnt--; 79 } 80 81 blkCnt = blockSize & 3; 82 #else 83 blkCnt = blockSize; 84 #endif 85 #endif 86 87 while (blkCnt > 0U) 88 { 89 /* C = log(A) */ 90 91 /* Calculate log and store result in destination buffer. */ 92 *pDst++ = expf(*pSrc++); 93 94 /* Decrement loop counter */ 95 blkCnt--; 96 } 97 }