annotate maths/MathUtilities.h @ 280:9c403afdd9e9

* Various fixes related to the bar estimator code
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 10 Feb 2009 16:37:11 +0000
parents c8908cdc8c32
children 702ff8c08137
rev   line source
c@241 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@241 2
c@241 3 /*
c@241 4 QM DSP Library
c@241 5
c@241 6 Centre for Digital Music, Queen Mary, University of London.
c@241 7 This file copyright 2005-2006 Christian Landone.
c@241 8 All rights reserved.
c@241 9 */
c@241 10
c@241 11 #ifndef MATHUTILITIES_H
c@241 12 #define MATHUTILITIES_H
c@241 13
c@241 14 #include <vector>
c@241 15
c@241 16 class MathUtilities
c@241 17 {
c@241 18 public:
c@241 19 static double round( double x );
c@259 20
c@241 21 static void getFrameMinMax( const double* data, unsigned int len, double* min, double* max );
c@259 22
c@241 23 static double mean( const double* src, unsigned int len );
c@279 24 static double mean( const std::vector<double> &data,
c@279 25 unsigned int start, unsigned int count );
c@241 26 static double sum( const double* src, unsigned int len );
c@259 27 static double median( const double* src, unsigned int len );
c@259 28
c@241 29 static double princarg( double ang );
c@241 30 static double mod( double x, double y);
c@259 31
c@241 32 static void getAlphaNorm(const double *data, unsigned int len, unsigned int alpha, double* ANorm);
c@241 33 static double getAlphaNorm(const std::vector <double> &data, unsigned int alpha );
c@259 34
c@241 35 static void circShift( double* data, int length, int shift);
c@259 36
c@279 37 static int getMax( double* data, unsigned int length, double* max = 0 );
c@279 38 static int getMax( const std::vector<double> &data, double* max = 0 );
c@241 39 static int compareInt(const void * a, const void * b);
c@259 40
c@259 41 enum NormaliseType {
c@259 42 NormaliseNone,
c@259 43 NormaliseUnitSum,
c@259 44 NormaliseUnitMax
c@259 45 };
c@259 46
c@259 47 static void normalise(double *data, int length,
c@259 48 NormaliseType n = NormaliseUnitMax);
c@259 49
c@259 50 static void normalise(std::vector<double> &data,
c@259 51 NormaliseType n = NormaliseUnitMax);
c@279 52
c@279 53 // moving mean threshholding:
c@279 54 static void adaptiveThreshold(std::vector<double> &data);
c@280 55
c@280 56 static bool isPowerOfTwo(int x);
c@280 57 static int nextPowerOfTwo(int x); // e.g. 1300 -> 2048, 2048 -> 2048
c@280 58 static int previousPowerOfTwo(int x); // e.g. 1300 -> 1024, 2048 -> 2048
c@280 59 static int nearestPowerOfTwo(int x); // e.g. 1300 -> 1024, 1700 -> 2048
c@241 60 };
c@241 61
c@241 62 #endif