Merge pull request #11270 from haslinghuis/rename_attr
[betaflight.git] / lib / main / CMSIS / DSP / Source / ComplexMathFunctions / arm_cmplx_conj_q31.c
blob709ce0e03c0f1994eee2dfd15fd17ebe07ec1cf0
1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_cmplx_conj_q31.c
4 * Description: Q31 complex conjugate
6 * $Date: 27. January 2017
7 * $Revision: V.1.5.1
9 * Target Processor: Cortex-M cores
10 * -------------------------------------------------------------------- */
12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
14 * SPDX-License-Identifier: Apache-2.0
16 * Licensed under the Apache License, Version 2.0 (the License); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
20 * www.apache.org/licenses/LICENSE-2.0
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
29 #include "arm_math.h"
31 /**
32 * @ingroup groupCmplxMath
35 /**
36 * @addtogroup cmplx_conj
37 * @{
40 /**
41 * @brief Q31 complex conjugate.
42 * @param *pSrc points to the input vector
43 * @param *pDst points to the output vector
44 * @param numSamples number of complex samples in each vector
45 * @return none.
47 * <b>Scaling and Overflow Behavior:</b>
48 * \par
49 * The function uses saturating arithmetic.
50 * The Q31 value -1 (0x80000000) will be saturated to the maximum allowable positive value 0x7FFFFFFF.
53 void arm_cmplx_conj_q31(
54 q31_t * pSrc,
55 q31_t * pDst,
56 uint32_t numSamples)
58 uint32_t blkCnt; /* loop counter */
59 q31_t in; /* Input value */
61 #if defined (ARM_MATH_DSP)
63 /* Run the below code for Cortex-M4 and Cortex-M3 */
64 q31_t inR1, inR2, inR3, inR4; /* Temporary real variables */
65 q31_t inI1, inI2, inI3, inI4; /* Temporary imaginary variables */
67 /*loop Unrolling */
68 blkCnt = numSamples >> 2U;
70 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
71 ** a second loop below computes the remaining 1 to 3 samples. */
72 while (blkCnt > 0U)
74 /* C[0]+jC[1] = A[0]+ j (-1) A[1] */
75 /* Calculate Complex Conjugate and then store the results in the destination buffer. */
76 /* Saturated to 0x7fffffff if the input is -1(0x80000000) */
77 /* read real input sample */
78 inR1 = pSrc[0];
79 /* store real input sample */
80 pDst[0] = inR1;
82 /* read imaginary input sample */
83 inI1 = pSrc[1];
85 /* read real input sample */
86 inR2 = pSrc[2];
87 /* store real input sample */
88 pDst[2] = inR2;
90 /* read imaginary input sample */
91 inI2 = pSrc[3];
93 /* negate imaginary input sample */
94 inI1 = __QSUB(0, inI1);
96 /* read real input sample */
97 inR3 = pSrc[4];
98 /* store real input sample */
99 pDst[4] = inR3;
101 /* read imaginary input sample */
102 inI3 = pSrc[5];
104 /* negate imaginary input sample */
105 inI2 = __QSUB(0, inI2);
107 /* read real input sample */
108 inR4 = pSrc[6];
109 /* store real input sample */
110 pDst[6] = inR4;
112 /* negate imaginary input sample */
113 inI3 = __QSUB(0, inI3);
115 /* store imaginary input sample */
116 inI4 = pSrc[7];
118 /* store imaginary input samples */
119 pDst[1] = inI1;
121 /* negate imaginary input sample */
122 inI4 = __QSUB(0, inI4);
124 /* store imaginary input samples */
125 pDst[3] = inI2;
127 /* increment source pointer by 8 to proecess next samples */
128 pSrc += 8U;
130 /* store imaginary input samples */
131 pDst[5] = inI3;
132 pDst[7] = inI4;
134 /* increment destination pointer by 8 to process next samples */
135 pDst += 8U;
137 /* Decrement the loop counter */
138 blkCnt--;
141 /* If the numSamples is not a multiple of 4, compute any remaining output samples here.
142 ** No loop unrolling is used. */
143 blkCnt = numSamples % 0x4U;
145 #else
147 /* Run the below code for Cortex-M0 */
148 blkCnt = numSamples;
151 #endif /* #if defined (ARM_MATH_DSP) */
153 while (blkCnt > 0U)
155 /* C[0]+jC[1] = A[0]+ j (-1) A[1] */
156 /* Calculate Complex Conjugate and then store the results in the destination buffer. */
157 /* Saturated to 0x7fffffff if the input is -1(0x80000000) */
158 *pDst++ = *pSrc++;
159 in = *pSrc++;
160 *pDst++ = (in == INT32_MIN) ? INT32_MAX : -in;
162 /* Decrement the loop counter */
163 blkCnt--;
168 * @} end of cmplx_conj group