V4.0.1 of the ARM CMSIS DSP libraries. Note that arm_bitreversal2.s, arm_cfft_f32.c and arm_rfft_fast_f32.c had to be removed. arm_bitreversal2.s will not assemble with the online tools. So, the fast f32 FFT functions are not yet available. All the other FFT functions are available.

Dependents:   MPU9150_Example fir_f32 fir_f32 MPU9150_nucleo_noni2cdev ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arm_cmplx_mult_cmplx_f32.c Source File

arm_cmplx_mult_cmplx_f32.c

00001 /* ----------------------------------------------------------------------    
00002 * Copyright (C) 2010-2014 ARM Limited. All rights reserved.    
00003 *    
00004 * $Date:        12. March 2014
00005 * $Revision:    V1.4.3
00006 *    
00007 * Project:      CMSIS DSP Library    
00008 * Title:        arm_cmplx_mult_cmplx_f32.c    
00009 *    
00010 * Description:  Floating-point complex-by-complex 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 #include "arm_math.h"
00041 
00042 /**        
00043  * @ingroup groupCmplxMath        
00044  */
00045 
00046 /**        
00047  * @defgroup CmplxByCmplxMult Complex-by-Complex Multiplication        
00048  *        
00049  * Multiplies a complex vector by another complex vector and generates a complex result.        
00050  * The data in the complex arrays is stored in an interleaved fashion        
00051  * (real, imag, real, imag, ...).        
00052  * The parameter <code>numSamples</code> represents the number of complex        
00053  * samples processed.  The complex arrays have a total of <code>2*numSamples</code>        
00054  * real values.        
00055  *        
00056  * The underlying algorithm is used:        
00057  *        
00058  * <pre>        
00059  * for(n=0; n<numSamples; n++) {        
00060  *     pDst[(2*n)+0] = pSrcA[(2*n)+0] * pSrcB[(2*n)+0] - pSrcA[(2*n)+1] * pSrcB[(2*n)+1];        
00061  *     pDst[(2*n)+1] = pSrcA[(2*n)+0] * pSrcB[(2*n)+1] + pSrcA[(2*n)+1] * pSrcB[(2*n)+0];        
00062  * }        
00063  * </pre>        
00064  *        
00065  * There are separate functions for floating-point, Q15, and Q31 data types.        
00066  */
00067 
00068 /**        
00069  * @addtogroup CmplxByCmplxMult        
00070  * @{        
00071  */
00072 
00073 
00074 /**        
00075  * @brief  Floating-point complex-by-complex multiplication        
00076  * @param[in]  *pSrcA points to the first input vector        
00077  * @param[in]  *pSrcB points to the second input vector        
00078  * @param[out]  *pDst  points to the output vector        
00079  * @param[in]  numSamples number of complex samples in each vector        
00080  * @return none.        
00081  */
00082 
00083 void arm_cmplx_mult_cmplx_f32(
00084   float32_t * pSrcA,
00085   float32_t * pSrcB,
00086   float32_t * pDst,
00087   uint32_t numSamples)
00088 {
00089   float32_t a1, b1, c1, d1;                      /* Temporary variables to store real and imaginary values */
00090   uint32_t blkCnt;                               /* loop counters */
00091 
00092 #ifndef ARM_MATH_CM0_FAMILY
00093 
00094   /* Run the below code for Cortex-M4 and Cortex-M3 */
00095   float32_t a2, b2, c2, d2;                      /* Temporary variables to store real and imaginary values */
00096   float32_t acc1, acc2, acc3, acc4;
00097 
00098 
00099   /* loop Unrolling */
00100   blkCnt = numSamples >> 2u;
00101 
00102   /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.        
00103    ** a second loop below computes the remaining 1 to 3 samples. */
00104   while(blkCnt > 0u)
00105   {
00106     /* C[2 * i] = A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1].  */
00107     /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i].  */
00108     a1 = *pSrcA;                /* A[2 * i] */
00109     c1 = *pSrcB;                /* B[2 * i] */
00110 
00111     b1 = *(pSrcA + 1);          /* A[2 * i + 1] */
00112     acc1 = a1 * c1;             /* acc1 = A[2 * i] * B[2 * i] */
00113 
00114     a2 = *(pSrcA + 2);          /* A[2 * i + 2] */
00115     acc2 = (b1 * c1);           /* acc2 = A[2 * i + 1] * B[2 * i] */
00116 
00117     d1 = *(pSrcB + 1);          /* B[2 * i + 1] */
00118     c2 = *(pSrcB + 2);          /* B[2 * i + 2] */
00119     acc1 -= b1 * d1;            /* acc1 =      A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1] */
00120 
00121     d2 = *(pSrcB + 3);          /* B[2 * i + 3] */
00122     acc3 = a2 * c2;             /* acc3 =       A[2 * i + 2] * B[2 * i + 2] */
00123 
00124     b2 = *(pSrcA + 3);          /* A[2 * i + 3] */
00125     acc2 += (a1 * d1);          /* acc2 =      A[2 * i + 1] * B[2 * i] + A[2 * i] * B[2 * i + 1] */
00126 
00127     a1 = *(pSrcA + 4);          /* A[2 * i + 4] */
00128     acc4 = (a2 * d2);           /* acc4 =   A[2 * i + 2] * B[2 * i + 3] */
00129 
00130     c1 = *(pSrcB + 4);          /* B[2 * i + 4] */
00131     acc3 -= (b2 * d2);          /* acc3 =       A[2 * i + 2] * B[2 * i + 2] - A[2 * i + 3] * B[2 * i + 3] */
00132     *pDst = acc1;               /* C[2 * i] = A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1] */
00133 
00134     b1 = *(pSrcA + 5);          /* A[2 * i + 5] */
00135     acc4 += b2 * c2;            /* acc4 =   A[2 * i + 2] * B[2 * i + 3] + A[2 * i + 3] * B[2 * i + 2] */
00136 
00137     *(pDst + 1) = acc2;         /* C[2 * i + 1] = A[2 * i + 1] * B[2 * i] + A[2 * i] * B[2 * i + 1]  */
00138     acc1 = (a1 * c1);
00139 
00140     d1 = *(pSrcB + 5);
00141     acc2 = (b1 * c1);
00142 
00143     *(pDst + 2) = acc3;
00144     *(pDst + 3) = acc4;
00145 
00146     a2 = *(pSrcA + 6);
00147     acc1 -= (b1 * d1);
00148 
00149     c2 = *(pSrcB + 6);
00150     acc2 += (a1 * d1);
00151 
00152     b2 = *(pSrcA + 7);
00153     acc3 = (a2 * c2);
00154 
00155     d2 = *(pSrcB + 7);
00156     acc4 = (b2 * c2);
00157 
00158     *(pDst + 4) = acc1;
00159     pSrcA += 8u;
00160 
00161     acc3 -= (b2 * d2);
00162     acc4 += (a2 * d2);
00163 
00164     *(pDst + 5) = acc2;
00165     pSrcB += 8u;
00166 
00167     *(pDst + 6) = acc3;
00168     *(pDst + 7) = acc4;
00169 
00170     pDst += 8u;
00171 
00172     /* Decrement the numSamples loop counter */
00173     blkCnt--;
00174   }
00175 
00176   /* If the numSamples is not a multiple of 4, compute any remaining output samples here.        
00177    ** No loop unrolling is used. */
00178   blkCnt = numSamples % 0x4u;
00179 
00180 #else
00181 
00182   /* Run the below code for Cortex-M0 */
00183   blkCnt = numSamples;
00184 
00185 #endif /* #ifndef ARM_MATH_CM0_FAMILY */
00186 
00187   while(blkCnt > 0u)
00188   {
00189     /* C[2 * i] = A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1].  */
00190     /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i].  */
00191     a1 = *pSrcA++;
00192     b1 = *pSrcA++;
00193     c1 = *pSrcB++;
00194     d1 = *pSrcB++;
00195 
00196     /* store the result in the destination buffer. */
00197     *pDst++ = (a1 * c1) - (b1 * d1);
00198     *pDst++ = (a1 * d1) + (b1 * c1);
00199 
00200     /* Decrement the numSamples loop counter */
00201     blkCnt--;
00202   }
00203 }
00204 
00205 /**        
00206  * @} end of CmplxByCmplxMult group        
00207  */