]> git.gag.com Git - fw/stlink/blob - exampleF4/CMSIS/DSP_Lib/Source/StatisticsFunctions/arm_min_q31.c
Added all the F4 libraries to the project
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / StatisticsFunctions / arm_min_q31.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_q31.c   
9 *   
10 * Description:  Minimum value of a Q31 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 Q31 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_q31(
54   q31_t * pSrc,
55   uint32_t blockSize,
56   q31_t * pResult,
57   uint32_t * pIndex)
58 {
59   q31_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   /* Loop over blockSize number of values */
72   blkCnt = (blockSize - 1u);
73
74   do
75   {
76     /* Initialize minVal to the next consecutive values one by one */
77     minVal = *pSrc++;
78
79     /* compare for the minimum value */
80     if(out > minVal)
81     {
82       /* Update the minimum value and its index */
83       out = minVal;
84       outIndex = blockSize - blkCnt;
85     }
86
87     blkCnt--;
88
89   } while(blkCnt > 0u);
90
91 #else
92
93   /* Run the below code for Cortex-M0 */
94
95   /* Loop over blockSize -1 number of values */
96   blkCnt = (blockSize - 1u);
97
98   while(blkCnt > 0u)
99   {
100     /* Initialize minVal to the next consecutive values one by one */
101     minVal = *pSrc++;
102
103     /* compare for the minimum value */
104     if(out > minVal)
105     {
106       /* Update the minimum value and its index */
107       out = minVal;
108       outIndex = blockSize - blkCnt;
109     }
110
111     /* Decrement the loop counter */
112     blkCnt--;
113
114   }
115
116 #endif /* #ifndef ARM_MATH_CM0 */
117
118   /* Store the minimum value and its index into destination pointers */
119   *pResult = out;
120   *pIndex = outIndex;
121 }
122
123 /**   
124  * @} end of Min group   
125  */