Aded CMSIS5 DSP and NN folder. Needs some work
Embed:
(wiki syntax)
Show/hide line numbers
arm_cmplx_mag_squared_q15.c
00001 /* ---------------------------------------------------------------------- 00002 * Project: CMSIS DSP Library 00003 * Title: arm_cmplx_mag_squared_q15.c 00004 * Description: Q15 complex magnitude squared 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_squared 00037 * @{ 00038 */ 00039 00040 /** 00041 * @brief Q15 complex magnitude squared 00042 * @param *pSrc points to the complex input vector 00043 * @param *pDst points to the real output vector 00044 * @param numSamples number of complex samples in the input vector 00045 * @return none. 00046 * 00047 * <b>Scaling and Overflow Behavior:</b> 00048 * \par 00049 * The function implements 1.15 by 1.15 multiplications and finally output is converted into 3.13 format. 00050 */ 00051 00052 void arm_cmplx_mag_squared_q15( 00053 q15_t * pSrc, 00054 q15_t * pDst, 00055 uint32_t numSamples) 00056 { 00057 q31_t acc0, acc1; /* Accumulators */ 00058 00059 #if defined (ARM_MATH_DSP) 00060 00061 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00062 uint32_t blkCnt; /* loop counter */ 00063 q31_t in1, in2, in3, in4; 00064 q31_t acc2, acc3; 00065 00066 /*loop Unrolling */ 00067 blkCnt = numSamples >> 2U; 00068 00069 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00070 ** a second loop below computes the remaining 1 to 3 samples. */ 00071 while (blkCnt > 0U) 00072 { 00073 /* C[0] = (A[0] * A[0] + A[1] * A[1]) */ 00074 in1 = *__SIMD32(pSrc)++; 00075 in2 = *__SIMD32(pSrc)++; 00076 in3 = *__SIMD32(pSrc)++; 00077 in4 = *__SIMD32(pSrc)++; 00078 00079 acc0 = __SMUAD(in1, in1); 00080 acc1 = __SMUAD(in2, in2); 00081 acc2 = __SMUAD(in3, in3); 00082 acc3 = __SMUAD(in4, in4); 00083 00084 /* store the result in 3.13 format in the destination buffer. */ 00085 *pDst++ = (q15_t) (acc0 >> 17); 00086 *pDst++ = (q15_t) (acc1 >> 17); 00087 *pDst++ = (q15_t) (acc2 >> 17); 00088 *pDst++ = (q15_t) (acc3 >> 17); 00089 00090 /* Decrement the loop counter */ 00091 blkCnt--; 00092 } 00093 00094 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00095 ** No loop unrolling is used. */ 00096 blkCnt = numSamples % 0x4U; 00097 00098 while (blkCnt > 0U) 00099 { 00100 /* C[0] = (A[0] * A[0] + A[1] * A[1]) */ 00101 in1 = *__SIMD32(pSrc)++; 00102 acc0 = __SMUAD(in1, in1); 00103 00104 /* store the result in 3.13 format in the destination buffer. */ 00105 *pDst++ = (q15_t) (acc0 >> 17); 00106 00107 /* Decrement the loop counter */ 00108 blkCnt--; 00109 } 00110 00111 #else 00112 00113 /* Run the below code for Cortex-M0 */ 00114 q15_t real, imag; /* Temporary variables to store real and imaginary values */ 00115 00116 while (numSamples > 0U) 00117 { 00118 /* out = ((real * real) + (imag * imag)) */ 00119 real = *pSrc++; 00120 imag = *pSrc++; 00121 acc0 = (real * real); 00122 acc1 = (imag * imag); 00123 /* store the result in 3.13 format in the destination buffer. */ 00124 *pDst++ = (q15_t) (((q63_t) acc0 + acc1) >> 17); 00125 00126 /* Decrement the loop counter */ 00127 numSamples--; 00128 } 00129 00130 #endif /* #if defined (ARM_MATH_DSP) */ 00131 00132 } 00133 00134 /** 00135 * @} end of cmplx_mag_squared group 00136 */ 00137
Generated on Tue Jul 12 2022 16:46:23 by 1.7.2