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_f32.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_f32.c 00009 * 00010 * Description: Floating-point 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 * @defgroup cmplx_dot_prod Complex Dot Product 00035 * 00036 * Computes the dot product of two complex vectors. 00037 * The vectors are multiplied element-by-element and then summed. 00038 * 00039 * The <code>pSrcA</code> points to the first complex input vector and 00040 * <code>pSrcB</code> points to the second complex input vector. 00041 * <code>numSamples</code> specifies the number of complex samples 00042 * and the data in each array is stored in an interleaved fashion 00043 * (real, imag, real, imag, ...). 00044 * Each array has a total of <code>2*numSamples</code> values. 00045 * 00046 * The underlying algorithm is used: 00047 * <pre> 00048 * realResult=0; 00049 * imagResult=0; 00050 * for(n=0; n<numSamples; n++) { 00051 * realResult += pSrcA[(2*n)+0]*pSrcB[(2*n)+0] - pSrcA[(2*n)+1]*pSrcB[(2*n)+1]; 00052 * imagResult += pSrcA[(2*n)+0]*pSrcB[(2*n)+1] + pSrcA[(2*n)+1]*pSrcB[(2*n)+0]; 00053 * } 00054 * </pre> 00055 * 00056 * There are separate functions for floating-point, Q15, and Q31 data types. 00057 */ 00058 00059 /** 00060 * @addtogroup cmplx_dot_prod 00061 * @{ 00062 */ 00063 00064 /** 00065 * @brief Floating-point complex dot product 00066 * @param *pSrcA points to the first input vector 00067 * @param *pSrcB points to the second input vector 00068 * @param numSamples number of complex samples in each vector 00069 * @param *realResult real part of the result returned here 00070 * @param *imagResult imaginary part of the result returned here 00071 * @return none. 00072 */ 00073 00074 void arm_cmplx_dot_prod_f32( 00075 float32_t * pSrcA, 00076 float32_t * pSrcB, 00077 uint32_t numSamples, 00078 float32_t * realResult, 00079 float32_t * imagResult) 00080 { 00081 float32_t real_sum = 0.0f, imag_sum = 0.0f; /* Temporary result storage */ 00082 uint32_t blkCnt; /* loop counter */ 00083 00084 /*loop Unrolling */ 00085 blkCnt = numSamples >> 2u; 00086 00087 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00088 ** a second loop below computes the remaining 1 to 3 samples. */ 00089 while(blkCnt > 0u) 00090 { 00091 /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */ 00092 real_sum += (*pSrcA++) * (*pSrcB++); 00093 /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */ 00094 imag_sum += (*pSrcA++) * (*pSrcB++); 00095 00096 real_sum += (*pSrcA++) * (*pSrcB++); 00097 imag_sum += (*pSrcA++) * (*pSrcB++); 00098 00099 real_sum += (*pSrcA++) * (*pSrcB++); 00100 imag_sum += (*pSrcA++) * (*pSrcB++); 00101 00102 real_sum += (*pSrcA++) * (*pSrcB++); 00103 imag_sum += (*pSrcA++) * (*pSrcB++); 00104 00105 /* Decrement the loop counter */ 00106 blkCnt--; 00107 } 00108 00109 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00110 ** No loop unrolling is used. */ 00111 blkCnt = numSamples % 0x4u; 00112 00113 while(blkCnt > 0u) 00114 { 00115 /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */ 00116 real_sum += (*pSrcA++) * (*pSrcB++); 00117 /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */ 00118 imag_sum += (*pSrcA++) * (*pSrcB++); 00119 00120 00121 /* Decrement the loop counter */ 00122 blkCnt--; 00123 } 00124 00125 /* Store the real and imaginary results in the destination buffers */ 00126 *realResult = real_sum; 00127 *imagResult = imag_sum; 00128 } 00129 00130 /** 00131 * @} end of cmplx_dot_prod group 00132 */
Generated on Tue Jul 12 2022 19:55:42 by
1.7.2
