STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
arm_cmplx_dot_prod_f32.c
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------
2 * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
3 *
4 * $Date: 19. March 2015
5 * $Revision: V.1.4.5
6 *
7 * Project: CMSIS DSP Library
8 * Title: arm_cmplx_dot_prod_f32.c
9 *
10 * Description: Floating-point complex dot product
11 *
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * - Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * - Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in
21 * the documentation and/or other materials provided with the
22 * distribution.
23 * - Neither the name of ARM LIMITED nor the names of its contributors
24 * may be used to endorse or promote products derived from this
25 * software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 * ---------------------------------------------------------------------------- */
40 
41 #include "arm_math.h"
42 
89  float32_t * pSrcA,
90  float32_t * pSrcB,
91  uint32_t numSamples,
92  float32_t * realResult,
93  float32_t * imagResult)
94 {
95  float32_t real_sum = 0.0f, imag_sum = 0.0f; /* Temporary result storage */
96  float32_t a0,b0,c0,d0;
97 
98 #ifndef ARM_MATH_CM0_FAMILY
99 
100  /* Run the below code for Cortex-M4 and Cortex-M3 */
101  uint32_t blkCnt; /* loop counter */
102 
103  /*loop Unrolling */
104  blkCnt = numSamples >> 2u;
105 
106  /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
107  ** a second loop below computes the remaining 1 to 3 samples. */
108  while(blkCnt > 0u)
109  {
110  a0 = *pSrcA++;
111  b0 = *pSrcA++;
112  c0 = *pSrcB++;
113  d0 = *pSrcB++;
114 
115  real_sum += a0 * c0;
116  imag_sum += a0 * d0;
117  real_sum -= b0 * d0;
118  imag_sum += b0 * c0;
119 
120  a0 = *pSrcA++;
121  b0 = *pSrcA++;
122  c0 = *pSrcB++;
123  d0 = *pSrcB++;
124 
125  real_sum += a0 * c0;
126  imag_sum += a0 * d0;
127  real_sum -= b0 * d0;
128  imag_sum += b0 * c0;
129 
130  a0 = *pSrcA++;
131  b0 = *pSrcA++;
132  c0 = *pSrcB++;
133  d0 = *pSrcB++;
134 
135  real_sum += a0 * c0;
136  imag_sum += a0 * d0;
137  real_sum -= b0 * d0;
138  imag_sum += b0 * c0;
139 
140  a0 = *pSrcA++;
141  b0 = *pSrcA++;
142  c0 = *pSrcB++;
143  d0 = *pSrcB++;
144 
145  real_sum += a0 * c0;
146  imag_sum += a0 * d0;
147  real_sum -= b0 * d0;
148  imag_sum += b0 * c0;
149 
150  /* Decrement the loop counter */
151  blkCnt--;
152  }
153 
154  /* If the numSamples is not a multiple of 4, compute any remaining output samples here.
155  ** No loop unrolling is used. */
156  blkCnt = numSamples & 0x3u;
157 
158  while(blkCnt > 0u)
159  {
160  a0 = *pSrcA++;
161  b0 = *pSrcA++;
162  c0 = *pSrcB++;
163  d0 = *pSrcB++;
164 
165  real_sum += a0 * c0;
166  imag_sum += a0 * d0;
167  real_sum -= b0 * d0;
168  imag_sum += b0 * c0;
169 
170  /* Decrement the loop counter */
171  blkCnt--;
172  }
173 
174 #else
175 
176  /* Run the below code for Cortex-M0 */
177 
178  while(numSamples > 0u)
179  {
180  a0 = *pSrcA++;
181  b0 = *pSrcA++;
182  c0 = *pSrcB++;
183  d0 = *pSrcB++;
184 
185  real_sum += a0 * c0;
186  imag_sum += a0 * d0;
187  real_sum -= b0 * d0;
188  imag_sum += b0 * c0;
189 
190  /* Decrement the loop counter */
191  numSamples--;
192  }
193 
194 #endif /* #ifndef ARM_MATH_CM0_FAMILY */
195 
196  /* Store the real and imaginary results in the destination buffers */
197  *realResult = real_sum;
198  *imagResult = imag_sum;
199 }
200 
float float32_t
32-bit floating-point type definition.
Definition: arm_math.h:407
void arm_cmplx_dot_prod_f32(float32_t *pSrcA, float32_t *pSrcB, uint32_t numSamples, float32_t *realResult, float32_t *imagResult)
Floating-point complex dot product.