Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
arm_cmplx_mult_cmplx_q15.c
00001 /* ---------------------------------------------------------------------- 00002 * Project: CMSIS DSP Library 00003 * Title: arm_cmplx_mult_cmplx_q15.c 00004 * Description: Q15 complex-by-complex multiplication 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 CmplxByCmplxMult 00037 * @{ 00038 */ 00039 00040 /** 00041 * @brief Q15 complex-by-complex multiplication 00042 * @param[in] *pSrcA points to the first input vector 00043 * @param[in] *pSrcB points to the second input vector 00044 * @param[out] *pDst points to the output vector 00045 * @param[in] numSamples number of complex samples in each 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 3.13 format. 00051 */ 00052 00053 void arm_cmplx_mult_cmplx_q15( 00054 q15_t * pSrcA, 00055 q15_t * pSrcB, 00056 q15_t * pDst, 00057 uint32_t numSamples) 00058 { 00059 q15_t a, b, c, d; /* Temporary variables to store real and imaginary values */ 00060 00061 #if defined (ARM_MATH_DSP) 00062 00063 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00064 uint32_t blkCnt; /* loop counters */ 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[2 * i] = A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1]. */ 00074 /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i]. */ 00075 a = *pSrcA++; 00076 b = *pSrcA++; 00077 c = *pSrcB++; 00078 d = *pSrcB++; 00079 00080 /* store the result in 3.13 format in the destination buffer. */ 00081 *pDst++ = 00082 (q15_t) (q31_t) (((q31_t) a * c) >> 17) - (((q31_t) b * d) >> 17); 00083 /* store the result in 3.13 format in the destination buffer. */ 00084 *pDst++ = 00085 (q15_t) (q31_t) (((q31_t) a * d) >> 17) + (((q31_t) b * c) >> 17); 00086 00087 a = *pSrcA++; 00088 b = *pSrcA++; 00089 c = *pSrcB++; 00090 d = *pSrcB++; 00091 00092 /* store the result in 3.13 format in the destination buffer. */ 00093 *pDst++ = 00094 (q15_t) (q31_t) (((q31_t) a * c) >> 17) - (((q31_t) b * d) >> 17); 00095 /* store the result in 3.13 format in the destination buffer. */ 00096 *pDst++ = 00097 (q15_t) (q31_t) (((q31_t) a * d) >> 17) + (((q31_t) b * c) >> 17); 00098 00099 a = *pSrcA++; 00100 b = *pSrcA++; 00101 c = *pSrcB++; 00102 d = *pSrcB++; 00103 00104 /* store the result in 3.13 format in the destination buffer. */ 00105 *pDst++ = 00106 (q15_t) (q31_t) (((q31_t) a * c) >> 17) - (((q31_t) b * d) >> 17); 00107 /* store the result in 3.13 format in the destination buffer. */ 00108 *pDst++ = 00109 (q15_t) (q31_t) (((q31_t) a * d) >> 17) + (((q31_t) b * c) >> 17); 00110 00111 a = *pSrcA++; 00112 b = *pSrcA++; 00113 c = *pSrcB++; 00114 d = *pSrcB++; 00115 00116 /* store the result in 3.13 format in the destination buffer. */ 00117 *pDst++ = 00118 (q15_t) (q31_t) (((q31_t) a * c) >> 17) - (((q31_t) b * d) >> 17); 00119 /* store the result in 3.13 format in the destination buffer. */ 00120 *pDst++ = 00121 (q15_t) (q31_t) (((q31_t) a * d) >> 17) + (((q31_t) b * c) >> 17); 00122 00123 /* Decrement the blockSize loop counter */ 00124 blkCnt--; 00125 } 00126 00127 /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 00128 ** No loop unrolling is used. */ 00129 blkCnt = numSamples % 0x4U; 00130 00131 while (blkCnt > 0U) 00132 { 00133 /* C[2 * i] = A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1]. */ 00134 /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i]. */ 00135 a = *pSrcA++; 00136 b = *pSrcA++; 00137 c = *pSrcB++; 00138 d = *pSrcB++; 00139 00140 /* store the result in 3.13 format in the destination buffer. */ 00141 *pDst++ = 00142 (q15_t) (q31_t) (((q31_t) a * c) >> 17) - (((q31_t) b * d) >> 17); 00143 /* store the result in 3.13 format in the destination buffer. */ 00144 *pDst++ = 00145 (q15_t) (q31_t) (((q31_t) a * d) >> 17) + (((q31_t) b * c) >> 17); 00146 00147 /* Decrement the blockSize loop counter */ 00148 blkCnt--; 00149 } 00150 00151 #else 00152 00153 /* Run the below code for Cortex-M0 */ 00154 00155 while (numSamples > 0U) 00156 { 00157 /* C[2 * i] = A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1]. */ 00158 /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i]. */ 00159 a = *pSrcA++; 00160 b = *pSrcA++; 00161 c = *pSrcB++; 00162 d = *pSrcB++; 00163 00164 /* store the result in 3.13 format in the destination buffer. */ 00165 *pDst++ = 00166 (q15_t) (q31_t) (((q31_t) a * c) >> 17) - (((q31_t) b * d) >> 17); 00167 /* store the result in 3.13 format in the destination buffer. */ 00168 *pDst++ = 00169 (q15_t) (q31_t) (((q31_t) a * d) >> 17) + (((q31_t) b * c) >> 17); 00170 00171 /* Decrement the blockSize loop counter */ 00172 numSamples--; 00173 } 00174 00175 #endif /* #if defined (ARM_MATH_DSP) */ 00176 00177 } 00178 00179 /** 00180 * @} end of CmplxByCmplxMult group 00181 */ 00182
Generated on Tue Jul 12 2022 16:46:23 by
 1.7.2
 1.7.2