changeset 487:5998ee1042d3

Use M_PI
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 31 May 2019 16:33:55 +0100
parents 7132d952b9a6
children 7992d0923626
files dsp/chromagram/ConstantQ.cpp dsp/chromagram/ConstantQ.h dsp/onsets/PeakPicking.h dsp/tempotracking/TempoTrack.cpp hmm/hmm.c hmm/hmm.h maths/MathAliases.h
diffstat 7 files changed, 12 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/dsp/chromagram/ConstantQ.cpp	Fri May 31 16:33:46 2019 +0100
+++ b/dsp/chromagram/ConstantQ.cpp	Fri May 31 16:33:55 2019 +0100
@@ -91,7 +91,7 @@
         unsigned origin = m_FFTLength/2 - hammingLength/2;
 
         for (unsigned i=0; i<hammingLength; i++) {
-            const double angle = 2*PI*m_dQ*i/hammingLength;
+            const double angle = 2*M_PI*m_dQ*i/hammingLength;
             const double real = cos(angle);
             const double imag = sin(angle);
             const double absol = hamming(hammingLength, i)/hammingLength;
--- a/dsp/chromagram/ConstantQ.h	Fri May 31 16:33:46 2019 +0100
+++ b/dsp/chromagram/ConstantQ.h	Fri May 31 16:33:55 2019 +0100
@@ -42,7 +42,7 @@
     void sparsekernel();
 
     double hamming(int len, int n) {
-        double out = 0.54 - 0.46*cos(2*PI*n/len);
+        double out = 0.54 - 0.46*cos(2*M_PI*n/len);
         return(out);
     }
         
--- a/dsp/onsets/PeakPicking.h	Fri May 31 16:33:46 2019 +0100
+++ b/dsp/onsets/PeakPicking.h	Fri May 31 16:33:55 2019 +0100
@@ -93,12 +93,12 @@
     PeakPicking( PPickParams Config );
     virtual ~PeakPicking();
         
-    void process( double* src, unsigned int len, vector<int> &onsets  );
+    void process( double* src, unsigned int len, std::vector<int> &onsets  );
 
 private:
     void initialise( PPickParams Config  );
     void deInitialise();
-    int  quadEval( vector<double> &src, vector<int> &idx );
+    int  quadEval( std::vector<double> &src, std::vector<int> &idx );
         
     DFProcConfig m_DFProcessingParams;
 
--- a/dsp/tempotracking/TempoTrack.cpp	Fri May 31 16:33:46 2019 +0100
+++ b/dsp/tempotracking/TempoTrack.cpp	Fri May 31 16:33:55 2019 +0100
@@ -120,7 +120,7 @@
         for( i = 0; i < winLength; i++ ) {
             double dlag = (double)(i+1) - beatLag;
             Filter[ i ] =  exp(-0.5 * pow(( dlag / m_sigma), 2.0) ) /
-                (sqrt( 2 * PI) * m_sigma);
+                (sqrt(TWO_PI) * m_sigma);
         }
     }
 }
@@ -519,7 +519,7 @@
         double temp = 0.0;
 
         for(  int i = 0; i < scratchLength; i++ ) {
-            phaseScratch[ i ] = exp( -0.5 * pow( ( i - mu ) / sigma, 2 ) ) / ( sqrt( 2*PI ) *sigma );
+            phaseScratch[ i ] = exp( -0.5 * pow( ( i - mu ) / sigma, 2 ) ) / ( sqrt(TWO_PI) *sigma );
         }
 
         MathUtilities::getFrameMinMax( phaseScratch, scratchLength, &PhaseMin, &PhaseMax );
--- a/hmm/hmm.c	Fri May 31 16:33:46 2019 +0100
+++ b/hmm/hmm.c	Fri May 31 16:33:55 2019 +0100
@@ -627,7 +627,7 @@
 
     s = cblas_ddot(L, z, 1, y, 1);
 	
-    return exp(-s/2.0) / (pow(2*PI, L/2.0) * sqrt(detcov));
+    return exp(-s/2.0) / (pow(2 * M_PI, L/2.0) * sqrt(detcov));
 }
 
 /* log probability of multivariate Gaussian given mean, inverse and determinant of covariance */
@@ -647,7 +647,7 @@
 
     s = cblas_ddot(L, z, 1, y, 1);
 	
-    ret = -0.5 * (s + L * log(2*PI) + log(detcov));
+    ret = -0.5 * (s + L * log(2 * M_PI) + log(detcov));
 	
     return ret;
 }
--- a/hmm/hmm.h	Fri May 31 16:33:46 2019 +0100
+++ b/hmm/hmm.h	Fri May 31 16:33:55 2019 +0100
@@ -20,10 +20,6 @@
 extern "C" {
 #endif
 
-#ifndef PI    
-#define PI 3.14159265358979323846264338327950288
-#endif 
-
 typedef struct _model_t {
     int N;          /* number of states */
     double* p0;     /* initial probs */
--- a/maths/MathAliases.h	Fri May 31 16:33:46 2019 +0100
+++ b/maths/MathAliases.h	Fri May 31 16:33:55 2019 +0100
@@ -19,17 +19,9 @@
 #include <cmath>
 #include <complex>
 
-using namespace std;
-typedef complex<double> ComplexData;
+#define TWO_PI          (2. * M_PI)
 
-
-#ifndef PI
-#define PI (3.14159265358979232846)
-#endif
-
-#define TWO_PI          (2. * PI)
-
-#define EPS 2.2204e-016
+#define EPS             2.2204e-016
 
 /* aliases to math.h functions */
 #define EXP                             exp
@@ -43,6 +35,8 @@
 #define FLOOR                   floorf
 #define TRUNC                   truncf
 
+typedef std::complex<double> ComplexData;
+
 /* aliases to complex.h functions */
 /** sample = EXPC(complex) */
 #define EXPC                    cexpf