Added all the F4 libraries to the project
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / StatisticsFunctions / arm_min_f32.c
1 /* ----------------------------------------------------------------------   
2 * Copyright (C) 2010 ARM Limited. All rights reserved.   
3 *   
4 * $Date:        15. July 2011  
5 * $Revision:    V1.0.10  
6 *   
7 * Project:          CMSIS DSP Library   
8 * Title:                arm_min_f32.c   
9 *   
10 * Description:  Minimum value of a floating-point vector.   
11 *   
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
13 *  
14 * Version 1.0.10 2011/7/15 
15 *    Big Endian support added and Merged M0 and M3/M4 Source code.  
16 *   
17 * Version 1.0.3 2010/11/29  
18 *    Re-organized the CMSIS folders and updated documentation.   
19 *    
20 * Version 1.0.2 2010/11/11   
21 *    Documentation updated.    
22 *   
23 * Version 1.0.1 2010/10/05    
24 *    Production release and review comments incorporated.   
25 *   
26 * Version 1.0.0 2010/09/20    
27 *    Production release and review comments incorporated.   
28 * ---------------------------------------------------------------------------- */
29
30 #include "arm_math.h"
31
32 /**   
33  * @ingroup groupStats   
34  */
35
36 /**   
37  * @defgroup Min Minimum   
38  *   
39  * Computes the minimum value of an array of data.    
40  * The function returns both the minimum value and its position within the array.    
41  * There are separate functions for floating-point, Q31, Q15, and Q7 data types.   
42  */
43
44 /**   
45  * @addtogroup Min   
46  * @{   
47  */
48
49
50 /**   
51  * @brief Minimum 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 minimum value returned here   
55  * @param[out]      *pIndex index of minimum value returned here   
56   * @return none.   
57  *   
58  */
59
60 void arm_min_f32(
61   float32_t * pSrc,
62   uint32_t blockSize,
63   float32_t * pResult,
64   uint32_t * pIndex)
65 {
66   float32_t minVal, out;                         /* Temporary variables to store the output value. */
67   uint32_t blkCnt, outIndex;                     /* loop counter */
68
69   /* Initialise the index value to zero. */
70   outIndex = 0u;
71   /* Load first input value that act as reference value for comparision */
72   out = *pSrc++;
73
74 #ifndef ARM_MATH_CM0
75
76   /* Run the below code for Cortex-M4 and Cortex-M3 */
77
78
79   /* Loop over blockSize number of values */
80   blkCnt = (blockSize - 1u);
81
82   do
83   {
84     /* Initialize minVal to the next consecutive values one by one */
85     minVal = *pSrc++;
86
87     /* compare for the minimum value */
88     if(out > minVal)
89     {
90       /* Update the minimum value and it's index */
91       out = minVal;
92       outIndex = blockSize - blkCnt;
93     }
94
95     blkCnt--;
96
97   } while(blkCnt > 0u);
98
99 #else
100
101   /* Run the below code for Cortex-M0 */
102
103   /* Loop over blockSize - 1 number of values */
104   blkCnt = (blockSize - 1u);
105
106   while(blkCnt > 0u)
107   {
108     /* Initialize minVal to the next consecutive values one by one */
109     minVal = *pSrc++;
110
111     /* compare for the minimum value */
112     if(out > minVal)
113     {
114       /* Update the minimum value and it's index */
115       out = minVal;
116       outIndex = blockSize - blkCnt;
117     }
118     /* Decrement the loop counter */
119     blkCnt--;
120
121   }
122
123 #endif /* #ifndef ARM_MATH_CM0 */
124
125
126   /* Store the minimum value and it's index into destination pointers */
127   *pResult = out;
128   *pIndex = outIndex;
129 }
130
131 /**   
132  * @} end of Min group   
133  */