Aded CMSIS5 DSP and NN folder. Needs some work
Embed:
(wiki syntax)
Show/hide line numbers
arm_max_q7.c
00001 /* ---------------------------------------------------------------------- 00002 * Project: CMSIS DSP Library 00003 * Title: arm_max_q7.c 00004 * Description: Maximum value of a Q7 vector 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 groupStats 00033 */ 00034 00035 /** 00036 * @addtogroup Max 00037 * @{ 00038 */ 00039 00040 00041 /** 00042 * @brief Maximum value of a Q7 vector. 00043 * @param[in] *pSrc points to the input vector 00044 * @param[in] blockSize length of the input vector 00045 * @param[out] *pResult maximum value returned here 00046 * @param[out] *pIndex index of maximum value returned here 00047 * @return none. 00048 */ 00049 00050 void arm_max_q7( 00051 q7_t * pSrc, 00052 uint32_t blockSize, 00053 q7_t * pResult, 00054 uint32_t * pIndex) 00055 { 00056 #if defined (ARM_MATH_DSP) 00057 /* Run the below code for Cortex-M4 and Cortex-M3 */ 00058 00059 q7_t maxVal1, maxVal2, out; /* Temporary variables to store the output value. */ 00060 uint32_t blkCnt, outIndex, count; /* loop counter */ 00061 00062 /* Initialise the count value. */ 00063 count = 0U; 00064 /* Initialise the index value to zero. */ 00065 outIndex = 0U; 00066 /* Load first input value that act as reference value for comparision */ 00067 out = *pSrc++; 00068 00069 /* Loop unrolling */ 00070 blkCnt = (blockSize - 1U) >> 2U; 00071 00072 while (blkCnt > 0U) 00073 { 00074 /* Initialize maxVal to the next consecutive values one by one */ 00075 maxVal1 = *pSrc++; 00076 maxVal2 = *pSrc++; 00077 00078 /* compare for the maximum value */ 00079 if (out < maxVal1) 00080 { 00081 /* Update the maximum value and its index */ 00082 out = maxVal1; 00083 outIndex = count + 1U; 00084 } 00085 00086 /* compare for the maximum value */ 00087 if (out < maxVal2) 00088 { 00089 /* Update the maximum value and its index */ 00090 out = maxVal2; 00091 outIndex = count + 2U; 00092 } 00093 00094 /* Initialize maxVal to the next consecutive values one by one */ 00095 maxVal1 = *pSrc++; 00096 maxVal2 = *pSrc++; 00097 00098 /* compare for the maximum value */ 00099 if (out < maxVal1) 00100 { 00101 /* Update the maximum value and its index */ 00102 out = maxVal1; 00103 outIndex = count + 3U; 00104 } 00105 00106 /* compare for the maximum value */ 00107 if (out < maxVal2) 00108 { 00109 /* Update the maximum value and its index */ 00110 out = maxVal2; 00111 outIndex = count + 4U; 00112 } 00113 00114 count += 4U; 00115 00116 /* Decrement the loop counter */ 00117 blkCnt--; 00118 } 00119 00120 /* if (blockSize - 1U) is not multiple of 4 */ 00121 blkCnt = (blockSize - 1U) % 4U; 00122 00123 #else 00124 /* Run the below code for Cortex-M0 */ 00125 00126 q7_t maxVal1, out; /* Temporary variables to store the output value. */ 00127 uint32_t blkCnt, outIndex; /* loop counter */ 00128 00129 /* Initialise the index value to zero. */ 00130 outIndex = 0U; 00131 /* Load first input value that act as reference value for comparision */ 00132 out = *pSrc++; 00133 00134 blkCnt = (blockSize - 1U); 00135 00136 #endif /* #if defined (ARM_MATH_DSP) */ 00137 00138 while (blkCnt > 0U) 00139 { 00140 /* Initialize maxVal to the next consecutive values one by one */ 00141 maxVal1 = *pSrc++; 00142 00143 /* compare for the maximum value */ 00144 if (out < maxVal1) 00145 { 00146 /* Update the maximum value and it's index */ 00147 out = maxVal1; 00148 outIndex = blockSize - blkCnt; 00149 } 00150 00151 /* Decrement the loop counter */ 00152 blkCnt--; 00153 } 00154 00155 /* Store the maximum value and it's index into destination pointers */ 00156 *pResult = out; 00157 *pIndex = outIndex; 00158 } 00159 00160 /** 00161 * @} end of Max group 00162 */ 00163
Generated on Tue Jul 12 2022 16:47:27 by 1.7.2