IT++ Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
freq_filt.cpp
Go to the documentation of this file.
1 
29 #include <itpp/signal/freq_filt.h>
30 #include <itpp/signal/transforms.h>
32 
34 
35 namespace itpp
36 {
37 
38 // Overlap-add routine
39 template<class Num_T>
40 void Freq_Filt<Num_T>::overlap_add(const cvec&x, cvec &y)
41 {
42  int nb = impulse.length();
43  int nx = x.length();
44 
45  y.set_size(nx, false);
46  y.zeros();
47  cvec X, Y;
48  int istart = 0;
49  int L = blksize;
50  while (istart < nx) {
51  int iend = std::min(istart + L - 1, nx - 1);
52 
53  X = fft(x(istart, iend), fftsize);
54  Y = ifft(elem_mult(X, B));
55  Y.set_subvector(0, Y(0, nb - 2) + zfinal);
56  int yend = std::min(nx - 1, istart + fftsize - 1);
57  y.set_subvector(istart, Y(0, yend - istart));
58  zfinal = Y(fftsize - (nb - 1), fftsize - 1);
59  istart += L;
60  }
61 }
62 
63 template<>
64 vec Freq_Filt<double>::overlap_add(const vec &x)
65 {
66  cvec y; // Size of y is set later
67  overlap_add(to_cvec(x), y);
68  return real(y);
69 }
70 
71 template<>
72 svec Freq_Filt<short>::overlap_add(const svec &x)
73 {
74  cvec y; // Size of y is set later
75  overlap_add(to_cvec(x), y);
76  return to_svec(real(y));
77 }
78 
79 template<>
80 ivec Freq_Filt<int>::overlap_add(const ivec &x)
81 {
82  cvec y; // Size of y is set later
83  overlap_add(to_cvec(x), y);
84  return to_ivec(real(y));
85 }
86 
87 template<>
88 cvec Freq_Filt<std::complex<double> >::overlap_add(const cvec &x)
89 {
90  cvec y; // Size of y is set later
91  overlap_add(x, y);
92  return y;
93 }
94 
95 } // namespace itpp
96 
SourceForge Logo

Generated on Fri Mar 21 2014 17:14:14 for IT++ by Doxygen 1.8.1.2