| 80 | |
| 81 | template<typename T> |
| 82 | void iirA0Test(const int xrows, const int xcols, const int brows, |
| 83 | const int bcols) { |
| 84 | SUPPORTED_TYPE_CHECK(T); |
| 85 | try { |
| 86 | dtype ty = (dtype)dtype_traits<T>::af_type; |
| 87 | array x = randu(xrows, xcols, ty); |
| 88 | array b = randu(brows, bcols, ty); |
| 89 | array a = randu(1, bcols, ty); |
| 90 | array bNorm = b / tile(a, brows); |
| 91 | |
| 92 | array y = iir(b, a, x); |
| 93 | array c = convolve1(x, bNorm, AF_CONV_EXPAND); |
| 94 | |
| 95 | const int ycols = xcols * bcols; |
| 96 | const int crows = xrows + brows - 1; |
| 97 | const int yrows = xrows; |
| 98 | |
| 99 | vector<T> hy(yrows * ycols); |
| 100 | vector<T> hc(crows * ycols); |
| 101 | |
| 102 | y.host(&hy[0]); |
| 103 | c.host(&hc[0]); |
| 104 | |
| 105 | for (int j = 0; j < ycols; j++) { |
| 106 | for (int i = 0; i < yrows; i++) { |
| 107 | ASSERT_NEAR(real(hy[j * yrows + i]), real(hc[j * crows + i]), |
| 108 | 0.01); |
| 109 | } |
| 110 | } |
| 111 | } catch (exception &ex) { FAIL() << ex.what(); } |
| 112 | } |
| 113 | |
| 114 | TYPED_TEST(filter, iirA0VecVec) { iirA0Test<TypeParam>(10000, 1, 1000, 1); } |
| 115 | |