Advertisement
grizlik

IIR

May 10th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <deque>
  4. #include <numeric>
  5.  
  6. int main()
  7. {
  8.     std::vector<double> b = { 0.0089, -0.0045, -0.0045, 0.0089 };
  9.     std::vector<double> a = { 1, 2.5641, -2.2185, 0.6456 };
  10.  
  11.     std::deque<double> d( std::max(a.size(), b.size()) );
  12.  
  13.     for (int i = 0; i < 150; ++i)
  14.     {
  15.         d.push_front(1.0);
  16.         d.pop_back();
  17.         d[0] = std::inner_product(begin(a), end(a), begin(d), 0.0);
  18.         double y = std::inner_product(begin(b), end(b), begin(d), 0.0);
  19.         std::cout << y << std::endl;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement