Ardour  9.0-pre0-386-g96ef4d20f2
MathUtilities.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  QM DSP Library
5 
6  Centre for Digital Music, Queen Mary, University of London.
7  This file 2005-2006 Christian Landone.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef MATHUTILITIES_H
17 #define MATHUTILITIES_H
18 
19 #include <vector>
20 
21 #include "nan-inf.h"
22 
27 {
28 public:
32  static double round( double x );
33 
38  static void getFrameMinMax( const double* data, int len, double* min, double* max );
39 
43  static double mean( const double* src, int len );
44 
49  static double mean( const std::vector<double> &data,
50  int start, int count );
51 
56  static double sum( const double* src, int len );
57 
63  static double median( const double* src, int len );
64 
69  static double princarg( double ang );
70 
74  static double mod( double x, double y);
75 
82  static void getAlphaNorm(const double *data, int len, int alpha, double* ANorm);
83 
90  static double getAlphaNorm(const std::vector <double> &data, int alpha );
91 
96  };
97 
98  static void normalise(double *data, int length,
100 
101  static void normalise(std::vector<double> &data,
103 
108  static double getLpNorm(const std::vector<double> &data,
109  int p);
110 
117  static std::vector<double> normaliseLp(const std::vector<double> &data,
118  int p,
119  double threshold = 1e-6);
120 
125  static void adaptiveThreshold(std::vector<double> &data);
126 
127  static void circShift( double* data, int length, int shift);
128 
129  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 compareInt(const void * a, const void * b);
132 
136  static bool isPowerOfTwo(int x);
137 
142  static int nextPowerOfTwo(int x);
143 
148  static int previousPowerOfTwo(int x);
149 
154  static int nearestPowerOfTwo(int x);
155 
159  static double factorial(int x); // returns double in case it is large
160 
164  static int gcd(int a, int b);
165 };
166 
167 #endif
static int compareInt(const void *a, const void *b)
static bool isPowerOfTwo(int x)
static double mean(const std::vector< double > &data, int start, int count)
static double getLpNorm(const std::vector< double > &data, int p)
static double sum(const double *src, int len)
static double round(double x)
static int nearestPowerOfTwo(int x)
static int getMax(double *data, int length, double *max=0)
static int previousPowerOfTwo(int x)
static int getMax(const std::vector< double > &data, double *max=0)
static void circShift(double *data, int length, int shift)
static void getAlphaNorm(const double *data, int len, int alpha, double *ANorm)
static double mod(double x, double y)
static double getAlphaNorm(const std::vector< double > &data, int alpha)
static void normalise(double *data, int length, NormaliseType n=NormaliseUnitMax)
static double princarg(double ang)
static int nextPowerOfTwo(int x)
static void adaptiveThreshold(std::vector< double > &data)
static double mean(const double *src, int len)
static void getFrameMinMax(const double *data, int len, double *min, double *max)
static std::vector< double > normaliseLp(const std::vector< double > &data, int p, double threshold=1e-6)
static double factorial(int x)
static void normalise(std::vector< double > &data, NormaliseType n=NormaliseUnitMax)
static double median(const double *src, int len)
static int gcd(int a, int b)
PBD::PropertyDescriptor< timecnt_t > length
PBD::PropertyDescriptor< timepos_t > start
PBD::PropertyDescriptor< float > shift