1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
4 * Description: Minimum value of a floating-point vector
6 * $Date: 27. January 2017
9 * Target Processor: Cortex-M cores
10 * -------------------------------------------------------------------- */
12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
14 * SPDX-License-Identifier: Apache-2.0
16 * Licensed under the Apache License, Version 2.0 (the License); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
20 * www.apache.org/licenses/LICENSE-2.0
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
36 * @defgroup Min Minimum
38 * Computes the minimum value of an array of data.
39 * The function returns both the minimum value and its position within the array.
40 * There are separate functions for floating-point, Q31, Q15, and Q7 data types.
50 * @brief Minimum value of a floating-point vector.
51 * @param[in] *pSrc points to the input vector
52 * @param[in] blockSize length of the input vector
53 * @param[out] *pResult minimum value returned here
54 * @param[out] *pIndex index of minimum value returned here
64 #if defined (ARM_MATH_DSP)
65 /* Run the below code for Cortex-M4 and Cortex-M3 */
67 float32_t minVal1
, minVal2
, out
; /* Temporary variables to store the output value. */
68 uint32_t blkCnt
, outIndex
, count
; /* loop counter */
70 /* Initialise the count value. */
72 /* Initialise the index value to zero. */
74 /* Load first input value that act as reference value for comparision */
78 blkCnt
= (blockSize
- 1U) >> 2U;
82 /* Initialize minVal to the next consecutive values one by one */
86 /* compare for the minimum value */
89 /* Update the minimum value and its index */
91 outIndex
= count
+ 1U;
94 /* compare for the minimum value */
97 /* Update the minimum value and its index */
99 outIndex
= count
+ 2U;
102 /* Initialize minVal to the next consecutive values one by one */
106 /* compare for the minimum value */
109 /* Update the minimum value and its index */
111 outIndex
= count
+ 3U;
114 /* compare for the minimum value */
117 /* Update the minimum value and its index */
119 outIndex
= count
+ 4U;
124 /* Decrement the loop counter */
128 /* if (blockSize - 1U) is not multiple of 4 */
129 blkCnt
= (blockSize
- 1U) % 4U;
132 /* Run the below code for Cortex-M0 */
134 float32_t minVal1
, out
; /* Temporary variables to store the output value. */
135 uint32_t blkCnt
, outIndex
; /* loop counter */
137 /* Initialise the index value to zero. */
139 /* Load first input value that act as reference value for comparision */
142 blkCnt
= (blockSize
- 1U);
144 #endif /* #if defined (ARM_MATH_DSP) */
148 /* Initialize minVal to the next consecutive values one by one */
151 /* compare for the minimum value */
154 /* Update the minimum value and it's index */
156 outIndex
= blockSize
- blkCnt
;
159 /* Decrement the loop counter */
163 /* Store the minimum value and it's index into destination pointers */
169 * @} end of Min group