Added all the F4 libraries to the project
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / ComplexMathFunctions / arm_cmplx_conj_q31.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_q31.c   
9 *   
10 * Description:  Q31 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  * @addtogroup cmplx_conj   
38  * @{   
39  */
40
41 /**   
42  * @brief  Q31 complex conjugate.   
43  * @param  *pSrc points to the input vector   
44  * @param  *pDst points to the output vector   
45  * @param  numSamples number of complex samples in each vector   
46  * @return none.   
47  *   
48  * <b>Scaling and Overflow Behavior:</b>   
49  * \par   
50  * The function uses saturating arithmetic.   
51  * The Q31 value -1 (0x80000000) will be saturated to the maximum allowable positive value 0x7FFFFFFF.   
52  */
53
54 void arm_cmplx_conj_q31(
55   q31_t * pSrc,
56   q31_t * pDst,
57   uint32_t numSamples)
58 {
59
60 #ifndef ARM_MATH_CM0
61
62   /* Run the below code for Cortex-M4 and Cortex-M3 */
63   uint32_t blkCnt;                               /* loop counter */
64   q31_t in;                                      /* Input value */
65
66   /*loop Unrolling */
67   blkCnt = numSamples >> 2u;
68
69   /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.   
70    ** a second loop below computes the remaining 1 to 3 samples. */
71   while(blkCnt > 0u)
72   {
73     /* C[0]+jC[1] = A[0]+ j (-1) A[1] */
74     /* Calculate Complex Conjugate and then store the results in the destination buffer. */
75     /* Saturated to 0x7fffffff if the input is -1(0x80000000) */
76     *pDst++ = *pSrc++;
77     in = *pSrc++;
78     *pDst++ = (in == 0x80000000) ? 0x7fffffff : -in;
79     *pDst++ = *pSrc++;
80     in = *pSrc++;
81     *pDst++ = (in == 0x80000000) ? 0x7fffffff : -in;
82     *pDst++ = *pSrc++;
83     in = *pSrc++;
84     *pDst++ = (in == 0x80000000) ? 0x7fffffff : -in;
85     *pDst++ = *pSrc++;
86     in = *pSrc++;
87     *pDst++ = (in == 0x80000000) ? 0x7fffffff : -in;
88
89     /* Decrement the loop counter */
90     blkCnt--;
91   }
92
93   /* If the numSamples is not a multiple of 4, compute any remaining output samples here.   
94    ** No loop unrolling is used. */
95   blkCnt = numSamples % 0x4u;
96
97   while(blkCnt > 0u)
98   {
99     /* C[0]+jC[1] = A[0]+ j (-1) A[1] */
100     /* Calculate Complex Conjugate and then store the results in the destination buffer. */
101     /* Saturated to 0x7fffffff if the input is -1(0x80000000) */
102     *pDst++ = *pSrc++;
103     in = *pSrc++;
104     *pDst++ = (in == 0x80000000) ? 0x7fffffff : -in;
105
106     /* Decrement the loop counter */
107     blkCnt--;
108   }
109
110 #else
111
112   /* Run the below code for Cortex-M0 */
113
114   while(numSamples > 0u)
115   {
116     /* realOut + j (imagOut) = realIn+ j (-1) imagIn */
117     /* Calculate Complex Conjugate and then store the results in the destination buffer. */
118     *pDst++ = *pSrc++;
119     *pDst++ = -*pSrc++;
120
121     /* Decrement the loop counter */
122     numSamples--;
123   }
124
125 #endif /* #ifndef ARM_MATH_CM0 */
126
127 }
128
129 /**   
130  * @} end of cmplx_conj group   
131  */