Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mathtools.h File Reference
#include <vector>
#include <cmath>
#include <functional>
#include <algorithm>
#include <limits>
#include "../system/prerequisites.h"
+ Include dependency graph for mathtools.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 MathTools
 

Functions

template<class T >
int MathTools::roundToInteger (T x)
 Round a floating point number to an integer. More...
 
double MathTools::computeMoment (const std::vector< double > &v, const int n)
 Determine the n-th moment of a distribution stored in a vector. More...
 
void MathTools::normalize (std::vector< double > &vec)
 Normalize a distribution stored in a vector. More...
 
double MathTools::computeNorm (std::vector< double > &vec)
 Compute the norm of a vector. More...
 
void MathTools::coarseGrainSpectrum (const std::vector< double > &X, std::vector< double > &Y, std::function< double(double y)> f, double exponent=0)
 
double MathTools::computeEntropy (const std::vector< double > &v)
 Compute the Shannon entropy of a normalized probability distribution. More...
 
double MathTools::computeRenyiEntropy (const std::vector< double > &v, const double q)
 Compute the Renyi entropy of a normalized probability distribution. More...
 
int MathTools::findMaximum (const std::vector< double > &X, int i, int j)
 Find the component where the vector has its maximum. More...
 
int MathTools::findMaximum (const std::vector< double > &X)
 
double MathTools::findSmoothedMaximum (const std::vector< double > &x)
 Use a parabola to fit the maximum. More...
 
double MathTools::weightedArithmetricMean (const std::vector< double > &Y, size_t start=0, size_t end=std::numeric_limits< size_t >::max())
 Computes the weighted arithmetric mean index of the given Y data. More...
 
double MathTools::restrictToInterval (double x, double xmin, double xmax)
 Restrict floating point value to an interval. More...
 
template<typename T >
void MathTools::transformVector (const std::vector< T > &v, std::vector< T > &w, std::function< T(T)> f)
 Map a vector to a different one by a unary map. More...
 
template<typename T >
std::vector< T > MathTools::transformVector (const std::vector< T > &v, std::function< T(T)> f)
 

Variables

const double MathTools::PI = 3.14159265358979323846
 
const double MathTools::TWO_PI = 2 * PI
 
const double MathTools::LOG2 = 0.69314718055994530942