Aded CMSIS5 DSP and NN folder. Needs some work
Embed:
(wiki syntax)
Show/hide line numbers
arm_cmplx_mag_q15.c
00001 /* ---------------------------------------------------------------------- 00002 * Project: CMSIS DSP Library 00003 * Title: arm_cmplx_mag_q15.c 00004 * Description: Q15 complex magnitude 00005 * 00006 * $Date: 27. January 2017 00007 * $Revision: V.1.5.1 00008 * 00009 * Target Processor: Cortex-M cores 00010 * -------------------------------------------------------------------- */ 00011 /* 00012 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. 00013 * 00014 * SPDX-License-Identifier: Apache-2.0 00015 * 00016 * Licensed under the Apache License, Version 2.0 (the License); you may 00017 * not use this file except in compliance with the License. 00018 * You may obtain a copy of the License at 00019 * 00020 * www.apache.org/licenses/LICENSE-2.0 00021 * 00022 * Unless required by applicable law or agreed to in writing, software 00023 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00024 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00025 * See the License for the specific language governing permissions and 00026 * limitations under the License. 00027 */ 00028 00029 #include "arm_math.h" 00030 00031 /** 00032 * @ingroup groupCmplxMath 00033 */ 00034 00035 /** 00036 * @addtogroup cmplx_mag 00037 * @{ 00038 */ 00039 00040 00041 /** 00042 * @brief Q15 complex magnitude 00043 * @param *pSrc points to the complex input vector 00044 * @param *pDst points to the real output vector 00045 * @param numSamples number of complex samples in the input vector 00046 * @return none. 00047 * 00048 * <b>Scaling and Overflow Behavior:</b> 00049 * \par 00050 * The function implements 1.15 by 1.15 multiplications and finally output is converted into 2.14 format. 00051 */ 00052 00053 void arm_cmplx_mag_q15( 00054 q15_t * pSrc, 00055 q15_t * pDst, 00056 uint32_t numSamples) 00057 { 00058 q31_t acc0, acc1; /* Accumulators */ 00059 00060 #if defined (ARM_MATH_DSP) 00061 00062 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00063 uint32_t blkCnt; /* loop counter */ 00064 q31_t in1, in2, in3, in4; 00065 q31_t acc2, acc3; 00066 00067 00068 /*loop Unrolling */ 00069 blkCnt = numSamples >> 2U; 00070 00071 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00072 ** a second loop below computes the remaining 1 to 3 samples. */ 00073 while (blkCnt > 0U) 00074 { 00075 00076 /* C[0] = sqrt(A[0] * A[0] + A[1] * A[1]) */ 00077 in1 = *__SIMD32(pSrc)++; 00078 in2 = *__SIMD32(pSrc)++; 00079 in3 = *__SIMD32(pSrc)++; 00080 in4 = *__SIMD32(pSrc)++; 00081 00082 acc0 = __SMUAD(in1, in1); 00083 acc1 = __SMUAD(in2, in2); 00084 acc2 = __SMUAD(in3, in3); 00085 acc3 = __SMUAD(in4, in4); 00086 00087 /* store the result in 2.14 format in the destination buffer. */ 00088 arm_sqrt_q15((q15_t) ((acc0) >> 17), pDst++); 00089 arm_sqrt_q15((q15_t) ((acc1) >> 17), pDst++); 00090 arm_sqrt_q15((q15_t) ((acc2) >> 17), pDst++); 00091 arm_sqrt_q15((q15_t) ((acc3) >> 17), pDst++); 00092 00093 /* Decrement the loop counter */ 00094 blkCnt--; 00095 } 00096 00097 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00098 ** No loop unrolling is used. */ 00099 blkCnt = numSamples % 0x4U; 00100 00101 while (blkCnt > 0U) 00102 { 00103 /* C[0] = sqrt(A[0] * A[0] + A[1] * A[1]) */ 00104 in1 = *__SIMD32(pSrc)++; 00105 acc0 = __SMUAD(in1, in1); 00106 00107 /* store the result in 2.14 format in the destination buffer. */ 00108 arm_sqrt_q15((q15_t) (acc0 >> 17), pDst++); 00109 00110 /* Decrement the loop counter */ 00111 blkCnt--; 00112 } 00113 00114 #else 00115 00116 /* Run the below code for Cortex-M0 */ 00117 q15_t real, imag; /* Temporary variables to hold input values */ 00118 00119 while (numSamples > 0U) 00120 { 00121 /* out = sqrt(real * real + imag * imag) */ 00122 real = *pSrc++; 00123 imag = *pSrc++; 00124 00125 acc0 = (real * real); 00126 acc1 = (imag * imag); 00127 00128 /* store the result in 2.14 format in the destination buffer. */ 00129 arm_sqrt_q15((q15_t) (((q63_t) acc0 + acc1) >> 17), pDst++); 00130 00131 /* Decrement the loop counter */ 00132 numSamples--; 00133 } 00134 00135 #endif /* #if defined (ARM_MATH_DSP) */ 00136 00137 } 00138 00139 /** 00140 * @} end of cmplx_mag group 00141 */ 00142
Generated on Tue Jul 12 2022 16:46:23 by 1.7.2