Mercurial > hg > qm-dsp
comparison maths/Correlation.cpp @ 505:930b5b0f707d
Merge branch 'codestyle-and-tidy'
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Wed, 05 Jun 2019 12:55:15 +0100 |
parents | af5b7ef02aa7 |
children |
comparison
equal
deleted
inserted
replaced
471:e3335cb213da | 505:930b5b0f707d |
---|---|
13 COPYING included with this distribution for more information. | 13 COPYING included with this distribution for more information. |
14 */ | 14 */ |
15 | 15 |
16 #include "Correlation.h" | 16 #include "Correlation.h" |
17 | 17 |
18 #include "MathAliases.h" | |
19 | |
18 ////////////////////////////////////////////////////////////////////// | 20 ////////////////////////////////////////////////////////////////////// |
19 // Construction/Destruction | 21 // Construction/Destruction |
20 ////////////////////////////////////////////////////////////////////// | 22 ////////////////////////////////////////////////////////////////////// |
21 | 23 |
22 Correlation::Correlation() | 24 Correlation::Correlation() |
27 Correlation::~Correlation() | 29 Correlation::~Correlation() |
28 { | 30 { |
29 | 31 |
30 } | 32 } |
31 | 33 |
32 void Correlation::doAutoUnBiased(double *src, double *dst, unsigned int length) | 34 void Correlation::doAutoUnBiased(double *src, double *dst, int length) |
33 { | 35 { |
34 double tmp = 0.0; | 36 double tmp = 0.0; |
35 double outVal = 0.0; | 37 double outVal = 0.0; |
36 | 38 |
37 unsigned int i,j; | 39 int i, j; |
38 | 40 |
39 for( i = 0; i < length; i++) | 41 for (i = 0; i < length; i++) { |
40 { | 42 for (j = i; j < length; j++) { |
41 for( j = i; j < length; j++) | 43 tmp += src[ j-i ] * src[ j ]; |
42 { | 44 } |
43 tmp += src[ j-i ] * src[ j ]; | |
44 } | |
45 | 45 |
46 outVal = tmp / ( length - i ); | |
46 | 47 |
47 outVal = tmp / ( length - i ); | 48 if (outVal <= 0) { |
48 | 49 dst[ i ] = EPS; |
49 if( outVal <= 0 ) | 50 } else { |
50 dst[ i ] = EPS; | 51 dst[ i ] = outVal; |
51 else | 52 } |
52 dst[ i ] = outVal; | 53 |
53 | 54 tmp = 0.0; |
54 tmp = 0.0; | |
55 } | 55 } |
56 } | 56 } |