Mercurial > hg > constant-q-cpp
comparison src/dsp/MathUtilities.cpp @ 126:b87290781071
README file, some text tweaks, avoid compiler warning
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 16 May 2014 09:06:34 +0100 |
parents | a38d6940f8fb |
children |
comparison
equal
deleted
inserted
replaced
125:b3f72e67e543 | 126:b87290781071 |
---|---|
103 double MathUtilities::median(const double *src, unsigned int len) | 103 double MathUtilities::median(const double *src, unsigned int len) |
104 { | 104 { |
105 if (len == 0) return 0; | 105 if (len == 0) return 0; |
106 | 106 |
107 std::vector<double> scratch; | 107 std::vector<double> scratch; |
108 for (int i = 0; i < len; ++i) scratch.push_back(src[i]); | 108 for (int i = 0; i < (int)len; ++i) scratch.push_back(src[i]); |
109 std::sort(scratch.begin(), scratch.end()); | 109 std::sort(scratch.begin(), scratch.end()); |
110 | 110 |
111 int middle = len/2; | 111 int middle = len/2; |
112 if (len % 2 == 0) { | 112 if (len % 2 == 0) { |
113 return (scratch[middle] + scratch[middle - 1]) / 2; | 113 return (scratch[middle] + scratch[middle - 1]) / 2; |