IT++ Logo

freq_filt.cpp

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

Generated on Wed Feb 9 2011 13:47:17 for IT++ by Doxygen 1.7.3