Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
arm_cmplx_dot_prod_f32.c
00001 /* ---------------------------------------------------------------------- 00002 * Project: CMSIS DSP Library 00003 * Title: arm_cmplx_dot_prod_f32.c 00004 * Description: Floating-point complex dot product 00005 * 00006 * $Date: 27. January 2017 00007 * $Revision: V.1.5.1 00008 * 00009 * Target Processor: Cortex-M cores 00010 * -------------------------------------------------------------------- */ 00011 /* 00012 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. 00013 * 00014 * SPDX-License-Identifier: Apache-2.0 00015 * 00016 * Licensed under the Apache License, Version 2.0 (the License); you may 00017 * not use this file except in compliance with the License. 00018 * You may obtain a copy of the License at 00019 * 00020 * www.apache.org/licenses/LICENSE-2.0 00021 * 00022 * Unless required by applicable law or agreed to in writing, software 00023 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00024 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00025 * See the License for the specific language governing permissions and 00026 * limitations under the License. 00027 */ 00028 00029 #include "arm_math.h" 00030 00031 /** 00032 * @ingroup groupCmplxMath 00033 */ 00034 00035 /** 00036 * @defgroup cmplx_dot_prod Complex Dot Product 00037 * 00038 * Computes the dot product of two complex vectors. 00039 * The vectors are multiplied element-by-element and then summed. 00040 * 00041 * The <code>pSrcA</code> points to the first complex input vector and 00042 * <code>pSrcB</code> points to the second complex input vector. 00043 * <code>numSamples</code> specifies the number of complex samples 00044 * and the data in each array is stored in an interleaved fashion 00045 * (real, imag, real, imag, ...). 00046 * Each array has a total of <code>2*numSamples</code> values. 00047 * 00048 * The underlying algorithm is used: 00049 * <pre> 00050 * realResult=0; 00051 * imagResult=0; 00052 * for(n=0; n<numSamples; n++) { 00053 * realResult += pSrcA[(2*n)+0]*pSrcB[(2*n)+0] - pSrcA[(2*n)+1]*pSrcB[(2*n)+1]; 00054 * imagResult += pSrcA[(2*n)+0]*pSrcB[(2*n)+1] + pSrcA[(2*n)+1]*pSrcB[(2*n)+0]; 00055 * } 00056 * </pre> 00057 * 00058 * There are separate functions for floating-point, Q15, and Q31 data types. 00059 */ 00060 00061 /** 00062 * @addtogroup cmplx_dot_prod 00063 * @{ 00064 */ 00065 00066 /** 00067 * @brief Floating-point complex dot product 00068 * @param *pSrcA points to the first input vector 00069 * @param *pSrcB points to the second input vector 00070 * @param numSamples number of complex samples in each vector 00071 * @param *realResult real part of the result returned here 00072 * @param *imagResult imaginary part of the result returned here 00073 * @return none. 00074 */ 00075 00076 void arm_cmplx_dot_prod_f32( 00077 float32_t * pSrcA, 00078 float32_t * pSrcB, 00079 uint32_t numSamples, 00080 float32_t * realResult, 00081 float32_t * imagResult) 00082 { 00083 float32_t real_sum = 0.0f, imag_sum = 0.0f; /* Temporary result storage */ 00084 float32_t a0,b0,c0,d0; 00085 00086 #if defined (ARM_MATH_DSP) 00087 00088 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00089 uint32_t blkCnt; /* loop counter */ 00090 00091 /*loop Unrolling */ 00092 blkCnt = numSamples >> 2U; 00093 00094 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00095 ** a second loop below computes the remaining 1 to 3 samples. */ 00096 while (blkCnt > 0U) 00097 { 00098 a0 = *pSrcA++; 00099 b0 = *pSrcA++; 00100 c0 = *pSrcB++; 00101 d0 = *pSrcB++; 00102 00103 real_sum += a0 * c0; 00104 imag_sum += a0 * d0; 00105 real_sum -= b0 * d0; 00106 imag_sum += b0 * c0; 00107 00108 a0 = *pSrcA++; 00109 b0 = *pSrcA++; 00110 c0 = *pSrcB++; 00111 d0 = *pSrcB++; 00112 00113 real_sum += a0 * c0; 00114 imag_sum += a0 * d0; 00115 real_sum -= b0 * d0; 00116 imag_sum += b0 * c0; 00117 00118 a0 = *pSrcA++; 00119 b0 = *pSrcA++; 00120 c0 = *pSrcB++; 00121 d0 = *pSrcB++; 00122 00123 real_sum += a0 * c0; 00124 imag_sum += a0 * d0; 00125 real_sum -= b0 * d0; 00126 imag_sum += b0 * c0; 00127 00128 a0 = *pSrcA++; 00129 b0 = *pSrcA++; 00130 c0 = *pSrcB++; 00131 d0 = *pSrcB++; 00132 00133 real_sum += a0 * c0; 00134 imag_sum += a0 * d0; 00135 real_sum -= b0 * d0; 00136 imag_sum += b0 * c0; 00137 00138 /* Decrement the loop counter */ 00139 blkCnt--; 00140 } 00141 00142 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00143 ** No loop unrolling is used. */ 00144 blkCnt = numSamples & 0x3U; 00145 00146 while (blkCnt > 0U) 00147 { 00148 a0 = *pSrcA++; 00149 b0 = *pSrcA++; 00150 c0 = *pSrcB++; 00151 d0 = *pSrcB++; 00152 00153 real_sum += a0 * c0; 00154 imag_sum += a0 * d0; 00155 real_sum -= b0 * d0; 00156 imag_sum += b0 * c0; 00157 00158 /* Decrement the loop counter */ 00159 blkCnt--; 00160 } 00161 00162 #else 00163 00164 /* Run the below code for Cortex-M0 */ 00165 00166 while (numSamples > 0U) 00167 { 00168 a0 = *pSrcA++; 00169 b0 = *pSrcA++; 00170 c0 = *pSrcB++; 00171 d0 = *pSrcB++; 00172 00173 real_sum += a0 * c0; 00174 imag_sum += a0 * d0; 00175 real_sum -= b0 * d0; 00176 imag_sum += b0 * c0; 00177 00178 /* Decrement the loop counter */ 00179 numSamples--; 00180 } 00181 00182 #endif /* #if defined (ARM_MATH_DSP) */ 00183 00184 /* Store the real and imaginary results in the destination buffers */ 00185 *realResult = real_sum; 00186 *imagResult = imag_sum; 00187 } 00188 00189 /** 00190 * @} end of cmplx_dot_prod group 00191 */ 00192
Generated on Tue Jul 12 2022 16:46:23 by
1.7.2