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.
Fork of dsp by
arm_cmplx_dot_prod_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_dot_prod_q31.c 00009 * 00010 * Description: Q31 complex dot product 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 cmplx_dot_prod 00035 * @{ 00036 */ 00037 00038 /** 00039 * @brief Q31 complex dot product 00040 * @param *pSrcA points to the first input vector 00041 * @param *pSrcB points to the second input vector 00042 * @param numSamples number of complex samples in each vector 00043 * @param *realResult real part of the result returned here 00044 * @param *imagResult imaginary part of the result returned here 00045 * @return none. 00046 * 00047 * <b>Scaling and Overflow Behavior:</b> 00048 * \par 00049 * The function is implemented using an internal 64-bit accumulator. 00050 * The intermediate 1.31 by 1.31 multiplications are performed with 64-bit precision and then shifted to 16.48 format. 00051 * The internal real and imaginary accumulators are in 16.48 format and provide 15 guard bits. 00052 * Additions are nonsaturating and no overflow will occur as long as <code>numSamples</code> is less than 32768. 00053 * The return results <code>realResult</code> and <code>imagResult</code> are in 16.48 format. 00054 * Input down scaling is not required. 00055 */ 00056 00057 void arm_cmplx_dot_prod_q31( 00058 q31_t * pSrcA, 00059 q31_t * pSrcB, 00060 uint32_t numSamples, 00061 q63_t * realResult, 00062 q63_t * imagResult) 00063 { 00064 q63_t real_sum = 0, imag_sum = 0; /* Temporary result storage */ 00065 uint32_t blkCnt; /* loop counter */ 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 /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */ 00076 /* Convert real data in 2.62 to 16.48 by 14 right shifts */ 00077 real_sum += (q63_t) * pSrcA++ * (*pSrcB++) >> 14; 00078 /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */ 00079 /* Convert imag data in 2.62 to 16.48 by 14 right shifts */ 00080 imag_sum += (q63_t) * pSrcA++ * (*pSrcB++) >> 14; 00081 00082 real_sum += (q63_t) * pSrcA++ * (*pSrcB++) >> 14; 00083 imag_sum += (q63_t) * pSrcA++ * (*pSrcB++) >> 14; 00084 00085 real_sum += (q63_t) * pSrcA++ * (*pSrcB++) >> 14; 00086 imag_sum += (q63_t) * pSrcA++ * (*pSrcB++) >> 14; 00087 00088 real_sum += (q63_t) * pSrcA++ * (*pSrcB++) >> 14; 00089 imag_sum += (q63_t) * pSrcA++ * (*pSrcB++) >> 14; 00090 00091 00092 /* Decrement the loop counter */ 00093 blkCnt--; 00094 } 00095 00096 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00097 ** No loop unrolling is used. */ 00098 blkCnt = numSamples % 0x4u; 00099 00100 while(blkCnt > 0u) 00101 { 00102 /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */ 00103 real_sum += (q63_t) * pSrcA++ * (*pSrcB++) >> 14; 00104 /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */ 00105 imag_sum += (q63_t) * pSrcA++ * (*pSrcB++) >> 14; 00106 00107 /* Decrement the loop counter */ 00108 blkCnt--; 00109 } 00110 00111 /* Store the real and imaginary results in 16.48 format */ 00112 *realResult = real_sum; 00113 *imagResult = imag_sum; 00114 } 00115 00116 /** 00117 * @} end of cmplx_dot_prod group 00118 */
Generated on Tue Jul 12 2022 19:55:42 by
 1.7.2
 1.7.2 
    