diff dsp/maths/MathUtilities.cpp @ 7:85a9e268a8c4

* Add key mode detector
author cannam
date Mon, 11 Dec 2006 09:48:33 +0000
parents d7116e3183f8
children
line wrap: on
line diff
--- a/dsp/maths/MathUtilities.cpp	Fri Dec 08 18:05:36 2006 +0000
+++ b/dsp/maths/MathUtilities.cpp	Mon Dec 11 09:48:33 2006 +0000
@@ -168,3 +168,54 @@
 		
     }
 }
+
+int MathUtilities::getMax( double* pData, unsigned int Length, double* pMax )
+{
+	unsigned int index = 0;
+	unsigned int i;
+	double temp = 0.0;
+	
+	double max = pData[0];
+
+	for( i = 0; i < Length; i++)
+	{
+		temp = pData[ i ];
+
+		if( temp > max )
+		{
+			max =  temp ;
+			index = i;
+		}
+		
+   	}
+
+	*pMax = max;
+
+
+	return index;
+}
+
+void MathUtilities::circShift( double* pData, int length, int shift)
+{
+	shift = shift % length;
+	double temp;
+	int i,n;
+
+	for( i = 0; i < shift; i++)
+	{
+		temp=*(pData + length - 1);
+
+		for( n = length-2; n >= 0; n--)
+		{
+			*(pData+n+1)=*(pData+n);
+		}
+
+        *pData = temp;
+    }
+}
+
+int MathUtilities::compareInt (const void * a, const void * b)
+{
+  return ( *(int*)a - *(int*)b );
+}
+