Set blackbox file handler to NULL after closing file
[inav.git] / lib / main / CMSIS / DSP / Source / ComplexMathFunctions / arm_cmplx_conj_f32.c
blobcfb6f1f947a64b2006cb86daa27bd7c26ce28ea9
1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_cmplx_conj_f32.c
4 * Description: Floating-point 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 * @defgroup cmplx_conj Complex Conjugate
38 * Conjugates the elements of a complex data vector.
40 * The <code>pSrc</code> points to the source data and
41 * <code>pDst</code> points to the where the result should be written.
42 * <code>numSamples</code> specifies the number of complex samples
43 * and the data in each array is stored in an interleaved fashion
44 * (real, imag, real, imag, ...).
45 * Each array has a total of <code>2*numSamples</code> values.
46 * The underlying algorithm is used:
48 * <pre>
49 * for(n=0; n<numSamples; n++) {
50 * pDst[(2*n)+0)] = pSrc[(2*n)+0]; // real part
51 * pDst[(2*n)+1)] = -pSrc[(2*n)+1]; // imag part
52 * }
53 * </pre>
55 * There are separate functions for floating-point, Q15, and Q31 data types.
58 /**
59 * @addtogroup cmplx_conj
60 * @{
63 /**
64 * @brief Floating-point complex conjugate.
65 * @param *pSrc points to the input vector
66 * @param *pDst points to the output vector
67 * @param numSamples number of complex samples in each vector
68 * @return none.
71 void arm_cmplx_conj_f32(
72 float32_t * pSrc,
73 float32_t * pDst,
74 uint32_t numSamples)
76 uint32_t blkCnt; /* loop counter */
78 #if defined (ARM_MATH_DSP)
80 /* Run the below code for Cortex-M4 and Cortex-M3 */
81 float32_t inR1, inR2, inR3, inR4;
82 float32_t inI1, inI2, inI3, inI4;
84 /*loop Unrolling */
85 blkCnt = numSamples >> 2U;
87 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
88 ** a second loop below computes the remaining 1 to 3 samples. */
89 while (blkCnt > 0U)
91 /* C[0]+jC[1] = A[0]+ j (-1) A[1] */
92 /* Calculate Complex Conjugate and then store the results in the destination buffer. */
93 /* read real input samples */
94 inR1 = pSrc[0];
95 /* store real samples to destination */
96 pDst[0] = inR1;
97 inR2 = pSrc[2];
98 pDst[2] = inR2;
99 inR3 = pSrc[4];
100 pDst[4] = inR3;
101 inR4 = pSrc[6];
102 pDst[6] = inR4;
104 /* read imaginary input samples */
105 inI1 = pSrc[1];
106 inI2 = pSrc[3];
108 /* conjugate input */
109 inI1 = -inI1;
111 /* read imaginary input samples */
112 inI3 = pSrc[5];
114 /* conjugate input */
115 inI2 = -inI2;
117 /* read imaginary input samples */
118 inI4 = pSrc[7];
120 /* conjugate input */
121 inI3 = -inI3;
123 /* store imaginary samples to destination */
124 pDst[1] = inI1;
125 pDst[3] = inI2;
127 /* conjugate input */
128 inI4 = -inI4;
130 /* store imaginary samples to destination */
131 pDst[5] = inI3;
133 /* increment source pointer by 8 to process next sampels */
134 pSrc += 8U;
136 /* store imaginary sample to destination */
137 pDst[7] = inI4;
139 /* increment destination pointer by 8 to store next samples */
140 pDst += 8U;
142 /* Decrement the loop counter */
143 blkCnt--;
146 /* If the numSamples is not a multiple of 4, compute any remaining output samples here.
147 ** No loop unrolling is used. */
148 blkCnt = numSamples % 0x4U;
150 #else
152 /* Run the below code for Cortex-M0 */
153 blkCnt = numSamples;
155 #endif /* #if defined (ARM_MATH_DSP) */
157 while (blkCnt > 0U)
159 /* realOut + j (imagOut) = realIn + j (-1) imagIn */
160 /* Calculate Complex Conjugate and then store the results in the destination buffer. */
161 *pDst++ = *pSrc++;
162 *pDst++ = -*pSrc++;
164 /* Decrement the loop counter */
165 blkCnt--;
170 * @} end of cmplx_conj group