1 /* ----------------------------------------------------------------------
2 * Copyright (C) 2010 ARM Limited. All rights reserved.
7 * Project: CMSIS DSP Library
10 * Description: Maximum value of a floating-point vector.
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
14 * Version 1.0.10 2011/7/15
15 * Big Endian support added and Merged M0 and M3/M4 Source code.
17 * Version 1.0.3 2010/11/29
18 * Re-organized the CMSIS folders and updated documentation.
20 * Version 1.0.2 2010/11/11
21 * Documentation updated.
23 * Version 1.0.1 2010/10/05
24 * Production release and review comments incorporated.
26 * Version 1.0.0 2010/09/20
27 * Production release and review comments incorporated.
28 * ---------------------------------------------------------------------------- */
37 * @defgroup Max Maximum
39 * Computes the maximum value of an array of data.
40 * The function returns both the maximum value and its position within the array.
41 * There are separate functions for floating-point, Q31, Q15, and Q7 data types.
51 * @brief Maximum value of a floating-point vector.
52 * @param[in] *pSrc points to the input vector
53 * @param[in] blockSize length of the input vector
54 * @param[out] *pResult maximum value returned here
55 * @param[out] *pIndex index of maximum value returned here
65 float32_t maxVal, out; /* Temporary variables to store the output value. */
66 uint32_t blkCnt, outIndex; /* loop counter */
68 /* Initialise the index value to zero. */
70 /* Load first input value that act as reference value for comparision */
73 /* Loop over blockSize number of values */
74 blkCnt = (blockSize - 1u);
78 /* Run the below code for Cortex-M4 and Cortex-M3 */
82 /* Initialize maxVal to the next consecutive values one by one */
85 /* compare for the maximum value */
88 /* Update the maximum value and it's index */
90 outIndex = blockSize - blkCnt;
92 /* Decrement the loop counter */
99 /* Run the below code for Cortex-M0 */
102 /* Initialize maxVal to the next consecutive values one by one */
105 /* compare for the maximum value */
108 /* Update the maximum value and it's index */
110 outIndex = blockSize - blkCnt;
112 /* Decrement the loop counter */
117 #endif /* #ifndef ARM_MATH_CM0 */
120 /* Store the maximum value and it's index into destination pointers */
126 * @} end of Max group