Mercurial > hg > qm-dsp
comparison dsp/maths/MathUtilities.cpp @ 7:85a9e268a8c4
* Add key mode detector
author | cannam |
---|---|
date | Mon, 11 Dec 2006 09:48:33 +0000 |
parents | d7116e3183f8 |
children |
comparison
equal
deleted
inserted
replaced
6:a9bf0cfe9383 | 7:85a9e268a8c4 |
---|---|
166 *max = temp ; | 166 *max = temp ; |
167 } | 167 } |
168 | 168 |
169 } | 169 } |
170 } | 170 } |
171 | |
172 int MathUtilities::getMax( double* pData, unsigned int Length, double* pMax ) | |
173 { | |
174 unsigned int index = 0; | |
175 unsigned int i; | |
176 double temp = 0.0; | |
177 | |
178 double max = pData[0]; | |
179 | |
180 for( i = 0; i < Length; i++) | |
181 { | |
182 temp = pData[ i ]; | |
183 | |
184 if( temp > max ) | |
185 { | |
186 max = temp ; | |
187 index = i; | |
188 } | |
189 | |
190 } | |
191 | |
192 *pMax = max; | |
193 | |
194 | |
195 return index; | |
196 } | |
197 | |
198 void MathUtilities::circShift( double* pData, int length, int shift) | |
199 { | |
200 shift = shift % length; | |
201 double temp; | |
202 int i,n; | |
203 | |
204 for( i = 0; i < shift; i++) | |
205 { | |
206 temp=*(pData + length - 1); | |
207 | |
208 for( n = length-2; n >= 0; n--) | |
209 { | |
210 *(pData+n+1)=*(pData+n); | |
211 } | |
212 | |
213 *pData = temp; | |
214 } | |
215 } | |
216 | |
217 int MathUtilities::compareInt (const void * a, const void * b) | |
218 { | |
219 return ( *(int*)a - *(int*)b ); | |
220 } | |
221 |