Mercurial > hg > qm-dsp
annotate maths/Correlation.cpp @ 515:08bcc06c38ec tip master
Remove fast-math
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 28 Jan 2020 15:27:37 +0000 |
parents | af5b7ef02aa7 |
children |
rev | line source |
---|---|
c@241 | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
c@241 | 2 |
c@241 | 3 /* |
c@241 | 4 QM DSP Library |
c@241 | 5 |
c@241 | 6 Centre for Digital Music, Queen Mary, University of London. |
c@309 | 7 This file 2005-2006 Christian Landone. |
c@309 | 8 |
c@309 | 9 This program is free software; you can redistribute it and/or |
c@309 | 10 modify it under the terms of the GNU General Public License as |
c@309 | 11 published by the Free Software Foundation; either version 2 of the |
c@309 | 12 License, or (at your option) any later version. See the file |
c@309 | 13 COPYING included with this distribution for more information. |
c@241 | 14 */ |
c@241 | 15 |
c@241 | 16 #include "Correlation.h" |
c@241 | 17 |
cannam@489 | 18 #include "MathAliases.h" |
cannam@489 | 19 |
c@241 | 20 ////////////////////////////////////////////////////////////////////// |
c@241 | 21 // Construction/Destruction |
c@241 | 22 ////////////////////////////////////////////////////////////////////// |
c@241 | 23 |
c@241 | 24 Correlation::Correlation() |
c@241 | 25 { |
c@241 | 26 |
c@241 | 27 } |
c@241 | 28 |
c@241 | 29 Correlation::~Correlation() |
c@241 | 30 { |
c@241 | 31 |
c@241 | 32 } |
c@241 | 33 |
cannam@499 | 34 void Correlation::doAutoUnBiased(double *src, double *dst, int length) |
c@241 | 35 { |
c@241 | 36 double tmp = 0.0; |
c@241 | 37 double outVal = 0.0; |
c@241 | 38 |
cannam@499 | 39 int i, j; |
c@241 | 40 |
cannam@499 | 41 for (i = 0; i < length; i++) { |
cannam@499 | 42 for (j = i; j < length; j++) { |
cannam@477 | 43 tmp += src[ j-i ] * src[ j ]; |
cannam@477 | 44 } |
c@241 | 45 |
cannam@477 | 46 outVal = tmp / ( length - i ); |
c@241 | 47 |
cannam@499 | 48 if (outVal <= 0) { |
cannam@477 | 49 dst[ i ] = EPS; |
cannam@477 | 50 } else { |
cannam@477 | 51 dst[ i ] = outVal; |
cannam@477 | 52 } |
cannam@477 | 53 |
cannam@477 | 54 tmp = 0.0; |
c@241 | 55 } |
c@241 | 56 } |