qm-dsp  1.8
MathUtilities Class Reference

Static helper functions for simple mathematical calculations. More...

#include <MathUtilities.h>

List of all members.

Public Types

enum  NormaliseType { NormaliseNone, NormaliseUnitSum, NormaliseUnitMax }

Static Public Member Functions

static double round (double x)
 Round x to the nearest integer.
static void getFrameMinMax (const double *data, unsigned int len, double *min, double *max)
 Return through min and max pointers the highest and lowest values in the given array of the given length.
static double mean (const double *src, unsigned int len)
 Return the mean of the given array of the given length.
static double mean (const std::vector< double > &data, unsigned int start, unsigned int count)
 Return the mean of the subset of the given vector identified by start and count.
static double sum (const double *src, unsigned int len)
 Return the sum of the values in the given array of the given length.
static double median (const double *src, unsigned int len)
 Return the median of the values in the given array of the given length.
static double princarg (double ang)
 The principle argument function.
static double mod (double x, double y)
 Floating-point division modulus: return x % y.
static void getAlphaNorm (const double *data, unsigned int len, unsigned int alpha, double *ANorm)
static double getAlphaNorm (const std::vector< double > &data, unsigned int alpha)
static void circShift (double *data, int length, int shift)
static int getMax (double *data, unsigned int length, double *max=0)
static int getMax (const std::vector< double > &data, double *max=0)
static int compareInt (const void *a, const void *b)
static void normalise (double *data, int length, NormaliseType n=NormaliseUnitMax)
static void normalise (std::vector< double > &data, NormaliseType n=NormaliseUnitMax)
static void adaptiveThreshold (std::vector< double > &data)
 Threshold the input/output vector data against a moving-mean average filter.
static bool isPowerOfTwo (int x)
 Return true if x is 2^n for some integer n >= 0.
static int nextPowerOfTwo (int x)
 Return the next higher integer power of two from x, e.g.
static int previousPowerOfTwo (int x)
 Return the next lower integer power of two from x, e.g.
static int nearestPowerOfTwo (int x)
 Return the nearest integer power of two to x, e.g.
static double factorial (int x)
 Return x!
static int gcd (int a, int b)
 Return the greatest common divisor of natural numbers a and b.

Detailed Description

Static helper functions for simple mathematical calculations.

Definition at line 26 of file MathUtilities.h.


Member Enumeration Documentation

Enumerator:
NormaliseNone 
NormaliseUnitSum 
NormaliseUnitMax 

Definition at line 85 of file MathUtilities.h.


Member Function Documentation

double MathUtilities::round ( double  x) [static]

Round x to the nearest integer.

Definition at line 78 of file MathUtilities.cpp.

Referenced by TempoTrack::beatPredict(), TempoTrack::createPhaseExtractor(), TempoTrack::findMeter(), and TempoTrack::phaseMM().

void MathUtilities::getFrameMinMax ( const double *  data,
unsigned int  len,
double *  min,
double *  max 
) [static]

Return through min and max pointers the highest and lowest values in the given array of the given length.

Definition at line 145 of file MathUtilities.cpp.

Referenced by TempoTrack::createPhaseExtractor(), DFProcess::removeDCNormalize(), and Chromagram::unityNormalise().

double MathUtilities::mean ( const double *  src,
unsigned int  len 
) [static]

Return the mean of the given array of the given length.

Definition at line 116 of file MathUtilities.cpp.

References sum().

Referenced by adaptiveThreshold(), GetKeyMode::krumCorr(), and TempoTrack::tempoMM().

double MathUtilities::mean ( const std::vector< double > &  data,
unsigned int  start,
unsigned int  count 
) [static]

Return the mean of the subset of the given vector identified by start and count.

Definition at line 129 of file MathUtilities.cpp.

References sum().

double MathUtilities::sum ( const double *  src,
unsigned int  len 
) [static]

Return the sum of the values in the given array of the given length.

Definition at line 103 of file MathUtilities.cpp.

Referenced by mean(), and normalise().

double MathUtilities::median ( const double *  src,
unsigned int  len 
) [static]

Return the median of the values in the given array of the given length.

If the array is even in length, the returned value will be half-way between the two values adjacent to median.

Definition at line 87 of file MathUtilities.cpp.

Referenced by DFProcess::medianFilter().

double MathUtilities::princarg ( double  ang) [static]

The principle argument function.

Map the phase angle ang into the range [-pi,pi).

Definition at line 32 of file MathUtilities.cpp.

References mod().

Referenced by DetectionFunction::complexSD(), DetectionFunction::phaseDev(), and PhaseVocoder::unwrapPhases().

double MathUtilities::mod ( double  x,
double  y 
) [static]

Floating-point division modulus: return x % y.

Definition at line 24 of file MathUtilities.cpp.

Referenced by princarg().

void MathUtilities::getAlphaNorm ( const double *  data,
unsigned int  len,
unsigned int  alpha,
double *  ANorm 
) [static]

Definition at line 41 of file MathUtilities.cpp.

Referenced by DFProcess::removeDCNormalize().

double MathUtilities::getAlphaNorm ( const std::vector< double > &  data,
unsigned int  alpha 
) [static]

Definition at line 59 of file MathUtilities.cpp.

void MathUtilities::circShift ( double *  data,
int  length,
int  shift 
) [static]

Definition at line 226 of file MathUtilities.cpp.

Referenced by GetKeyMode::process().

int MathUtilities::getMax ( double *  data,
unsigned int  length,
double *  max = 0 
) [static]

Definition at line 174 of file MathUtilities.cpp.

Referenced by DownBeat::findDownBeats(), and GetKeyMode::process().

int MathUtilities::getMax ( const std::vector< double > &  data,
double *  max = 0 
) [static]

Definition at line 200 of file MathUtilities.cpp.

int MathUtilities::compareInt ( const void *  a,
const void *  b 
) [static]

Definition at line 245 of file MathUtilities.cpp.

Referenced by GetKeyMode::process().

void MathUtilities::normalise ( double *  data,
int  length,
NormaliseType  n = NormaliseUnitMax 
) [static]

Definition at line 250 of file MathUtilities.cpp.

References NormaliseNone, NormaliseUnitMax, NormaliseUnitSum, and sum().

Referenced by Chromagram::process().

void MathUtilities::normalise ( std::vector< double > &  data,
NormaliseType  n = NormaliseUnitMax 
) [static]

Definition at line 289 of file MathUtilities.cpp.

References NormaliseNone, NormaliseUnitMax, NormaliseUnitSum, and sum().

void MathUtilities::adaptiveThreshold ( std::vector< double > &  data) [static]

Threshold the input/output vector data against a moving-mean average filter.

Definition at line 320 of file MathUtilities.cpp.

References mean().

Referenced by DownBeat::findDownBeats(), and TempoTrackV2::get_rcf().

bool MathUtilities::isPowerOfTwo ( int  x) [static]

Return true if x is 2^n for some integer n >= 0.

Definition at line 345 of file MathUtilities.cpp.

Referenced by DecimatorB::initialise(), nearestPowerOfTwo(), nextPowerOfTwo(), and previousPowerOfTwo().

int MathUtilities::nextPowerOfTwo ( int  x) [static]

Return the next higher integer power of two from x, e.g.

1300 -> 2048, 2048 -> 2048.

Definition at line 353 of file MathUtilities.cpp.

References isPowerOfTwo().

Referenced by DownBeat::DownBeat(), and nearestPowerOfTwo().

int MathUtilities::previousPowerOfTwo ( int  x) [static]

Return the next lower integer power of two from x, e.g.

1300 -> 1024, 2048 -> 2048.

Definition at line 363 of file MathUtilities.cpp.

References isPowerOfTwo().

Referenced by nearestPowerOfTwo().

int MathUtilities::nearestPowerOfTwo ( int  x) [static]

Return the nearest integer power of two to x, e.g.

1300 -> 1024, 12 -> 16 (not 8; if two are equidistant, the higher is returned).

Definition at line 374 of file MathUtilities.cpp.

References isPowerOfTwo(), nextPowerOfTwo(), and previousPowerOfTwo().

double MathUtilities::factorial ( int  x) [static]

Return x!

Definition at line 383 of file MathUtilities.cpp.

Referenced by besselTerm().

int MathUtilities::gcd ( int  a,
int  b 
) [static]

Return the greatest common divisor of natural numbers a and b.

Definition at line 394 of file MathUtilities.cpp.

Referenced by Resampler::initialise().


The documentation for this class was generated from the following files: