1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_cmplx_conj_q31.c
4 * Description: Q31 complex conjugate
6 * $Date: 27. January 2017
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.
32 * @ingroup groupCmplxMath
36 * @addtogroup cmplx_conj
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
47 * <b>Scaling and Overflow Behavior:</b>
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(
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 */
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. */
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 */
79 /* store real input sample */
82 /* read imaginary input sample */
85 /* read real input sample */
87 /* store real input sample */
90 /* read imaginary input sample */
93 /* negate imaginary input sample */
94 inI1
= __QSUB(0, inI1
);
96 /* read real input sample */
98 /* store real input sample */
101 /* read imaginary input sample */
104 /* negate imaginary input sample */
105 inI2
= __QSUB(0, inI2
);
107 /* read real input sample */
109 /* store real input sample */
112 /* negate imaginary input sample */
113 inI3
= __QSUB(0, inI3
);
115 /* store imaginary input sample */
118 /* store imaginary input samples */
121 /* negate imaginary input sample */
122 inI4
= __QSUB(0, inI4
);
124 /* store imaginary input samples */
127 /* increment source pointer by 8 to proecess next samples */
130 /* store imaginary input samples */
134 /* increment destination pointer by 8 to process next samples */
137 /* Decrement the loop counter */
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
;
147 /* Run the below code for Cortex-M0 */
151 #endif /* #if defined (ARM_MATH_DSP) */
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) */
160 *pDst
++ = (in
== INT32_MIN
) ? INT32_MAX
: -in
;
162 /* Decrement the loop counter */
168 * @} end of cmplx_conj group