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_sub_f32.c
00001 /* ---------------------------------------------------------------------- 00002 * Project: CMSIS DSP Library 00003 * Title: arm_sub_f32.c 00004 * Description: Floating-point vector subtraction. 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 BasicSub Vector Subtraction 00037 * 00038 * Element-by-element subtraction of two vectors. 00039 * 00040 * <pre> 00041 * pDst[n] = pSrcA[n] - pSrcB[n], 0 <= n < blockSize. 00042 * </pre> 00043 * 00044 * There are separate functions for floating-point, Q7, Q15, and Q31 data types. 00045 */ 00046 00047 /** 00048 * @addtogroup BasicSub 00049 * @{ 00050 */ 00051 00052 00053 /** 00054 * @brief Floating-point vector subtraction. 00055 * @param[in] *pSrcA points to the first input vector 00056 * @param[in] *pSrcB points to the second input vector 00057 * @param[out] *pDst points to the output vector 00058 * @param[in] blockSize number of samples in each vector 00059 * @return none. 00060 */ 00061 00062 void arm_sub_f32( 00063 float32_t * pSrcA, 00064 float32_t * pSrcB, 00065 float32_t * pDst, 00066 uint32_t blockSize) 00067 { 00068 uint32_t blkCnt; /* loop counter */ 00069 00070 #if defined (ARM_MATH_DSP) 00071 00072 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00073 float32_t inA1, inA2, inA3, inA4; /* temporary variables */ 00074 float32_t inB1, inB2, inB3, inB4; /* temporary variables */ 00075 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 - B */ 00084 /* Subtract and then store the results in the destination buffer. */ 00085 /* Read 4 input samples from sourceA and sourceB */ 00086 inA1 = *pSrcA; 00087 inB1 = *pSrcB; 00088 inA2 = *(pSrcA + 1); 00089 inB2 = *(pSrcB + 1); 00090 inA3 = *(pSrcA + 2); 00091 inB3 = *(pSrcB + 2); 00092 inA4 = *(pSrcA + 3); 00093 inB4 = *(pSrcB + 3); 00094 00095 /* dst = srcA - srcB */ 00096 /* subtract and store the result */ 00097 *pDst = inA1 - inB1; 00098 *(pDst + 1) = inA2 - inB2; 00099 *(pDst + 2) = inA3 - inB3; 00100 *(pDst + 3) = inA4 - inB4; 00101 00102 00103 /* Update pointers to process next sampels */ 00104 pSrcA += 4U; 00105 pSrcB += 4U; 00106 pDst += 4U; 00107 00108 /* Decrement the loop counter */ 00109 blkCnt--; 00110 } 00111 00112 /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 00113 ** No loop unrolling is used. */ 00114 blkCnt = blockSize % 0x4U; 00115 00116 #else 00117 00118 /* Run the below code for Cortex-M0 */ 00119 00120 /* Initialize blkCnt with number of samples */ 00121 blkCnt = blockSize; 00122 00123 #endif /* #if defined (ARM_MATH_DSP) */ 00124 00125 while (blkCnt > 0U) 00126 { 00127 /* C = A - B */ 00128 /* Subtract and then store the results in the destination buffer. */ 00129 *pDst++ = (*pSrcA++) - (*pSrcB++); 00130 00131 /* Decrement the loop counter */ 00132 blkCnt--; 00133 } 00134 } 00135 00136 /** 00137 * @} end of BasicSub group 00138 */ 00139
Generated on Tue Jul 12 2022 16:47:28 by
