qm-dsp 1.8
|
Static helper functions for simple mathematical calculations. More...
#include <MathUtilities.h>
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. | |
Static helper functions for simple mathematical calculations.
Definition at line 26 of file MathUtilities.h.
Enumerator | |
---|---|
NormaliseNone | |
NormaliseUnitSum | |
NormaliseUnitMax |
Definition at line 85 of file MathUtilities.h.
|
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().
|
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().
|
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().
|
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().
|
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(), mean(), normalise(), and normalise().
|
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().
|
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().
|
static |
Floating-point division modulus: return x % y.
Definition at line 24 of file MathUtilities.cpp.
Referenced by princarg().
|
static |
Definition at line 41 of file MathUtilities.cpp.
Referenced by DFProcess::removeDCNormalize().
|
static |
Definition at line 59 of file MathUtilities.cpp.
|
static |
Definition at line 226 of file MathUtilities.cpp.
Referenced by GetKeyMode::process().
|
static |
Definition at line 174 of file MathUtilities.cpp.
Referenced by DownBeat::findDownBeats(), and GetKeyMode::process().
|
static |
Definition at line 200 of file MathUtilities.cpp.
|
static |
Definition at line 245 of file MathUtilities.cpp.
Referenced by GetKeyMode::process().
|
static |
Definition at line 250 of file MathUtilities.cpp.
References NormaliseNone, NormaliseUnitMax, NormaliseUnitSum, and sum().
Referenced by Chromagram::process().
|
static |
Definition at line 289 of file MathUtilities.cpp.
References NormaliseNone, NormaliseUnitMax, NormaliseUnitSum, and sum().
|
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().
|
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().
|
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().
|
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().
|
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().
|
static |
|
static |
Return the greatest common divisor of natural numbers a and b.
Definition at line 394 of file MathUtilities.cpp.
References gcd().
Referenced by gcd(), and Resampler::initialise().