Subversion Repositories dashGPS

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/* ----------------------------------------------------------------------
2
 * Project:      CMSIS DSP Library
3
 * Title:        arm_cmplx_conj_f32.c
4
 * Description:  Floating-point complex conjugate
5
 *
6
 * $Date:        27. January 2017
7
 * $Revision:    V.1.5.1
8
 *
9
 * Target Processor: Cortex-M cores
10
 * -------------------------------------------------------------------- */
11
/*
12
 * Copyright (C) 2010-2017 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 "arm_math.h"
30
 
31
/**
32
 * @ingroup groupCmplxMath
33
 */
34
 
35
/**
36
 * @defgroup cmplx_conj Complex Conjugate
37
 *
38
 * Conjugates the elements of a complex data vector.
39
 *
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:
47
 *
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>
54
 *
55
 * There are separate functions for floating-point, Q15, and Q31 data types.
56
 */
57
 
58
/**
59
 * @addtogroup cmplx_conj
60
 * @{
61
 */
62
 
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.
69
 */
70
 
71
void arm_cmplx_conj_f32(
72
  float32_t * pSrc,
73
  float32_t * pDst,
74
  uint32_t numSamples)
75
{
76
  uint32_t blkCnt;                               /* loop counter */
77
 
78
#if defined (ARM_MATH_DSP)
79
 
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;
83
 
84
  /*loop Unrolling */
85
  blkCnt = numSamples >> 2U;
86
 
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)
90
  {
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;
103
 
104
    /* read imaginary input samples */
105
    inI1 = pSrc[1];
106
    inI2 = pSrc[3];
107
 
108
    /* conjugate input */
109
    inI1 = -inI1;
110
 
111
    /* read imaginary input samples */
112
    inI3 = pSrc[5];
113
 
114
    /* conjugate input */
115
    inI2 = -inI2;
116
 
117
    /* read imaginary input samples */
118
    inI4 = pSrc[7];
119
 
120
    /* conjugate input */
121
    inI3 = -inI3;
122
 
123
    /* store imaginary samples to destination */
124
    pDst[1] = inI1;
125
    pDst[3] = inI2;
126
 
127
    /* conjugate input */
128
    inI4 = -inI4;
129
 
130
    /* store imaginary samples to destination */
131
    pDst[5] = inI3;
132
 
133
    /* increment source pointer by 8 to process next sampels */
134
    pSrc += 8U;
135
 
136
    /* store imaginary sample to destination */
137
    pDst[7] = inI4;
138
 
139
    /* increment destination pointer by 8 to store next samples */
140
    pDst += 8U;
141
 
142
    /* Decrement the loop counter */
143
    blkCnt--;
144
  }
145
 
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;
149
 
150
#else
151
 
152
  /* Run the below code for Cortex-M0 */
153
  blkCnt = numSamples;
154
 
155
#endif /* #if defined (ARM_MATH_DSP) */
156
 
157
  while (blkCnt > 0U)
158
  {
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++;
163
 
164
    /* Decrement the loop counter */
165
    blkCnt--;
166
  }
167
}
168
 
169
/**
170
 * @} end of cmplx_conj group
171
 */