Mercurial > hg > qm-dsp
comparison maths/MathUtilities.h @ 477:fa407c1d9923
Untabify + indent
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Thu, 30 May 2019 18:36:48 +0100 |
parents | d583feeeed7a |
children |
comparison
equal
deleted
inserted
replaced
476:2de6184b2ce0 | 477:fa407c1d9923 |
---|---|
23 /** | 23 /** |
24 * Static helper functions for simple mathematical calculations. | 24 * Static helper functions for simple mathematical calculations. |
25 */ | 25 */ |
26 class MathUtilities | 26 class MathUtilities |
27 { | 27 { |
28 public: | 28 public: |
29 /** | 29 /** |
30 * Round x to the nearest integer. | 30 * Round x to the nearest integer. |
31 */ | 31 */ |
32 static double round( double x ); | 32 static double round( double x ); |
33 | 33 |
34 /** | 34 /** |
35 * Return through min and max pointers the highest and lowest | 35 * Return through min and max pointers the highest and lowest |
36 * values in the given array of the given length. | 36 * values in the given array of the given length. |
37 */ | 37 */ |
38 static void getFrameMinMax( const double* data, int len, double* min, double* max ); | 38 static void getFrameMinMax( const double* data, int len, |
39 double* min, double* max ); | |
39 | 40 |
40 /** | 41 /** |
41 * Return the mean of the given array of the given length. | 42 * Return the mean of the given array of the given length. |
42 */ | 43 */ |
43 static double mean( const double* src, int len ); | 44 static double mean( const double* src, int len ); |
77 * The alpha norm is the alpha'th root of the mean alpha'th power | 78 * The alpha norm is the alpha'th root of the mean alpha'th power |
78 * magnitude. For example if alpha = 2 this corresponds to the RMS | 79 * magnitude. For example if alpha = 2 this corresponds to the RMS |
79 * of the input data, and when alpha = 1 this is the mean | 80 * of the input data, and when alpha = 1 this is the mean |
80 * magnitude. | 81 * magnitude. |
81 */ | 82 */ |
82 static void getAlphaNorm(const double *data, int len, int alpha, double* ANorm); | 83 static void getAlphaNorm(const double *data, int len, int alpha, double* ANorm); |
83 | 84 |
84 /** | 85 /** |
85 * The alpha norm is the alpha'th root of the mean alpha'th power | 86 * The alpha norm is the alpha'th root of the mean alpha'th power |
86 * magnitude. For example if alpha = 2 this corresponds to the RMS | 87 * magnitude. For example if alpha = 2 this corresponds to the RMS |
87 * of the input data, and when alpha = 1 this is the mean | 88 * of the input data, and when alpha = 1 this is the mean |
122 * Threshold the input/output vector data against a moving-mean | 123 * Threshold the input/output vector data against a moving-mean |
123 * average filter. | 124 * average filter. |
124 */ | 125 */ |
125 static void adaptiveThreshold(std::vector<double> &data); | 126 static void adaptiveThreshold(std::vector<double> &data); |
126 | 127 |
127 static void circShift( double* data, int length, int shift); | 128 static void circShift( double* data, int length, int shift); |
128 | 129 |
129 static int getMax( double* data, int length, double* max = 0 ); | 130 static int getMax( double* data, int length, double* max = 0 ); |
130 static int getMax( const std::vector<double> &data, double* max = 0 ); | 131 static int getMax( const std::vector<double> &data, double* max = 0 ); |
131 static int compareInt(const void * a, const void * b); | 132 static int compareInt(const void * a, const void * b); |
132 | 133 |
133 /** | 134 /** |
134 * Return true if x is 2^n for some integer n >= 0. | 135 * Return true if x is 2^n for some integer n >= 0. |
135 */ | 136 */ |
136 static bool isPowerOfTwo(int x); | 137 static bool isPowerOfTwo(int x); |