annotate f103c8/Drivers/CMSIS/DSP_Lib/Source/StatisticsFunctions/arm_min_f32.c @ 4:ca4f5b55b391

working on pwm
author cin
date Wed, 18 Jan 2017 03:27:00 +0300
parents 0c59e7a7782a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
1 /* ----------------------------------------------------------------------
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
2 * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
3 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
4 * $Date: 19. March 2015
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
5 * $Revision: V.1.4.5
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
6 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
7 * Project: CMSIS DSP Library
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
8 * Title: arm_min_f32.c
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
9 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
10 * Description: Minimum value of a floating-point vector.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
11 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
13 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
14 * Redistribution and use in source and binary forms, with or without
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
15 * modification, are permitted provided that the following conditions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
16 * are met:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
17 * - Redistributions of source code must retain the above copyright
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
18 * notice, this list of conditions and the following disclaimer.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
19 * - Redistributions in binary form must reproduce the above copyright
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
20 * notice, this list of conditions and the following disclaimer in
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
21 * the documentation and/or other materials provided with the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
22 * distribution.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
23 * - Neither the name of ARM LIMITED nor the names of its contributors
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
24 * may be used to endorse or promote products derived from this
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
25 * software without specific prior written permission.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
26 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
38 * POSSIBILITY OF SUCH DAMAGE.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
39 * ---------------------------------------------------------------------------- */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
40
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
41 #include "arm_math.h"
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
42
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
43 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
44 * @ingroup groupStats
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
45 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
46
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
47 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
48 * @defgroup Min Minimum
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
49 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
50 * Computes the minimum value of an array of data.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
51 * The function returns both the minimum value and its position within the array.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
52 * There are separate functions for floating-point, Q31, Q15, and Q7 data types.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
53 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
54
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
55 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
56 * @addtogroup Min
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
57 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
58 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
59
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
60
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
61 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
62 * @brief Minimum value of a floating-point vector.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
63 * @param[in] *pSrc points to the input vector
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
64 * @param[in] blockSize length of the input vector
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
65 * @param[out] *pResult minimum value returned here
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
66 * @param[out] *pIndex index of minimum value returned here
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
67 * @return none.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
68 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
69 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
70
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
71 void arm_min_f32(
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
72 float32_t * pSrc,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
73 uint32_t blockSize,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
74 float32_t * pResult,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
75 uint32_t * pIndex)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
76 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
77 #ifndef ARM_MATH_CM0_FAMILY
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
78
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
79 /* Run the below code for Cortex-M4 and Cortex-M3 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
80
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
81 float32_t minVal1, minVal2, out; /* Temporary variables to store the output value. */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
82 uint32_t blkCnt, outIndex, count; /* loop counter */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
83
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
84 /* Initialise the count value. */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
85 count = 0u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
86 /* Initialise the index value to zero. */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
87 outIndex = 0u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
88 /* Load first input value that act as reference value for comparision */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
89 out = *pSrc++;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
90
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
91 /* Loop unrolling */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
92 blkCnt = (blockSize - 1u) >> 2u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
93
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
94 while(blkCnt > 0)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
95 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
96 /* Initialize minVal to the next consecutive values one by one */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
97 minVal1 = *pSrc++;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
98 minVal2 = *pSrc++;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
99
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
100 /* compare for the minimum value */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
101 if(out > minVal1)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
102 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
103 /* Update the minimum value and its index */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
104 out = minVal1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
105 outIndex = count + 1u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
106 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
107
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
108 minVal1 = *pSrc++;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
109
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
110 /* compare for the minimum value */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
111 if(out > minVal2)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
112 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
113 /* Update the minimum value and its index */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
114 out = minVal2;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
115 outIndex = count + 2u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
116 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
117
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
118 minVal2 = *pSrc++;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
119
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
120 /* compare for the minimum value */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
121 if(out > minVal1)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
122 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
123 /* Update the minimum value and its index */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
124 out = minVal1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
125 outIndex = count + 3u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
126 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
127
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
128 /* compare for the minimum value */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
129 if(out > minVal2)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
130 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
131 /* Update the minimum value and its index */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
132 out = minVal2;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
133 outIndex = count + 4u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
134 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
135
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
136 count += 4u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
137
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
138 blkCnt--;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
139 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
140
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
141 /* if (blockSize - 1u ) is not multiple of 4 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
142 blkCnt = (blockSize - 1u) % 4u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
143
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
144 #else
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
145
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
146 /* Run the below code for Cortex-M0 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
147 float32_t minVal1, out; /* Temporary variables to store the output value. */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
148 uint32_t blkCnt, outIndex; /* loop counter */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
149
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
150 /* Initialise the index value to zero. */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
151 outIndex = 0u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
152 /* Load first input value that act as reference value for comparision */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
153 out = *pSrc++;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
154
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
155 blkCnt = (blockSize - 1u);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
156
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
157 #endif // #ifndef ARM_MATH_CM0_FAMILY
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
158
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
159 while(blkCnt > 0)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
160 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
161 /* Initialize minVal to the next consecutive values one by one */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
162 minVal1 = *pSrc++;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
163
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
164 /* compare for the minimum value */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
165 if(out > minVal1)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
166 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
167 /* Update the minimum value and it's index */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
168 out = minVal1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
169 outIndex = blockSize - blkCnt;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
170 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
171
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
172 blkCnt--;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
173
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
174 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
175
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
176 /* Store the minimum value and it's index into destination pointers */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
177 *pResult = out;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
178 *pIndex = outIndex;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
179 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
180
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
181 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
182 * @} end of Min group
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
183 */