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>
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) {
251 old_data.set_size(0,
false);
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>
275 int nb = impulse.length();
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>
304 template<
class Num_T>
312 template<
class Num_T>
320 template<
class Num_T>
343 #endif // #ifndef FREQ_FILT_H
Various functions on vectors and matrices - header file.
Mat< Num_T > elem_mult(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Element wise multiplication of two matrices.
int get_blk_size()
Return the data block size.
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.
Minimum and maximum functions on vectors and matrices.
int get_fft_size()
Return FFT size.
Freq_Filt Frequency domain filtering using the overlap-add techniqueThe Freq_Filt class implements an...
Definitions of converters between different vector and matrix types.
T min(const Vec< T > &in)
Minimum value of vector.
svec to_svec(const Vec< T > &v)
Converts a Vec<T> to svec.
Freq_Filt(const Vec< Num_T > &b, const int xlength)
Constructor with initialization of the impulse response b.
vec log2(const vec &x)
log-2 of the elements
vec pow(const double x, const vec &y)
Calculates x to the power of y (x^y)
vec to_vec(const Vec< T > &v)
Converts a Vec<T> to vec.
int length() const
The size of the vector.
ivec to_ivec(const Vec< T > &v)
Converts a Vec<T> to ivec.
Definitions of special vectors and matrices.
int min_index(const Vec< T > &in)
Return the postion of the minimum element in the vector.
vec linspace(double from, double to, int points)
linspace (works in the same way as the MATLAB version)
cvec to_cvec(const Vec< T > &v)
Converts a Vec<T> to cvec.
Vec< Num_T > filter(const Vec< Num_T > &x, const int strm=0)
Filter data in the input vector x.
Elementary mathematical functions - header file.
vec real(const cvec &data)
Real part of complex values.
vec ceil(const vec &x)
Round to nearest upper integer.
Templated Vector Class Definitions.
const Array< T > concat(const Array< T > &a, const T &e)
Append element e to the end of the Array a.