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_mult_real_f32.c 00009 * 00010 * Description: Floating-point complex by real multiplication 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 00068 void arm_cmplx_mult_real_f32( 00069 float32_t * pSrcCmplx, 00070 float32_t * pSrcReal, 00071 float32_t * pCmplxDst, 00072 uint32_t numSamples) 00073 { 00074 float32_t in; /* Temporary variable to store input value */ 00075 uint32_t blkCnt; /* loop counters */ 00076 float32_t inA1, inA2, inA3, inA4; /* Temporary variables to hold input data */ 00077 float32_t inA5, inA6, inA7, inA8; /* Temporary variables to hold input data */ 00078 float32_t inB1, inB2, inB3, inB4; /* Temporary variables to hold input data */ 00079 float32_t out1, out2, out3, out4; /* Temporary variables to hold output data */ 00080 float32_t out5, out6, out7, out8; /* Temporary variables to hold output data */ 00081 00082 /* loop Unrolling */ 00083 blkCnt = numSamples >> 2u; 00084 00085 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00086 ** a second loop below computes the remaining 1 to 3 samples. */ 00087 while(blkCnt > 0u) 00088 { 00089 /* C[2 * i] = A[2 * i] * B[i]. */ 00090 /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */ 00091 /* read input from complex input buffer */ 00092 inA1 = pSrcCmplx[0]; 00093 inA2 = pSrcCmplx[1]; 00094 /* read input from real input buffer */ 00095 inB1 = pSrcReal[0]; 00096 00097 /* read input from complex input buffer */ 00098 inA3 = pSrcCmplx[2]; 00099 00100 /* multiply complex buffer real input with real buffer input */ 00101 out1 = inA1 * inB1; 00102 00103 /* read input from complex input buffer */ 00104 inA4 = pSrcCmplx[3]; 00105 00106 /* multiply complex buffer imaginary input with real buffer input */ 00107 out2 = inA2 * inB1; 00108 00109 /* read input from real input buffer */ 00110 inB2 = pSrcReal[1]; 00111 /* read input from complex input buffer */ 00112 inA5 = pSrcCmplx[4]; 00113 00114 /* multiply complex buffer real input with real buffer input */ 00115 out3 = inA3 * inB2; 00116 00117 /* read input from complex input buffer */ 00118 inA6 = pSrcCmplx[5]; 00119 /* read input from real input buffer */ 00120 inB3 = pSrcReal[2]; 00121 00122 /* multiply complex buffer imaginary input with real buffer input */ 00123 out4 = inA4 * inB2; 00124 00125 /* read input from complex input buffer */ 00126 inA7 = pSrcCmplx[6]; 00127 00128 /* multiply complex buffer real input with real buffer input */ 00129 out5 = inA5 * inB3; 00130 00131 /* read input from complex input buffer */ 00132 inA8 = pSrcCmplx[7]; 00133 00134 /* multiply complex buffer imaginary input with real buffer input */ 00135 out6 = inA6 * inB3; 00136 00137 /* read input from real input buffer */ 00138 inB4 = pSrcReal[3]; 00139 00140 /* store result to destination bufer */ 00141 pCmplxDst[0] = out1; 00142 00143 /* multiply complex buffer real input with real buffer input */ 00144 out7 = inA7 * inB4; 00145 00146 /* store result to destination bufer */ 00147 pCmplxDst[1] = out2; 00148 00149 /* multiply complex buffer imaginary input with real buffer input */ 00150 out8 = inA8 * inB4; 00151 00152 /* store result to destination bufer */ 00153 pCmplxDst[2] = out3; 00154 pCmplxDst[3] = out4; 00155 pCmplxDst[4] = out5; 00156 00157 /* incremnet complex input buffer by 8 to process next samples */ 00158 pSrcCmplx += 8u; 00159 00160 /* store result to destination bufer */ 00161 pCmplxDst[5] = out6; 00162 00163 /* increment real input buffer by 4 to process next samples */ 00164 pSrcReal += 4u; 00165 00166 /* store result to destination bufer */ 00167 pCmplxDst[6] = out7; 00168 pCmplxDst[7] = out8; 00169 00170 /* increment destination buffer by 8 to process next sampels */ 00171 pCmplxDst += 8u; 00172 00173 /* Decrement the numSamples loop counter */ 00174 blkCnt--; 00175 } 00176 00177 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00178 ** No loop unrolling is used. */ 00179 blkCnt = numSamples % 0x4u; 00180 00181 while(blkCnt > 0u) 00182 { 00183 /* C[2 * i] = A[2 * i] * B[i]. */ 00184 /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */ 00185 in = *pSrcReal++; 00186 /* store the result in the destination buffer. */ 00187 *pCmplxDst++ = (*pSrcCmplx++) * (in); 00188 *pCmplxDst++ = (*pSrcCmplx++) * (in); 00189 00190 /* Decrement the numSamples loop counter */ 00191 blkCnt--; 00192 } 00193 } 00194