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_dot_prod_f32.c
00001 /* ---------------------------------------------------------------------- 00002 * Project: CMSIS DSP Library 00003 * Title: arm_dot_prod_f32.c 00004 * Description: Floating-point 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 groupMath 00033 */ 00034 00035 /** 00036 * @defgroup dot_prod Vector Dot Product 00037 * 00038 * Computes the dot product of two vectors. 00039 * The vectors are multiplied element-by-element and then summed. 00040 * 00041 * <pre> 00042 * sum = pSrcA[0]*pSrcB[0] + pSrcA[1]*pSrcB[1] + ... + pSrcA[blockSize-1]*pSrcB[blockSize-1] 00043 * </pre> 00044 * 00045 * There are separate functions for floating-point, Q7, Q15, and Q31 data types. 00046 */ 00047 00048 /** 00049 * @addtogroup dot_prod 00050 * @{ 00051 */ 00052 00053 /** 00054 * @brief Dot product of floating-point vectors. 00055 * @param[in] *pSrcA points to the first input vector 00056 * @param[in] *pSrcB points to the second input vector 00057 * @param[in] blockSize number of samples in each vector 00058 * @param[out] *result output result returned here 00059 * @return none. 00060 */ 00061 00062 00063 void arm_dot_prod_f32( 00064 float32_t * pSrcA, 00065 float32_t * pSrcB, 00066 uint32_t blockSize, 00067 float32_t * result) 00068 { 00069 float32_t sum = 0.0f; /* Temporary result storage */ 00070 uint32_t blkCnt; /* loop counter */ 00071 00072 00073 #if defined (ARM_MATH_DSP) 00074 00075 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00076 /*loop Unrolling */ 00077 blkCnt = blockSize >> 2U; 00078 00079 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00080 ** a second loop below computes the remaining 1 to 3 samples. */ 00081 while (blkCnt > 0U) 00082 { 00083 /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ 00084 /* Calculate dot product and then store the result in a temporary buffer */ 00085 sum += (*pSrcA++) * (*pSrcB++); 00086 sum += (*pSrcA++) * (*pSrcB++); 00087 sum += (*pSrcA++) * (*pSrcB++); 00088 sum += (*pSrcA++) * (*pSrcB++); 00089 00090 /* Decrement the loop counter */ 00091 blkCnt--; 00092 } 00093 00094 /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 00095 ** No loop unrolling is used. */ 00096 blkCnt = blockSize % 0x4U; 00097 00098 #else 00099 00100 /* Run the below code for Cortex-M0 */ 00101 00102 /* Initialize blkCnt with number of samples */ 00103 blkCnt = blockSize; 00104 00105 #endif /* #if defined (ARM_MATH_DSP) */ 00106 00107 00108 while (blkCnt > 0U) 00109 { 00110 /* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */ 00111 /* Calculate dot product and then store the result in a temporary buffer. */ 00112 sum += (*pSrcA++) * (*pSrcB++); 00113 00114 /* Decrement the loop counter */ 00115 blkCnt--; 00116 } 00117 /* Store the result back in the destination buffer */ 00118 *result = sum; 00119 } 00120 00121 /** 00122 * @} end of dot_prod group 00123 */ 00124
Generated on Tue Jul 12 2022 16:47:27 by
1.7.2