1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_cmplx_conj_f16.c
4 * Description: Floating-point complex conjugate
5 *
6 * $Date: 23 April 2021
7 * $Revision: V1.9.0
8 *
9 * Target Processor: Cortex-M and Cortex-A cores
10 * -------------------------------------------------------------------- */
11 /*
12 * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
13 *
14 * SPDX-License-Identifier: Apache-2.0
15 *
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
19 *
20 * www.apache.org/licenses/LICENSE-2.0
21 *
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.
27 */
28
29 #include "dsp/complex_math_functions_f16.h"
30
31 #if defined(ARM_FLOAT16_SUPPORTED)
32 /**
33 @ingroup groupCmplxMath
34 */
35
36
37 /**
38 @addtogroup cmplx_conj
39 @{
40 */
41
42 /**
43 @brief Floating-point complex conjugate.
44 @param[in] pSrc points to the input vector
45 @param[out] pDst points to the output vector
46 @param[in] numSamples number of samples in each vector
47 @return none
48 */
49
50 #if defined(ARM_MATH_MVE_FLOAT16) && !defined(ARM_MATH_AUTOVECTORIZE)
51
arm_cmplx_conj_f16(const float16_t * pSrc,float16_t * pDst,uint32_t numSamples)52 void arm_cmplx_conj_f16(
53 const float16_t * pSrc,
54 float16_t * pDst,
55 uint32_t numSamples)
56 {
57 static const float16_t cmplx_conj_sign[8] = { 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f };
58 uint32_t blockSize = numSamples * CMPLX_DIM; /* loop counters */
59 uint32_t blkCnt;
60 f16x8_t vecSrc;
61 f16x8_t vecSign;
62
63 /*
64 * load sign vector
65 */
66 vecSign = *(f16x8_t *) cmplx_conj_sign;
67
68 /* Compute 4 real samples at a time */
69 blkCnt = blockSize >> 3U;
70
71 while (blkCnt > 0U)
72 {
73 vecSrc = vld1q(pSrc);
74 vst1q(pDst,vmulq(vecSrc, vecSign));
75 /*
76 * Decrement the blkCnt loop counter
77 * Advance vector source and destination pointers
78 */
79 pSrc += 8;
80 pDst += 8;
81 blkCnt--;
82 }
83
84 /* Tail */
85 blkCnt = (blockSize & 0x7) >> 1;
86
87 while (blkCnt > 0U)
88 {
89 /* C[0] + jC[1] = A[0]+ j(-1)A[1] */
90
91 /* Calculate Complex Conjugate and store result in destination buffer. */
92 *pDst++ = *pSrc++;
93 *pDst++ = -(_Float16)*pSrc++;
94
95 /* Decrement loop counter */
96 blkCnt--;
97 }
98
99 }
100
101 #else
arm_cmplx_conj_f16(const float16_t * pSrc,float16_t * pDst,uint32_t numSamples)102 void arm_cmplx_conj_f16(
103 const float16_t * pSrc,
104 float16_t * pDst,
105 uint32_t numSamples)
106 {
107 uint32_t blkCnt; /* Loop counter */
108
109 #if defined (ARM_MATH_LOOPUNROLL) && !defined(ARM_MATH_AUTOVECTORIZE)
110
111 /* Loop unrolling: Compute 4 outputs at a time */
112 blkCnt = numSamples >> 2U;
113
114 while (blkCnt > 0U)
115 {
116 /* C[0] + jC[1] = A[0]+ j(-1)A[1] */
117
118 /* Calculate Complex Conjugate and store result in destination buffer. */
119 *pDst++ = *pSrc++;
120 *pDst++ = -(_Float16)*pSrc++;
121
122 *pDst++ = *pSrc++;
123 *pDst++ = -(_Float16)*pSrc++;
124
125 *pDst++ = *pSrc++;
126 *pDst++ = -(_Float16)*pSrc++;
127
128 *pDst++ = *pSrc++;
129 *pDst++ = -(_Float16)*pSrc++;
130
131 /* Decrement loop counter */
132 blkCnt--;
133 }
134
135 /* Loop unrolling: Compute remaining outputs */
136 blkCnt = numSamples % 0x4U;
137
138 #else
139
140 /* Initialize blkCnt with number of samples */
141 blkCnt = numSamples;
142
143 #endif /* #if defined (ARM_MATH_LOOPUNROLL) */
144
145 while (blkCnt > 0U)
146 {
147 /* C[0] + jC[1] = A[0]+ j(-1)A[1] */
148
149 /* Calculate Complex Conjugate and store result in destination buffer. */
150 *pDst++ = *pSrc++;
151 *pDst++ = -(_Float16)*pSrc++;
152
153 /* Decrement loop counter */
154 blkCnt--;
155 }
156
157 }
158 #endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */
159
160 /**
161 @} end of cmplx_conj group
162 */
163 #endif /* #if defined(ARM_FLOAT16_SUPPORTED) */
164