40#include <itpp/itexports.h>
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);
173template <
class Num_T>
174void 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));
229template <
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);
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);
297vec Freq_Filt<Num_T>::overlap_add(
const vec &x)
305svec Freq_Filt<Num_T>::overlap_add(
const svec &x)
313ivec Freq_Filt<Num_T>::overlap_add(
const ivec &x)
321cvec Freq_Filt<Num_T>::overlap_add(
const cvec &x)
334ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Freq_Filt<double>;
335ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Freq_Filt<std::complex<double> >;
336ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Freq_Filt<short>;
337ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Freq_Filt<int>;
Freq_Filt Frequency domain filtering using the overlap-add technique.
int get_blk_size()
Return the data block size.
Freq_Filt(const Vec< Num_T > &b, const int xlength)
Constructor with initialization of the impulse response b.
int get_fft_size()
Return FFT size.
Vec< Num_T > filter(const Vec< Num_T > &x, const int strm=0)
Filter data in the input vector x.
void zeros()
Set the vector to the all zero vector.
void set_size(int size, bool copy=false)
Set length of vector. if copy = true then keeping the old values.
int length() const
The size of the vector.
Definitions of converters between different vector and matrix types.
Elementary mathematical functions - header file.
ITPP_EXPORT void ifft(const cvec &in, cvec &out)
Inverse Fast Fourier Transform.
ITPP_EXPORT void fft(const cvec &in, cvec &out)
Fast Fourier Transform.
vec pow(const double x, const vec &y)
Calculates x to the power of y (x^y)
vec log2(const vec &x)
log-2 of the elements
int min_index(const Vec< T > &in)
Return the postion of the minimum element in the vector.
vec real(const cvec &data)
Real part of complex values.
vec linspace(double from, double to, int points)
linspace (works in the same way as the MATLAB version)
vec impulse(int size)
Impulse vector.
Various functions on vectors and matrices - header file.
Minimum and maximum functions on vectors and matrices.
cvec to_cvec(const Vec< T > &v)
Converts a Vec<T> to cvec.
svec to_svec(const Vec< T > &v)
Converts a Vec<T> to svec.
vec ceil(const vec &x)
Round to nearest upper integer.
const Array< T > concat(const Array< T > &a, const T &e)
Append element e to the end of the Array a.
vec to_vec(const Vec< T > &v)
Converts a Vec<T> to vec.
ivec to_ivec(const Vec< T > &v)
Converts a Vec<T> to ivec.
Mat< Num_T > elem_mult(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Element wise multiplication of two matrices.
Definitions of special vectors and matrices.
Templated Vector Class Definitions.