IT++ Logo
freq_filt.cpp
Go to the documentation of this file.
00001 
00029 #include <itpp/signal/freq_filt.h>
00030 #include <itpp/signal/transforms.h>
00031 #include <itpp/base/math/elem_math.h>
00032 
00034 
00035 namespace itpp
00036 {
00037 
00038 // Overlap-add routine
00039 template<class Num_T>
00040 void Freq_Filt<Num_T>::overlap_add(const cvec&x, cvec &y)
00041 {
00042   int nb = impulse.length();
00043   int nx = x.length();
00044 
00045   y.set_size(nx, false);
00046   y.zeros();
00047   cvec X, Y;
00048   int istart = 0;
00049   int L = blksize;
00050   while (istart < nx) {
00051     int iend = std::min(istart + L - 1, nx - 1);
00052 
00053     X = fft(x(istart, iend), fftsize);
00054     Y = ifft(elem_mult(X, B));
00055     Y.set_subvector(0, Y(0, nb - 2) + zfinal);
00056     int yend = std::min(nx - 1, istart + fftsize - 1);
00057     y.set_subvector(istart, Y(0, yend - istart));
00058     zfinal = Y(fftsize - (nb - 1), fftsize - 1);
00059     istart += L;
00060   }
00061 }
00062 
00063 template<>
00064 vec Freq_Filt<double>::overlap_add(const vec &x)
00065 {
00066   cvec y; // Size of y is set later
00067   overlap_add(to_cvec(x), y);
00068   return real(y);
00069 }
00070 
00071 template<>
00072 svec Freq_Filt<short>::overlap_add(const svec &x)
00073 {
00074   cvec y; // Size of y is set later
00075   overlap_add(to_cvec(x), y);
00076   return to_svec(real(y));
00077 }
00078 
00079 template<>
00080 ivec Freq_Filt<int>::overlap_add(const ivec &x)
00081 {
00082   cvec y; // Size of y is set later
00083   overlap_add(to_cvec(x), y);
00084   return to_ivec(real(y));
00085 }
00086 
00087 template<>
00088 cvec Freq_Filt<std::complex<double> >::overlap_add(const cvec &x)
00089 {
00090   cvec y; // Size of y is set later
00091   overlap_add(x, y);
00092   return y;
00093 }
00094 
00095 } // namespace itpp
00096 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SourceForge Logo

Generated on Wed Jul 27 2011 16:27:05 for IT++ by Doxygen 1.7.4