]> git.gag.com Git - fw/stlink/blob - exampleF4/CMSIS/DSP_Lib/Source/StatisticsFunctions/arm_min_q15.c
Added all the F4 libraries to the project
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / StatisticsFunctions / arm_min_q15.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_q15.c   
9 *   
10 * Description:  Minimum value of a Q15 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 /**   
38  * @addtogroup Min   
39  * @{   
40  */
41
42
43 /**   
44  * @brief Minimum value of a Q15 vector.   
45  * @param[in]       *pSrc points to the input vector   
46  * @param[in]       blockSize length of the input vector   
47  * @param[out]      *pResult minimum value returned here   
48  * @param[out]      *pIndex index of minimum value returned here   
49  * @return none.   
50  *   
51  */
52
53 void arm_min_q15(
54   q15_t * pSrc,
55   uint32_t blockSize,
56   q15_t * pResult,
57   uint32_t * pIndex)
58 {
59   q15_t minVal, out;                             /* Temporary variables to store the output value. */
60   uint32_t blkCnt, outIndex;                     /* loop counter */
61
62   /* Initialise the index value to zero. */
63   outIndex = 0u;
64   /* Load first input value that act as reference value for comparision */
65   out = *pSrc++;
66
67 #ifndef ARM_MATH_CM0
68
69   /* Run the below code for Cortex-M4 and Cortex-M3 */
70
71
72   /* Loop over blockSize number of values */
73   blkCnt = (blockSize - 1u);
74
75   do
76   {
77     /* Initialize minVal to the next consecutive values one by one */
78     minVal = *pSrc++;
79
80     /* compare for the minimum value */
81     if(out > minVal)
82     {
83       /* Update the minimum value and its index */
84       out = minVal;
85       outIndex = blockSize - blkCnt;
86     }
87
88     blkCnt--;
89
90   } while(blkCnt > 0u);
91
92 #else
93
94   /* Run the below code for Cortex-M0 */
95
96   /* Loop over blockSize - 1 number of values */
97   blkCnt = (blockSize - 1u);
98
99   while(blkCnt > 0u)
100   {
101     /* Initialize minVal to the next consecutive values one by one */
102     minVal = *pSrc++;
103
104     /* compare for the minimum value */
105     if(out > minVal)
106     {
107       /* Update the minimum value and its index */
108       out = minVal;
109       outIndex = blockSize - blkCnt;
110     }
111
112     /* Decrement the loop counter */
113     blkCnt--;
114
115   }
116
117 #endif /* #ifndef ARM_MATH_CM0 */
118
119
120   /* Store the minimum value and its index into destination pointers */
121   *pResult = out;
122   *pIndex = outIndex;
123 }
124
125 /**   
126  * @} end of Min group   
127  */