40 #include <itpp/itexports.h>
111 template<
class Num_T>
157 int fftsize, blksize;
163 void init(
const Vec<Num_T> &b,
const int xlength);
164 vec overlap_add(
const vec &x);
165 svec overlap_add(
const svec &x);
166 ivec overlap_add(
const ivec &x);
167 cvec overlap_add(
const cvec &x);
168 void overlap_add(
const cvec &x, cvec &y);
173 template <
class Num_T>
174 void Freq_Filt<Num_T>::init(
const Vec<Num_T> &b,
const int xlength)
180 int num_elements =
impulse.length();
183 old_data.set_size(0,
false);
186 zfinal.set_size(num_elements - 1,
false);
205 ivec index(n.length());
207 for (
int ii = 0; ii < n.length(); ii++) {
208 if (n(ii) > (num_elements - 1)) {
213 index.set_size(cnt,
true);
215 fftflops = fftflops(index);
219 Lvec = n - (double)(num_elements - 1);
221 fftsize =
static_cast<int>(n(min_ind));
222 blksize =
static_cast<int>(Lvec(min_ind));
229 template <
class Num_T>
245 old_data.set_size(0,
false);
248 tempv =
concat(old_data, input);
249 if (tempv.
length() <= blksize) {
255 int numblks = end / blksize;
256 if ((end % blksize)) {
257 x = tempv(0, blksize * numblks - 1);
258 old_data = tempv(blksize * numblks, end - 1);
261 x = tempv(0, blksize * numblks - 1);
262 old_data.set_size(0,
false);
266 output = overlap_add(x);
272 template<
class Num_T>
278 y.set_size(nx,
false);
283 while (istart < nx) {
284 int iend =
std::min(istart + L - 1, nx - 1);
286 X =
fft(x(istart, iend), fftsize);
288 Y.set_subvector(0, Y(0, nb - 2) + zfinal);
289 int yend =
std::min(nx - 1, istart + fftsize - 1);
290 y.set_subvector(istart, Y(0, yend - istart));
291 zfinal = Y(fftsize - (nb - 1), fftsize - 1);
296 template<
class Num_T>
297 vec Freq_Filt<Num_T>::overlap_add(
const vec &x)
304 template<
class Num_T>
305 svec Freq_Filt<Num_T>::overlap_add(
const svec &x)
312 template<
class Num_T>
313 ivec Freq_Filt<Num_T>::overlap_add(
const ivec &x)
320 template<
class Num_T>
321 cvec Freq_Filt<Num_T>::overlap_add(
const cvec &x)
334 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Freq_Filt<double>;
335 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Freq_Filt<std::complex<double> >;
336 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Freq_Filt<short>;
337 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Freq_Filt<int>;
343 #endif // #ifndef FREQ_FILT_H