00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2011 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 15. December 2011 00005 * $Revision: V2.0.0 00006 * 00007 * Project: Cortex-R DSP Library 00008 * Title: arm_cmplx_dot_prod_f32.c 00009 * 00010 * Description: Floating-point complex dot product 00011 * 00012 * Target Processor: Cortex-R4/R5 00013 * 00014 * Version 1.0.0 2011/03/08 00015 * Alpha release. 00016 * 00017 * Version 1.0.1 2011/09/30 00018 * Beta release. 00019 * 00020 * Version 2.0.0 2011/12/15 00021 * Final release. 00022 * 00023 * ---------------------------------------------------------------------------- */ 00024 #include "arm_math.h" 00025 00071 void arm_cmplx_dot_prod_f32( 00072 float32_t * pSrcA, 00073 float32_t * pSrcB, 00074 uint32_t numSamples, 00075 float32_t * realResult, 00076 float32_t * imagResult) 00077 { 00078 float32_t real_sum = 0.0f, imag_sum = 0.0f; /* Temporary result storage */ 00079 uint32_t blkCnt; /* loop counter */ 00080 float32_t inAR1, inBR1, inAR2, inBR2; /* Temporary variables to store real values */ 00081 float32_t inAI1, inBI1, inAI2, inBI2; /* Temporary variables to store imaginary values */ 00082 00083 /*loop Unrolling */ 00084 blkCnt = numSamples >> 2u; 00085 00086 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00087 ** a second loop below computes the remaining 1 to 3 samples. */ 00088 while(blkCnt > 0u) 00089 { 00090 /* read real input sample from sourceA */ 00091 inAR1 = pSrcA[0]; 00092 /* read real input sample from sourceB */ 00093 inBR1 = pSrcB[0]; 00094 /* read imaginary input sample from sourceA */ 00095 inAI1 = pSrcA[1]; 00096 00097 /* multiply and accumulate real values */ 00098 real_sum += inAR1*inBR1; 00099 00100 /* read imaginary input sample from sourceB */ 00101 inBI1 = pSrcB[1]; 00102 00103 /* read real input sample from sourceA */ 00104 inAR2 = pSrcA[2]; 00105 /* read real input sample from sourceB */ 00106 inBR2 = pSrcB[2]; 00107 00108 /* multiply and accumulate imaginary values */ 00109 imag_sum += inAI1*inBI1; 00110 00111 /* read imaginary input sample from sourceA */ 00112 inAI2 = pSrcA[3]; 00113 00114 /* multiply and accumulate real values */ 00115 real_sum += inAR2*inBR2; 00116 00117 /* read imaginary input sample from sourceB */ 00118 inBI2 = pSrcB[3]; 00119 00120 /* read real input sample from sourceA */ 00121 inAR1 = pSrcA[4]; 00122 00123 /* multiply and accumulate imaginary values */ 00124 imag_sum += inAI2*inBI2; 00125 00126 /* read real input sample from sourceB */ 00127 inBR1 = pSrcB[4]; 00128 /* read imaginary input sample from sourceA */ 00129 inAI1 = pSrcA[5]; 00130 00131 /* multiply and accumulate real values */ 00132 real_sum += inAR1*inBR1; 00133 00134 /* read imaginary input sample from sourceB */ 00135 inBI1 = pSrcB[5]; 00136 00137 /* read real input sample from sourceA */ 00138 inAR2 = pSrcA[6]; 00139 00140 /* multiply and accumulate imaginary values */ 00141 imag_sum += inAI1*inBI1; 00142 00143 /* read real input sample from sourceB */ 00144 inBR2 = pSrcB[6]; 00145 /* read imaginary input sample from sourceA */ 00146 inAI2 = pSrcA[7]; 00147 00148 /* multiply and accumulate real values */ 00149 real_sum += inAR2*inBR2; 00150 00151 /* read imaginary input sample from sourceB */ 00152 inBI2 = pSrcB[7]; 00153 00154 /* increment sourceA pointer by 8 to process next samples */ 00155 pSrcA += 8u; 00156 00157 /* multiply and accumulate imaginary values */ 00158 imag_sum += inAI2*inBI2; 00159 00160 /* increment sourceB pointer by 8 to process next samples */ 00161 pSrcB += 8u; 00162 00163 /* Decrement the loop counter */ 00164 blkCnt--; 00165 } 00166 00167 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00168 ** No loop unrolling is used. */ 00169 blkCnt = numSamples % 0x4u; 00170 00171 while(blkCnt > 0u) 00172 { 00173 /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */ 00174 real_sum += (*pSrcA++) * (*pSrcB++); 00175 /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */ 00176 imag_sum += (*pSrcA++) * (*pSrcB++); 00177 00178 00179 /* Decrement the loop counter */ 00180 blkCnt--; 00181 } 00182 00183 /* Store the real and imaginary results in the destination buffers */ 00184 *realResult = real_sum; 00185 *imagResult = imag_sum; 00186 } 00187