16#ifndef MATHUTILITIES_H
17#define MATHUTILITIES_H
32 static double round(
double x );
38 static void getFrameMinMax(
const double* data,
unsigned int len,
double* min,
double* max );
43 static double mean(
const double* src,
unsigned int len );
49 static double mean(
const std::vector<double> &data,
50 unsigned int start,
unsigned int count );
56 static double sum(
const double* src,
unsigned int len );
63 static double median(
const double* src,
unsigned int len );
69 static double princarg(
double ang );
74 static double mod(
double x,
double y);
76 static void getAlphaNorm(
const double *data,
unsigned int len,
unsigned int alpha,
double* ANorm);
77 static double getAlphaNorm(
const std::vector <double> &data,
unsigned int alpha );
79 static void circShift(
double* data,
int length,
int shift);
81 static int getMax(
double* data,
unsigned int length,
double* max = 0 );
82 static int getMax(
const std::vector<double> &data,
double* max = 0 );
83 static int compareInt(
const void * a,
const void * b);
91 static void normalise(
double *data,
int length,
94 static void normalise(std::vector<double> &data,
134 static int gcd(
int a,
int b);
Static helper functions for simple mathematical calculations.
static int nearestPowerOfTwo(int x)
Return the nearest integer power of two to x, e.g.
static void getAlphaNorm(const double *data, unsigned int len, unsigned int alpha, double *ANorm)
static int compareInt(const void *a, const void *b)
static double sum(const double *src, unsigned int len)
Return the sum of the values in the given array of the given length.
static void normalise(double *data, int length, NormaliseType n=NormaliseUnitMax)
static double mod(double x, double y)
Floating-point division modulus: return x % y.
static int nextPowerOfTwo(int x)
Return the next higher integer power of two from x, e.g.
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 mean(const double *src, unsigned int len)
Return the mean of the given array of the given length.
static bool isPowerOfTwo(int x)
Return true if x is 2^n for some integer n >= 0.
static int gcd(int a, int b)
Return the greatest common divisor of natural numbers a and b.
static void adaptiveThreshold(std::vector< double > &data)
Threshold the input/output vector data against a moving-mean average filter.
static double factorial(int x)
Return x!
static double round(double x)
Round x to the nearest integer.
static int getMax(double *data, unsigned int length, double *max=0)
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 len...
static void circShift(double *data, int length, int shift)
static int previousPowerOfTwo(int x)
Return the next lower integer power of two from x, e.g.
static double princarg(double ang)
The principle argument function.