1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
4 * Description: Minimum value of a Q31 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.
43 * @brief Minimum value of a Q31 vector.
44 * @param[in] *pSrc points to the input vector
45 * @param[in] blockSize length of the input vector
46 * @param[out] *pResult minimum value returned here
47 * @param[out] *pIndex index of minimum value returned here
57 #if defined (ARM_MATH_DSP)
58 /* Run the below code for Cortex-M4 and Cortex-M3 */
60 q31_t minVal1
, minVal2
, out
; /* Temporary variables to store the output value. */
61 uint32_t blkCnt
, outIndex
, count
; /* loop counter */
63 /* Initialise the count value. */
65 /* Initialise the index value to zero. */
67 /* Load first input value that act as reference value for comparision */
71 blkCnt
= (blockSize
- 1U) >> 2U;
75 /* Initialize minVal to the next consecutive values one by one */
79 /* compare for the minimum value */
82 /* Update the minimum value and its index */
84 outIndex
= count
+ 1U;
87 /* compare for the minimum value */
90 /* Update the minimum value and its index */
92 outIndex
= count
+ 2U;
95 /* Initialize minVal to the next consecutive values one by one */
99 /* compare for the minimum value */
102 /* Update the minimum value and its index */
104 outIndex
= count
+ 3U;
107 /* compare for the minimum value */
110 /* Update the minimum value and its index */
112 outIndex
= count
+ 4U;
117 /* Decrement the loop counter */
121 /* if (blockSize - 1U) is not multiple of 4 */
122 blkCnt
= (blockSize
- 1U) % 4U;
125 /* Run the below code for Cortex-M0 */
127 q31_t minVal1
, out
; /* Temporary variables to store the output value. */
128 uint32_t blkCnt
, outIndex
; /* loop counter */
130 /* Initialise the index value to zero. */
132 /* Load first input value that act as reference value for comparision */
135 blkCnt
= (blockSize
- 1U);
137 #endif /* #if defined (ARM_MATH_DSP) */
141 /* Initialize minVal to the next consecutive values one by one */
144 /* compare for the minimum value */
147 /* Update the minimum value and it's index */
149 outIndex
= blockSize
- blkCnt
;
152 /* Decrement the loop counter */
156 /* Store the minimum value and it's index into destination pointers */
162 * @} end of Min group