summaryrefslogtreecommitdiff
path: root/libs/qm-dsp/maths
diff options
context:
space:
mode:
Diffstat (limited to 'libs/qm-dsp/maths')
-rw-r--r--libs/qm-dsp/maths/MathUtilities.cpp26
-rw-r--r--libs/qm-dsp/maths/MathUtilities.h2
-rw-r--r--libs/qm-dsp/maths/pca/pca.c20
3 files changed, 24 insertions, 24 deletions
diff --git a/libs/qm-dsp/maths/MathUtilities.cpp b/libs/qm-dsp/maths/MathUtilities.cpp
index 2249c53a95..a55252b365 100644
--- a/libs/qm-dsp/maths/MathUtilities.cpp
+++ b/libs/qm-dsp/maths/MathUtilities.cpp
@@ -41,11 +41,11 @@ void MathUtilities::getAlphaNorm(const double *data, unsigned int len, unsigned
unsigned int i;
double temp = 0.0;
double a=0.0;
-
+
for( i = 0; i < len; i++)
{
temp = data[ i ];
-
+
a += ::pow( fabs(temp), double(alpha) );
}
a /= ( double )len;
@@ -60,11 +60,11 @@ double MathUtilities::getAlphaNorm( const std::vector <double> &data, unsigned i
unsigned int len = data.size();
double temp = 0.0;
double a=0.0;
-
+
for( i = 0; i < len; i++)
{
temp = data[ i ];
-
+
a += ::pow( fabs(temp), double(alpha) );
}
a /= ( double )len;
@@ -143,7 +143,7 @@ double MathUtilities::mean(const double *src, unsigned int len)
double retVal =0.0;
double s = sum( src, len );
-
+
retVal = s / (double)len;
return retVal;
@@ -154,7 +154,7 @@ double MathUtilities::mean(const std::vector<double> &src,
unsigned int count)
{
double sum = 0.;
-
+
for (unsigned int i = 0; i < count; ++i)
{
sum += src[start + i];
@@ -172,7 +172,7 @@ void MathUtilities::getFrameMinMax(const double *data, unsigned int len, double
*min = *max = 0;
return;
}
-
+
*min = data[0];
*max = data[0];
@@ -188,7 +188,7 @@ void MathUtilities::getFrameMinMax(const double *data, unsigned int len, double
{
*max = temp ;
}
-
+
}
}
@@ -197,7 +197,7 @@ int MathUtilities::getMax( double* pData, unsigned int Length, double* pMax )
unsigned int index = 0;
unsigned int i;
double temp = 0.0;
-
+
double max = pData[0];
for( i = 0; i < Length; i++)
@@ -209,7 +209,7 @@ int MathUtilities::getMax( double* pData, unsigned int Length, double* pMax )
max = temp ;
index = i;
}
-
+
}
if (pMax) *pMax = max;
@@ -223,7 +223,7 @@ int MathUtilities::getMax( const std::vector<double> & data, double* pMax )
unsigned int index = 0;
unsigned int i;
double temp = 0.0;
-
+
double max = data[0];
for( i = 0; i < data.size(); i++)
@@ -235,7 +235,7 @@ int MathUtilities::getMax( const std::vector<double> & data, double* pMax )
max = temp ;
index = i;
}
-
+
}
if (pMax) *pMax = max;
@@ -344,7 +344,7 @@ void MathUtilities::adaptiveThreshold(std::vector<double> &data)
if (sz == 0) return;
std::vector<double> smoothed(sz);
-
+
int p_pre = 8;
int p_post = 7;
diff --git a/libs/qm-dsp/maths/MathUtilities.h b/libs/qm-dsp/maths/MathUtilities.h
index 1d3395e8ad..85774756d4 100644
--- a/libs/qm-dsp/maths/MathUtilities.h
+++ b/libs/qm-dsp/maths/MathUtilities.h
@@ -22,7 +22,7 @@
class MathUtilities
{
-public:
+public:
static double round( double x );
static void getFrameMinMax( const double* data, unsigned int len, double* min, double* max );
diff --git a/libs/qm-dsp/maths/pca/pca.c b/libs/qm-dsp/maths/pca/pca.c
index 288ec4d2e4..d2b2f11c47 100644
--- a/libs/qm-dsp/maths/pca/pca.c
+++ b/libs/qm-dsp/maths/pca/pca.c
@@ -110,7 +110,7 @@ void tred2(double** a, int n, double* d, double* e)
{
int l, k, j, i;
double scale, hh, h, g, f;
-
+
for (i = n-1; i >= 1; i--)
{
l = i - 1;
@@ -188,7 +188,7 @@ void tqli(double* d, double* e, int n, double** z)
{
int m, l, iter, i, k;
double s, r, p, g, f, dd, c, b;
-
+
for (i = 1; i < n; i++)
e[i-1] = e[i];
e[n-1] = 0.0;
@@ -253,19 +253,19 @@ void pca_project(double** data, int n, int m, int ncomponents)
{
int i, j, k, k2;
double **symmat, **symmat2, *evals, *interm;
-
+
//TODO: assert ncomponents < m
-
+
symmat = (double**) malloc(m*sizeof(double*));
for (i = 0; i < m; i++)
symmat[i] = (double*) malloc(m*sizeof(double));
-
+
covcol(data, n, m, symmat);
-
+
/*********************************************************************
Eigen-reduction
**********************************************************************/
-
+
/* Allocate storage for dummy and new vectors. */
evals = (double*) malloc(m*sizeof(double)); /* Storage alloc. for vector of eigenvalues */
interm = (double*) malloc(m*sizeof(double)); /* Storage alloc. for 'intermediate' vector */
@@ -278,7 +278,7 @@ void pca_project(double** data, int n, int m, int ncomponents)
tred2(symmat, m, evals, interm); /* Triangular decomposition */
tqli(evals, interm, m, symmat); /* Reduction of sym. trid. matrix */
/* evals now contains the eigenvalues,
-columns of symmat now contain the associated eigenvectors. */
+columns of symmat now contain the associated eigenvectors. */
/*
printf("\nEigenvalues:\n");
@@ -289,7 +289,7 @@ columns of symmat now contain the associated eigenvectors. */
printf("Eigenvalues are often expressed as cumulative\n");
printf("percentages, representing the 'percentage variance\n");
printf("explained' by the associated axis or principal component.)\n");
-
+
printf("\nEigenvectors:\n");
printf("(First three; their definition in terms of original vbes.)\n");
for (j = 0; j < m; j++) {
@@ -310,7 +310,7 @@ for (i = 0; i < n; i++) {
}
}
-/*
+/*
printf("\nProjections of row-points on first 3 prin. comps.:\n");
for (i = 0; i < n; i++) {
for (j = 0; j < 3; j++) {