1 /* ----------------------------------------------------------------------
2 * Copyright (C) 2010 ARM Limited. All rights reserved.
7 * Project: CMSIS DSP Library
8 * Title: arm_cmplx_mult_real_q15.c
10 * Description: Q15 complex by real 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 * @addtogroup CmplxByRealMult
43 * @brief Q15 complex-by-real multiplication
44 * @param[in] *pSrcCmplx points to the complex input vector
45 * @param[in] *pSrcReal points to the real input vector
46 * @param[out] *pCmplxDst points to the complex output vector
47 * @param[in] numSamples number of samples in each vector
50 * <b>Scaling and Overflow Behavior:</b>
52 * The function uses saturating arithmetic.
53 * Results outside of the allowable Q15 range [0x8000 0x7FFF] will be saturated.
56 void arm_cmplx_mult_real_q15(
62 q15_t in; /* Temporary variable to store input value */
66 /* Run the below code for Cortex-M4 and Cortex-M3 */
67 uint32_t blkCnt; /* loop counters */
70 blkCnt = numSamples >> 2u;
72 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
73 ** a second loop below computes the remaining 1 to 3 samples. */
76 /* C[2 * i] = A[2 * i] * B[i]. */
77 /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */
79 /* store the result in the destination buffer. */
81 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
83 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
87 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
89 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
93 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
95 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
99 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
101 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
103 /* Decrement the numSamples loop counter */
107 /* If the numSamples is not a multiple of 4, compute any remaining output samples here.
108 ** No loop unrolling is used. */
109 blkCnt = numSamples % 0x4u;
113 /* C[2 * i] = A[2 * i] * B[i]. */
114 /* C[2 * i + 1] = A[2 * i + 1] * B[i]. */
116 /* store the result in the destination buffer. */
118 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
120 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
122 /* Decrement the numSamples loop counter */
128 /* Run the below code for Cortex-M0 */
130 while(numSamples > 0u)
132 /* realOut = realA * realB. */
133 /* imagOut = imagA * realB. */
135 /* store the result in the destination buffer. */
137 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
139 (q15_t) __SSAT((((q31_t) (*pSrcCmplx++) * (in)) >> 15), 16);
141 /* Decrement the numSamples loop counter */
145 #endif /* #ifndef ARM_MATH_CM0 */
150 * @} end of CmplxByRealMult group