CMSIS DSP library
Dependents: performance_timer Surfboard_ gps2rtty Capstone ... more
arm_cmplx_mult_real_f32.c
00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 19. March 2015 00005 * $Revision: V.1.4.5 00006 * 00007 * Project: CMSIS DSP Library 00008 * Title: arm_cmplx_mult_real_f32.c 00009 * 00010 * Description: Floating-point complex by real multiplication 00011 * 00012 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 00013 * 00014 * Redistribution and use in source and binary forms, with or without 00015 * modification, are permitted provided that the following conditions 00016 * are met: 00017 * - Redistributions of source code must retain the above copyright 00018 * notice, this list of conditions and the following disclaimer. 00019 * - Redistributions in binary form must reproduce the above copyright 00020 * notice, this list of conditions and the following disclaimer in 00021 * the documentation and/or other materials provided with the 00022 * distribution. 00023 * - Neither the name of ARM LIMITED nor the names of its contributors 00024 * may be used to endorse or promote products derived from this 00025 * software without specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00028 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00029 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00030 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00031 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00032 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00033 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00034 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00035 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00036 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00037 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00038 * POSSIBILITY OF SUCH DAMAGE. 00039 * -------------------------------------------------------------------- */ 00040 00041 #include "arm_math.h" 00042 00043 /** 00044 * @ingroup groupCmplxMath 00045 */ 00046 00047 /** 00048 * @defgroup CmplxByRealMult Complex-by-Real Multiplication 00049 * 00050 * Multiplies a complex vector by a real vector and generates a complex result. 00051 * The data in the complex arrays is stored in an interleaved fashion 00052 * (real, imag, real, imag, ...). 00053 * The parameter <code>numSamples</code> represents the number of complex 00054 * samples processed. The complex arrays have a total of <code>2*numSamples</code> 00055 * real values while the real array has a total of <code>numSamples</code> 00056 * real values. 00057 * 00058 * The underlying algorithm is used: 00059 * 00060 * <pre> 00061 * for(n=0; n<numSamples; n++) { 00062 * pCmplxDst[(2*n)+0] = pSrcCmplx[(2*n)+0] * pSrcReal[n]; 00063 * pCmplxDst[(2*n)+1] = pSrcCmplx[(2*n)+1] * pSrcReal[n]; 00064 * } 00065 * </pre> 00066 * 00067 * There are separate functions for floating-point, Q15, and Q31 data types. 00068 */ 00069 00070 /** 00071 * @addtogroup CmplxByRealMult 00072 * @{ 00073 */ 00074 00075 00076 /** 00077 * @brief Floating-point complex-by-real multiplication 00078 * @param[in] *pSrcCmplx points to the complex input vector 00079 * @param[in] *pSrcReal points to the real input vector 00080 * @param[out] *pCmplxDst points to the complex output vector 00081 * @param[in] numSamples number of samples in each vector 00082 * @return none. 00083 */ 00084 00085 void arm_cmplx_mult_real_f32( 00086 float32_t * pSrcCmplx, 00087 float32_t * pSrcReal, 00088 float32_t * pCmplxDst, 00089 uint32_t numSamples) 00090 { 00091 float32_t in; /* Temporary variable to store input value */ 00092 uint32_t blkCnt; /* loop counters */ 00093 00094 #ifndef ARM_MATH_CM0_FAMILY 00095 00096 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00097 float32_t inA1, inA2, inA3, inA4; /* Temporary variables to hold input data */ 00098 float32_t inA5, inA6, inA7, inA8; /* Temporary variables to hold input data */ 00099 float32_t inB1, inB2, inB3, inB4; /* Temporary variables to hold input data */ 00100 float32_t out1, out2, out3, out4; /* Temporary variables to hold output data */ 00101 float32_t out5, out6, out7, out8; /* Temporary variables to hold output data */ 00102 00103 /* loop Unrolling */ 00104 blkCnt = numSamples >> 2u; 00105 00106 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00107 ** a second loop below computes the remaining 1 to 3 samples. */ 00108 while(blkCnt > 0u) 00109 { 00110 /* C[2 * i] = A[2 * i] * B[i]. */ 00111 /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */ 00112 /* read input from complex input buffer */ 00113 inA1 = pSrcCmplx[0]; 00114 inA2 = pSrcCmplx[1]; 00115 /* read input from real input buffer */ 00116 inB1 = pSrcReal[0]; 00117 00118 /* read input from complex input buffer */ 00119 inA3 = pSrcCmplx[2]; 00120 00121 /* multiply complex buffer real input with real buffer input */ 00122 out1 = inA1 * inB1; 00123 00124 /* read input from complex input buffer */ 00125 inA4 = pSrcCmplx[3]; 00126 00127 /* multiply complex buffer imaginary input with real buffer input */ 00128 out2 = inA2 * inB1; 00129 00130 /* read input from real input buffer */ 00131 inB2 = pSrcReal[1]; 00132 /* read input from complex input buffer */ 00133 inA5 = pSrcCmplx[4]; 00134 00135 /* multiply complex buffer real input with real buffer input */ 00136 out3 = inA3 * inB2; 00137 00138 /* read input from complex input buffer */ 00139 inA6 = pSrcCmplx[5]; 00140 /* read input from real input buffer */ 00141 inB3 = pSrcReal[2]; 00142 00143 /* multiply complex buffer imaginary input with real buffer input */ 00144 out4 = inA4 * inB2; 00145 00146 /* read input from complex input buffer */ 00147 inA7 = pSrcCmplx[6]; 00148 00149 /* multiply complex buffer real input with real buffer input */ 00150 out5 = inA5 * inB3; 00151 00152 /* read input from complex input buffer */ 00153 inA8 = pSrcCmplx[7]; 00154 00155 /* multiply complex buffer imaginary input with real buffer input */ 00156 out6 = inA6 * inB3; 00157 00158 /* read input from real input buffer */ 00159 inB4 = pSrcReal[3]; 00160 00161 /* store result to destination bufer */ 00162 pCmplxDst[0] = out1; 00163 00164 /* multiply complex buffer real input with real buffer input */ 00165 out7 = inA7 * inB4; 00166 00167 /* store result to destination bufer */ 00168 pCmplxDst[1] = out2; 00169 00170 /* multiply complex buffer imaginary input with real buffer input */ 00171 out8 = inA8 * inB4; 00172 00173 /* store result to destination bufer */ 00174 pCmplxDst[2] = out3; 00175 pCmplxDst[3] = out4; 00176 pCmplxDst[4] = out5; 00177 00178 /* incremnet complex input buffer by 8 to process next samples */ 00179 pSrcCmplx += 8u; 00180 00181 /* store result to destination bufer */ 00182 pCmplxDst[5] = out6; 00183 00184 /* increment real input buffer by 4 to process next samples */ 00185 pSrcReal += 4u; 00186 00187 /* store result to destination bufer */ 00188 pCmplxDst[6] = out7; 00189 pCmplxDst[7] = out8; 00190 00191 /* increment destination buffer by 8 to process next sampels */ 00192 pCmplxDst += 8u; 00193 00194 /* Decrement the numSamples loop counter */ 00195 blkCnt--; 00196 } 00197 00198 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00199 ** No loop unrolling is used. */ 00200 blkCnt = numSamples % 0x4u; 00201 00202 #else 00203 00204 /* Run the below code for Cortex-M0 */ 00205 blkCnt = numSamples; 00206 00207 #endif /* #ifndef ARM_MATH_CM0_FAMILY */ 00208 00209 while(blkCnt > 0u) 00210 { 00211 /* C[2 * i] = A[2 * i] * B[i]. */ 00212 /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */ 00213 in = *pSrcReal++; 00214 /* store the result in the destination buffer. */ 00215 *pCmplxDst++ = (*pSrcCmplx++) * (in); 00216 *pCmplxDst++ = (*pSrcCmplx++) * (in); 00217 00218 /* Decrement the numSamples loop counter */ 00219 blkCnt--; 00220 } 00221 } 00222 00223 /** 00224 * @} end of CmplxByRealMult group 00225 */
Generated on Tue Jul 12 2022 11:59:15 by 1.7.2