/*---------------------------------------------------------------------------* * IT++ * *---------------------------------------------------------------------------* * Copyright (c) 1995-2004 by Tony Ottosson, Thomas Eriksson, Pål Frenger, * * Tobias Ringström, and Jonas Samuelsson. * * * * Permission to use, copy, modify, and distribute this software and its * * documentation under the terms of the GNU General Public License is hereby * * granted. No representations are made about the suitability of this * * software for any purpose. It is provided "as is" without expressed or * * implied warranty. See the GNU General Public License for more details. * *---------------------------------------------------------------------------*/ /*! \file \brief Implementation of signal processing functions. \author Tony Ottosson, Thomas Eriksson, Pål Frenger, and Tobias Ringström 1.8 2004/09/03 09:27:35 */ #include "base/elmatfunc.h" #include "base/matfunc.h" #include "base/stat.h" #include "base/specmat.h" #include "base/operators.h" #include "base/sigfun.h" #include namespace itpp { void xcorr(const vec &x, vec &out, const int max_lag, const string scaleopt) { int m, n; double s, M_double, coeff_scale = 0.0; int M, N; M = x.size(); M_double = double(M); if (max_lag==-1) { N = x.size(); } else { N = max_lag + 1; } out.set_size(2*N-1,false); it_assert(N<=x.size(),"xcorr: max_lag cannot be as large as, or larger than, the length of x."); for (m=0;my_size) { it_assert(scaleopt=="none","xcorr: scaleopt must be none for different size vectors x and y"); y.set_size(x_size,true); D = x_size - y_size; for (d=0; d v.size()) { P = sqr(abs( fft(to_cvec(elem_mult(zero_pad(v, nfft), w)))(0, nfft/2) )); P /= w_energy; } else { int k = (v.size()-noverlap) / (nfft-noverlap), idx = 0; for (int i=0; i v.size()) { P = sqr(abs( fft(to_cvec(elem_mult(zero_pad(v, nfft), w)))(0, nfft/2) )); P /= w_energy; } else { int k = (v.size()-noverlap) / (nfft-noverlap), idx = 0; for (int i=0; i