c@225: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@225: c@225: /* c@225: QM DSP Library c@225: c@225: Centre for Digital Music, Queen Mary, University of London. c@225: This file copyright 2005-2006 Christian Landone. c@225: All rights reserved. c@225: */ c@225: c@225: #include "Correlation.h" c@225: c@225: ////////////////////////////////////////////////////////////////////// c@225: // Construction/Destruction c@225: ////////////////////////////////////////////////////////////////////// c@225: c@225: Correlation::Correlation() c@225: { c@225: c@225: } c@225: c@225: Correlation::~Correlation() c@225: { c@225: c@225: } c@225: c@225: void Correlation::doAutoUnBiased(double *src, double *dst, unsigned int length) c@225: { c@225: double tmp = 0.0; c@225: double outVal = 0.0; c@225: c@225: unsigned int i,j; c@225: c@225: for( i = 0; i < length; i++) c@225: { c@225: for( j = i; j < length; j++) c@225: { c@225: tmp += src[ j-i ] * src[ j ]; c@225: } c@225: c@225: c@225: outVal = tmp / ( length - i ); c@225: c@225: if( outVal <= 0 ) c@225: dst[ i ] = EPS; c@225: else c@225: dst[ i ] = outVal; c@225: c@225: tmp = 0.0; c@225: } c@225: }