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_negate_f32.c
00001 /* ---------------------------------------------------------------------- 00002 * Project: CMSIS DSP Library 00003 * Title: arm_negate_f32.c 00004 * Description: Negates floating-point vectors 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 negate Vector Negate 00037 * 00038 * Negates the elements of a vector. 00039 * 00040 * <pre> 00041 * pDst[n] = -pSrc[n], 0 <= n < blockSize. 00042 * </pre> 00043 * 00044 * The functions support in-place computation allowing the source and 00045 * destination pointers to reference the same memory buffer. 00046 * There are separate functions for floating-point, Q7, Q15, and Q31 data types. 00047 */ 00048 00049 /** 00050 * @addtogroup negate 00051 * @{ 00052 */ 00053 00054 /** 00055 * @brief Negates the elements of a floating-point vector. 00056 * @param[in] *pSrc points to the input vector 00057 * @param[out] *pDst points to the output vector 00058 * @param[in] blockSize number of samples in the vector 00059 * @return none. 00060 */ 00061 00062 void arm_negate_f32( 00063 float32_t * pSrc, 00064 float32_t * pDst, 00065 uint32_t blockSize) 00066 { 00067 uint32_t blkCnt; /* loop counter */ 00068 00069 00070 #if defined (ARM_MATH_DSP) 00071 00072 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00073 float32_t in1, in2, in3, in4; /* temporary variables */ 00074 00075 /*loop Unrolling */ 00076 blkCnt = blockSize >> 2U; 00077 00078 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00079 ** a second loop below computes the remaining 1 to 3 samples. */ 00080 while (blkCnt > 0U) 00081 { 00082 /* read inputs from source */ 00083 in1 = *pSrc; 00084 in2 = *(pSrc + 1); 00085 in3 = *(pSrc + 2); 00086 in4 = *(pSrc + 3); 00087 00088 /* negate the input */ 00089 in1 = -in1; 00090 in2 = -in2; 00091 in3 = -in3; 00092 in4 = -in4; 00093 00094 /* store the result to destination */ 00095 *pDst = in1; 00096 *(pDst + 1) = in2; 00097 *(pDst + 2) = in3; 00098 *(pDst + 3) = in4; 00099 00100 /* update pointers to process next samples */ 00101 pSrc += 4U; 00102 pDst += 4U; 00103 00104 /* Decrement the loop counter */ 00105 blkCnt--; 00106 } 00107 00108 /* If the blockSize is not a multiple of 4, compute any remaining output samples here. 00109 ** No loop unrolling is used. */ 00110 blkCnt = blockSize % 0x4U; 00111 00112 #else 00113 00114 /* Run the below code for Cortex-M0 */ 00115 00116 /* Initialize blkCnt with number of samples */ 00117 blkCnt = blockSize; 00118 00119 #endif /* #if defined (ARM_MATH_DSP) */ 00120 00121 while (blkCnt > 0U) 00122 { 00123 /* C = -A */ 00124 /* Negate and then store the results in the destination buffer. */ 00125 *pDst++ = -*pSrc++; 00126 00127 /* Decrement the loop counter */ 00128 blkCnt--; 00129 } 00130 } 00131 00132 /** 00133 * @} end of negate group 00134 */ 00135
Generated on Tue Jul 12 2022 16:47:27 by
