CMSIS DSP Library from CMSIS 2.0. See http://www.onarm.com/cmsis/ for full details
Dependents: K22F_DSP_Matrix_least_square BNO055-ELEC3810 1BNO055 ECE4180Project--Slave2 ... more
arm_cmplx_mult_cmplx_q31.c
00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2010 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 29. November 2010 00005 * $Revision: V1.0.3 00006 * 00007 * Project: CMSIS DSP Library 00008 * Title: arm_cmplx_mult_cmplx_q31.c 00009 * 00010 * Description: Q31 complex-by-complex multiplication 00011 * 00012 * Target Processor: Cortex-M4/Cortex-M3 00013 * 00014 * Version 1.0.3 2010/11/29 00015 * Re-organized the CMSIS folders and updated documentation. 00016 * 00017 * Version 1.0.2 2010/11/11 00018 * Documentation updated. 00019 * 00020 * Version 1.0.1 2010/10/05 00021 * Production release and review comments incorporated. 00022 * 00023 * Version 1.0.0 2010/09/20 00024 * Production release and review comments incorporated. 00025 * -------------------------------------------------------------------- */ 00026 00027 #include "arm_math.h" 00028 00029 /** 00030 * @ingroup groupCmplxMath 00031 */ 00032 00033 /** 00034 * @addtogroup CmplxByCmplxMult 00035 * @{ 00036 */ 00037 00038 00039 /** 00040 * @brief Q31 complex-by-complex multiplication 00041 * @param[in] *pSrcA points to the first input vector 00042 * @param[in] *pSrcB points to the second input vector 00043 * @param[out] *pDst points to the output vector 00044 * @param[in] numSamples number of complex samples in each vector 00045 * @return none. 00046 * 00047 * <b>Scaling and Overflow Behavior:</b> 00048 * \par 00049 * The function implements 1.31 by 1.31 multiplications and finally output is converted into 3.29 format. 00050 * Input down scaling is not required. 00051 */ 00052 00053 void arm_cmplx_mult_cmplx_q31( 00054 q31_t * pSrcA, 00055 q31_t * pSrcB, 00056 q31_t * pDst, 00057 uint32_t numSamples) 00058 { 00059 q31_t a, b, c, d; /* Temporary variables to store real and imaginary values */ 00060 uint32_t blkCnt; /* loop counters */ 00061 00062 /* loop Unrolling */ 00063 blkCnt = numSamples >> 2u; 00064 00065 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00066 ** a second loop below computes the remaining 1 to 3 samples. */ 00067 while(blkCnt > 0u) 00068 { 00069 /* C[2 * i] = A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1]. */ 00070 /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i]. */ 00071 a = *pSrcA++; 00072 b = *pSrcA++; 00073 c = *pSrcB++; 00074 d = *pSrcB++; 00075 00076 /* store the real result in 3.29 format in the destination buffer. */ 00077 *pDst++ = (q31_t) ((((q63_t) a * c) >> 33) - (((q63_t) b * d) >> 33)); 00078 /* store the imag result in 3.29 format in the destination buffer. */ 00079 *pDst++ = (q31_t) ((((q63_t) a * d) >> 33) + (((q63_t) b * c) >> 33)); 00080 00081 a = *pSrcA++; 00082 b = *pSrcA++; 00083 c = *pSrcB++; 00084 d = *pSrcB++; 00085 00086 /* store the result in 3.29 format in the destination buffer. */ 00087 *pDst++ = (q31_t) ((((q63_t) a * c) >> 33) - (((q63_t) b * d) >> 33)); 00088 /* store the result in 3.29 format in the destination buffer. */ 00089 *pDst++ = (q31_t) ((((q63_t) a * d) >> 33) + (((q63_t) b * c) >> 33)); 00090 00091 a = *pSrcA++; 00092 b = *pSrcA++; 00093 c = *pSrcB++; 00094 d = *pSrcB++; 00095 00096 /* store the result in 3.29 format in the destination buffer. */ 00097 *pDst++ = (q31_t) ((((q63_t) a * c) >> 33) - (((q63_t) b * d) >> 33)); 00098 /* store the result in 3.29 format in the destination buffer. */ 00099 *pDst++ = (q31_t) ((((q63_t) a * d) >> 33) + (((q63_t) b * c) >> 33)); 00100 00101 a = *pSrcA++; 00102 b = *pSrcA++; 00103 c = *pSrcB++; 00104 d = *pSrcB++; 00105 00106 /* store the result in 3.29 format in the destination buffer. */ 00107 *pDst++ = (q31_t) ((((q63_t) a * c) >> 33) - (((q63_t) b * d) >> 33)); 00108 /* store the result in 3.29 format in the destination buffer. */ 00109 *pDst++ = (q31_t) ((((q63_t) a * d) >> 33) + (((q63_t) b * c) >> 33)); 00110 00111 /* Decrement the blockSize loop counter */ 00112 blkCnt--; 00113 } 00114 00115 /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 00116 ** No loop unrolling is used. */ 00117 blkCnt = numSamples % 0x4u; 00118 00119 while(blkCnt > 0u) 00120 { 00121 /* C[2 * i] = A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1]. */ 00122 /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i]. */ 00123 a = *pSrcA++; 00124 b = *pSrcA++; 00125 c = *pSrcB++; 00126 d = *pSrcB++; 00127 00128 /* store the result in 3.29 format in the destination buffer. */ 00129 *pDst++ = (q31_t) ((((q63_t) a * c) >> 33) - (((q63_t) b * d) >> 33)); 00130 /* store the result in 3.29 format in the destination buffer. */ 00131 *pDst++ = (q31_t) ((((q63_t) a * d) >> 33) + (((q63_t) b * c) >> 33)); 00132 00133 /* Decrement the blockSize loop counter */ 00134 blkCnt--; 00135 } 00136 } 00137 00138 /** 00139 * @} end of CmplxByCmplxMult group 00140 */
Generated on Tue Jul 12 2022 14:13:52 by 1.7.2