34 #ifndef __INCLUDE_FILTER_IIR_FILTER_H__
35 #define __INCLUDE_FILTER_IIR_FILTER_H__
38 #ifndef __INCLUDE_MIST_H__
42 #ifndef __INCLUDE_MIST_TYPE_TRAIT_H__
43 #include "../config/type_trait.h"
53 namespace __iir_filter__
56 template<
class T,
class Allocator>
58 const array1<T, Allocator>& in,
59 array1<T, Allocator>& out,
61 const array1<T, Allocator>& a,
62 const array1<T, Allocator>& b)
64 array1<double> buf(order + 2, 0.0);
66 out.resize(in.size());
69 for(
int n = 0; n < in.size(); n ++)
71 out[n] = output = b[0] * in[n] + buf[1];
73 for(
int k = 1; k < order + 1; k ++)
75 buf[k] = (b[k] * in[n]) - (a[k] * output) + buf[k + 1];
81 template<
class T,
class Allocator>
83 const array1<T, Allocator>& in,
84 array1<T, Allocator>& out,
87 const array2<T, Allocator>& a,
88 const array2<T, Allocator>& b)
90 array2<double> buf(blocks + 1, order + 2, 0.0);
92 out.resize(in.size());
95 for(
int n = 0; n < in.size(); n ++)
99 for(
int blk = 1; blk < blocks + 1; blk ++)
101 buf(blk, 0) = output = b(blk - 1, 0) * buf(blk - 1, 0) + buf(blk, 1);
103 for(
int k = 1; k < order + 1; k ++)
105 buf(blk, k) = (b(blk - 1, k) * buf(blk - 1, 0)) - (a(blk - 1, k) * output) + buf(blk, k + 1);
109 out[n] = buf(blocks, 0);
119 #endif // __INCLUDE_FILTER_IIR_FILTER_H__