annotate maths/MathUtilities.h @ 304:702ff8c08137

* Solaris build fixes
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 14 Sep 2009 13:01:44 +0000
parents 9c403afdd9e9
children d5014ab8b0e5
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@304 16 #include "nan-inf.h"
c@304 17
c@241 18 class MathUtilities
c@241 19 {
c@241 20 public:
c@241 21 static double round( double x );
c@259 22
c@241 23 static void getFrameMinMax( const double* data, unsigned int len, double* min, double* max );
c@259 24
c@241 25 static double mean( const double* src, unsigned int len );
c@279 26 static double mean( const std::vector<double> &data,
c@279 27 unsigned int start, unsigned int count );
c@241 28 static double sum( const double* src, unsigned int len );
c@259 29 static double median( const double* src, unsigned int len );
c@259 30
c@241 31 static double princarg( double ang );
c@241 32 static double mod( double x, double y);
c@259 33
c@241 34 static void getAlphaNorm(const double *data, unsigned int len, unsigned int alpha, double* ANorm);
c@241 35 static double getAlphaNorm(const std::vector <double> &data, unsigned int alpha );
c@259 36
c@241 37 static void circShift( double* data, int length, int shift);
c@259 38
c@279 39 static int getMax( double* data, unsigned int length, double* max = 0 );
c@279 40 static int getMax( const std::vector<double> &data, double* max = 0 );
c@241 41 static int compareInt(const void * a, const void * b);
c@259 42
c@259 43 enum NormaliseType {
c@259 44 NormaliseNone,
c@259 45 NormaliseUnitSum,
c@259 46 NormaliseUnitMax
c@259 47 };
c@259 48
c@259 49 static void normalise(double *data, int length,
c@259 50 NormaliseType n = NormaliseUnitMax);
c@259 51
c@259 52 static void normalise(std::vector<double> &data,
c@259 53 NormaliseType n = NormaliseUnitMax);
c@279 54
c@279 55 // moving mean threshholding:
c@279 56 static void adaptiveThreshold(std::vector<double> &data);
c@280 57
c@280 58 static bool isPowerOfTwo(int x);
c@280 59 static int nextPowerOfTwo(int x); // e.g. 1300 -> 2048, 2048 -> 2048
c@280 60 static int previousPowerOfTwo(int x); // e.g. 1300 -> 1024, 2048 -> 2048
c@280 61 static int nearestPowerOfTwo(int x); // e.g. 1300 -> 1024, 1700 -> 2048
c@241 62 };
c@241 63
c@241 64 #endif