qm-dsp
1.8
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 QM DSP Library 00005 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file 2005-2006 Christian Landone. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #include "Correlation.h" 00017 00019 // Construction/Destruction 00021 00022 Correlation::Correlation() 00023 { 00024 00025 } 00026 00027 Correlation::~Correlation() 00028 { 00029 00030 } 00031 00032 void Correlation::doAutoUnBiased(double *src, double *dst, unsigned int length) 00033 { 00034 double tmp = 0.0; 00035 double outVal = 0.0; 00036 00037 unsigned int i,j; 00038 00039 for( i = 0; i < length; i++) 00040 { 00041 for( j = i; j < length; j++) 00042 { 00043 tmp += src[ j-i ] * src[ j ]; 00044 } 00045 00046 00047 outVal = tmp / ( length - i ); 00048 00049 if( outVal <= 0 ) 00050 dst[ i ] = EPS; 00051 else 00052 dst[ i ] = outVal; 00053 00054 tmp = 0.0; 00055 } 00056 }