1 /* ----------------------------------------------------------------------
2 * Copyright (C) 2010 ARM Limited. All rights reserved.
7 * Project: CMSIS DSP Library
8 * Title: arm_cmplx_mult_cmplx_f32.c
10 * Description: Floating-point complex-by-complex multiplication
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
14 * Version 1.0.10 2011/7/15
15 * Big Endian support added and Merged M0 and M3/M4 Source code.
17 * Version 1.0.3 2010/11/29
18 * Re-organized the CMSIS folders and updated documentation.
20 * Version 1.0.2 2010/11/11
21 * Documentation updated.
23 * Version 1.0.1 2010/10/05
24 * Production release and review comments incorporated.
26 * Version 1.0.0 2010/09/20
27 * Production release and review comments incorporated.
28 * -------------------------------------------------------------------- */
33 * @ingroup groupCmplxMath
37 * @defgroup CmplxByCmplxMult Complex-by-Complex Multiplication
39 * Multiplies a complex vector by another complex vector and generates a complex result.
40 * The data in the complex arrays is stored in an interleaved fashion
41 * (real, imag, real, imag, ...).
42 * The parameter <code>numSamples</code> represents the number of complex
43 * samples processed. The complex arrays have a total of <code>2*numSamples</code>
46 * The underlying algorithm is used:
49 * for(n=0; n<numSamples; n++) {
50 * pDst[(2*n)+0] = pSrcA[(2*n)+0] * pSrcB[(2*n)+0] - pSrcA[(2*n)+1] * pSrcB[(2*n)+1];
51 * pDst[(2*n)+1] = pSrcA[(2*n)+0] * pSrcB[(2*n)+1] + pSrcA[(2*n)+1] * pSrcB[(2*n)+0];
55 * There are separate functions for floating-point, Q15, and Q31 data types.
59 * @addtogroup CmplxByCmplxMult
65 * @brief Floating-point complex-by-complex multiplication
66 * @param[in] *pSrcA points to the first input vector
67 * @param[in] *pSrcB points to the second input vector
68 * @param[out] *pDst points to the output vector
69 * @param[in] numSamples number of complex samples in each vector
73 void arm_cmplx_mult_cmplx_f32(
79 float32_t a, b, c, d; /* Temporary variables to store real and imaginary values */
83 /* Run the below code for Cortex-M4 and Cortex-M3 */
84 uint32_t blkCnt; /* loop counters */
87 blkCnt = numSamples >> 2u;
89 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
90 ** a second loop below computes the remaining 1 to 3 samples. */
93 /* C[2 * i] = A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1]. */
94 /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i]. */
100 /* store the result in the destination buffer. */
101 *pDst++ = (a * c) - (b * d);
102 *pDst++ = (a * d) + (b * c);
109 *pDst++ = (a * c) - (b * d);
110 *pDst++ = (a * d) + (b * c);
117 *pDst++ = (a * c) - (b * d);
118 *pDst++ = (a * d) + (b * c);
125 *pDst++ = (a * c) - (b * d);
126 *pDst++ = (a * d) + (b * c);
128 /* Decrement the numSamples loop counter */
132 /* If the numSamples is not a multiple of 4, compute any remaining output samples here.
133 ** No loop unrolling is used. */
134 blkCnt = numSamples % 0x4u;
138 /* C[2 * i] = A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1]. */
139 /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i]. */
145 /* store the result in the destination buffer. */
146 *pDst++ = (a * c) - (b * d);
147 *pDst++ = (a * d) + (b * c);
149 /* Decrement the numSamples loop counter */
155 /* Run the below code for Cortex-M0 */
157 while(numSamples > 0u)
159 /* C[2 * i] = A[2 * i] * B[2 * i] - A[2 * i + 1] * B[2 * i + 1]. */
160 /* C[2 * i + 1] = A[2 * i] * B[2 * i + 1] + A[2 * i + 1] * B[2 * i]. */
166 /* store the result in the destination buffer. */
167 *pDst++ = (a * c) - (b * d);
168 *pDst++ = (a * d) + (b * c);
170 /* Decrement the numSamples loop counter */
174 #endif /* #ifndef ARM_MATH_CM0 */
179 * @} end of CmplxByCmplxMult group