Mercurial > hg > pyin
comparison YinUtil.cpp @ 60:60eb8771d340 tony
slower, but timestamp-unbiased pyin
author | matthiasm |
---|---|
date | Fri, 07 Mar 2014 10:43:55 +0000 |
parents | b39d6745c596 |
children | d501b52f95b6 |
comparison
equal
deleted
inserted
replaced
59:b13d82111c8f | 60:60eb8771d340 |
---|---|
18 #include <cstdio> | 18 #include <cstdio> |
19 #include <cmath> | 19 #include <cmath> |
20 #include <algorithm> | 20 #include <algorithm> |
21 | 21 |
22 #include <boost/math/distributions.hpp> | 22 #include <boost/math/distributions.hpp> |
23 | |
24 void | |
25 YinUtil::slowDifference(const double *in, double *yinBuffer, const size_t yinBufferSize) | |
26 { | |
27 yinBuffer[0] = 0; | |
28 double delta ; | |
29 int startPoint = 0; | |
30 int endPoint = 0; | |
31 for (int i = 1; i < yinBufferSize; ++i) { | |
32 yinBuffer[i] = 0; | |
33 startPoint = yinBufferSize/2 - i/2; | |
34 endPoint = startPoint + yinBufferSize; | |
35 for (int j = startPoint; j < endPoint; ++j) { | |
36 delta = in[i+j] - in[j]; | |
37 yinBuffer[i] += delta * delta; | |
38 } | |
39 } | |
40 } | |
23 | 41 |
24 void | 42 void |
25 YinUtil::fastDifference(const double *in, double *yinBuffer, const size_t yinBufferSize) | 43 YinUtil::fastDifference(const double *in, double *yinBuffer, const size_t yinBufferSize) |
26 { | 44 { |
27 | 45 |