1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
4 * Description: Maximum 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.
42 * @brief Maximum value of a Q31 vector.
43 * @param[in] *pSrc points to the input vector
44 * @param[in] blockSize length of the input vector
45 * @param[out] *pResult maximum value returned here
46 * @param[out] *pIndex index of maximum value returned here
56 #if defined (ARM_MATH_DSP)
57 /* Run the below code for Cortex-M4 and Cortex-M3 */
59 q31_t maxVal1
, maxVal2
, out
; /* Temporary variables to store the output value. */
60 uint32_t blkCnt
, outIndex
, count
; /* loop counter */
62 /* Initialise the count value. */
64 /* Initialise the index value to zero. */
66 /* Load first input value that act as reference value for comparision */
70 blkCnt
= (blockSize
- 1U) >> 2U;
74 /* Initialize maxVal to the next consecutive values one by one */
78 /* compare for the maximum value */
81 /* Update the maximum value and its index */
83 outIndex
= count
+ 1U;
86 /* compare for the maximum value */
89 /* Update the maximum value and its index */
91 outIndex
= count
+ 2U;
94 /* Initialize maxVal to the next consecutive values one by one */
98 /* compare for the maximum value */
101 /* Update the maximum value and its index */
103 outIndex
= count
+ 3U;
106 /* compare for the maximum value */
109 /* Update the maximum value and its index */
111 outIndex
= count
+ 4U;
116 /* Decrement the loop counter */
120 /* if (blockSize - 1U) is not multiple of 4 */
121 blkCnt
= (blockSize
- 1U) % 4U;
124 /* Run the below code for Cortex-M0 */
126 q31_t maxVal1
, out
; /* Temporary variables to store the output value. */
127 uint32_t blkCnt
, outIndex
; /* loop counter */
129 /* Initialise the index value to zero. */
131 /* Load first input value that act as reference value for comparision */
134 blkCnt
= (blockSize
- 1U);
136 #endif /* #if defined (ARM_MATH_DSP) */
140 /* Initialize maxVal to the next consecutive values one by one */
143 /* compare for the maximum value */
146 /* Update the maximum value and it's index */
148 outIndex
= blockSize
- blkCnt
;
151 /* Decrement the loop counter */
155 /* Store the maximum value and it's index into destination pointers */
161 * @} end of Max group