Merge branch 'jnosky/master'
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / ComplexMathFunctions / arm_cmplx_conj_f32.c
1 /* ----------------------------------------------------------------------   
2 * Copyright (C) 2010 ARM Limited. All rights reserved.   
3 *   
4 * $Date:        15. July 2011  
5 * $Revision:    V1.0.10  
6 *   
7 * Project:          CMSIS DSP Library   
8 * Title:                arm_cmplx_conj_f32.c   
9 *   
10 * Description:  Floating-point complex conjugate.   
11 *   
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
13 *  
14 * Version 1.0.10 2011/7/15 
15 *    Big Endian support added and Merged M0 and M3/M4 Source code.  
16 *   
17 * Version 1.0.3 2010/11/29  
18 *    Re-organized the CMSIS folders and updated documentation.   
19 *    
20 * Version 1.0.2 2010/11/11   
21 *    Documentation updated.    
22 *   
23 * Version 1.0.1 2010/10/05    
24 *    Production release and review comments incorporated.   
25 *   
26 * Version 1.0.0 2010/09/20    
27 *    Production release and review comments incorporated.   
28 * ---------------------------------------------------------------------------- */
29
30 #include "arm_math.h"
31
32 /**   
33  * @ingroup groupCmplxMath   
34  */
35
36 /**   
37  * @defgroup cmplx_conj Complex Conjugate   
38  *   
39  * Conjugates the elements of a complex data vector.   
40  *  
41  * The <code>pSrc</code> points to the source data and   
42  * <code>pDst</code> points to the where the result should be written.   
43  * <code>numSamples</code> specifies the number of complex samples   
44  * and the data in each array is stored in an interleaved fashion   
45  * (real, imag, real, imag, ...).   
46  * Each array has a total of <code>2*numSamples</code> values.   
47  * The underlying algorithm is used:   
48  *   
49  * <pre>   
50  * for(n=0; n<numSamples; n++) {   
51  *     pDst[(2*n)+0)] = pSrc[(2*n)+0];     // real part   
52  *     pDst[(2*n)+1)] = -pSrc[(2*n)+1];    // imag part   
53  * }   
54  * </pre>   
55  *   
56  * There are separate functions for floating-point, Q15, and Q31 data types.   
57  */
58
59 /**   
60  * @addtogroup cmplx_conj   
61  * @{   
62  */
63
64 /**   
65  * @brief  Floating-point complex conjugate.   
66  * @param  *pSrc points to the input vector   
67  * @param  *pDst points to the output vector   
68  * @param  numSamples number of complex samples in each vector   
69  * @return none.   
70  */
71
72 void arm_cmplx_conj_f32(
73   float32_t * pSrc,
74   float32_t * pDst,
75   uint32_t numSamples)
76 {
77
78 #ifndef ARM_MATH_CM0
79
80   /* Run the below code for Cortex-M4 and Cortex-M3 */
81   uint32_t blkCnt;                               /* loop counter */
82
83   /*loop Unrolling */
84   blkCnt = numSamples >> 2u;
85
86   /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.   
87    ** a second loop below computes the remaining 1 to 3 samples. */
88   while(blkCnt > 0u)
89   {
90     /* C[0]+jC[1] = A[0]+ j (-1) A[1] */
91     /* Calculate Complex Conjugate and then store the results in the destination buffer. */
92     *pDst++ = *pSrc++;
93     *pDst++ = -*pSrc++;
94     *pDst++ = *pSrc++;
95     *pDst++ = -*pSrc++;
96     *pDst++ = *pSrc++;
97     *pDst++ = -*pSrc++;
98     *pDst++ = *pSrc++;
99     *pDst++ = -*pSrc++;
100
101     /* Decrement the loop counter */
102     blkCnt--;
103   }
104
105   /* If the numSamples is not a multiple of 4, compute any remaining output samples here.   
106    ** No loop unrolling is used. */
107   blkCnt = numSamples % 0x4u;
108
109   while(blkCnt > 0u)
110   {
111     /* C[0]+jC[1] = A[0]+ j (-1) A[1] */
112     /* Calculate Complex Conjugate and then store the results in the destination buffer. */
113     *pDst++ = *pSrc++;
114     *pDst++ = -*pSrc++;
115
116     /* Decrement the loop counter */
117     blkCnt--;
118   }
119
120 #else
121
122   /* Run the below code for Cortex-M0 */
123
124   while(numSamples > 0u)
125   {
126     /* realOut + j (imagOut) = realIn + j (-1) imagIn */
127     /* Calculate Complex Conjugate and then store the results in the destination buffer. */
128     *pDst++ = *pSrc++;
129     *pDst++ = -*pSrc++;
130
131     /* Decrement the loop counter */
132     numSamples--;
133   }
134
135 #endif /* #ifndef ARM_MATH_CM0 */
136
137 }
138
139 /**   
140  * @} end of cmplx_conj group   
141  */