1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_cmplx_conj_q15.c
4 * Description: Q15 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 Q15 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 Q15 value -1 (0x8000) will be saturated to the maximum allowable positive value 0x7FFF.
53 void arm_cmplx_conj_q15(
59 #if defined (ARM_MATH_DSP)
61 /* Run the below code for Cortex-M4 and Cortex-M3 */
62 uint32_t blkCnt
; /* loop counter */
63 q31_t in1
, in2
, in3
, in4
;
67 blkCnt
= numSamples
>> 2U;
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. */
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 in1
= *__SIMD32(pSrc
)++;
76 in2
= *__SIMD32(pSrc
)++;
77 in3
= *__SIMD32(pSrc
)++;
78 in4
= *__SIMD32(pSrc
)++;
80 #ifndef ARM_MATH_BIG_ENDIAN
82 in1
= __QASX(zero
, in1
);
83 in2
= __QASX(zero
, in2
);
84 in3
= __QASX(zero
, in3
);
85 in4
= __QASX(zero
, in4
);
89 in1
= __QSAX(zero
, in1
);
90 in2
= __QSAX(zero
, in2
);
91 in3
= __QSAX(zero
, in3
);
92 in4
= __QSAX(zero
, in4
);
94 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
96 in1
= ((uint32_t) in1
>> 16) | ((uint32_t) in1
<< 16);
97 in2
= ((uint32_t) in2
>> 16) | ((uint32_t) in2
<< 16);
98 in3
= ((uint32_t) in3
>> 16) | ((uint32_t) in3
<< 16);
99 in4
= ((uint32_t) in4
>> 16) | ((uint32_t) in4
<< 16);
101 *__SIMD32(pDst
)++ = in1
;
102 *__SIMD32(pDst
)++ = in2
;
103 *__SIMD32(pDst
)++ = in3
;
104 *__SIMD32(pDst
)++ = in4
;
106 /* Decrement the loop counter */
110 /* If the numSamples is not a multiple of 4, compute any remaining output samples here.
111 ** No loop unrolling is used. */
112 blkCnt
= numSamples
% 0x4U
;
116 /* C[0]+jC[1] = A[0]+ j (-1) A[1] */
117 /* Calculate Complex Conjugate and then store the results in the destination buffer. */
119 *pDst
++ = __SSAT(-*pSrc
++, 16);
121 /* Decrement the loop counter */
129 /* Run the below code for Cortex-M0 */
131 while (numSamples
> 0U)
133 /* realOut + j (imagOut) = realIn+ j (-1) imagIn */
134 /* Calculate Complex Conjugate and then store the results in the destination buffer. */
137 *pDst
++ = (in
== (q15_t
) 0x8000) ? 0x7fff : -in
;
139 /* Decrement the loop counter */
143 #endif /* #if defined (ARM_MATH_DSP) */
148 * @} end of cmplx_conj group