| 41 | |
| 42 | template<typename T> |
| 43 | void firTest(const int xrows, const int xcols, const int brows, |
| 44 | const int bcols) { |
| 45 | SUPPORTED_TYPE_CHECK(T); |
| 46 | try { |
| 47 | dtype ty = (dtype)dtype_traits<T>::af_type; |
| 48 | array x = randu(xrows, xcols, ty); |
| 49 | array b = randu(brows, bcols, ty); |
| 50 | |
| 51 | array y = fir(b, x); |
| 52 | array c = convolve1(x, b, AF_CONV_EXPAND); |
| 53 | |
| 54 | const int ycols = xcols * bcols; |
| 55 | const int crows = xrows + brows - 1; |
| 56 | const int yrows = xrows; |
| 57 | |
| 58 | vector<T> hy(yrows * ycols); |
| 59 | vector<T> hc(crows * ycols); |
| 60 | |
| 61 | y.host(&hy[0]); |
| 62 | c.host(&hc[0]); |
| 63 | |
| 64 | for (int j = 0; j < ycols; j++) { |
| 65 | for (int i = 0; i < yrows; i++) { |
| 66 | ASSERT_NEAR(real(hy[j * yrows + i]), real(hc[j * crows + i]), |
| 67 | 0.01); |
| 68 | } |
| 69 | } |
| 70 | } catch (exception &ex) { FAIL() << ex.what(); } |
| 71 | } |
| 72 | |
| 73 | TYPED_TEST(filter, firVecVec) { firTest<TypeParam>(10000, 1, 1000, 1); } |
| 74 | |