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