| 22 | namespace cuda { |
| 23 | template<typename T> |
| 24 | Array<T> iir(const Array<T> &b, const Array<T> &a, const Array<T> &x) { |
| 25 | AF_BATCH_KIND type = x.ndims() == 1 ? AF_BATCH_NONE : AF_BATCH_SAME; |
| 26 | if (x.ndims() != b.ndims()) { |
| 27 | type = (x.ndims() < b.ndims()) ? AF_BATCH_RHS : AF_BATCH_LHS; |
| 28 | } |
| 29 | |
| 30 | // Extract the first N elements |
| 31 | Array<T> c = convolve<T, T>(x, b, type, 1, true); |
| 32 | dim4 cdims = c.dims(); |
| 33 | cdims[0] = x.dims()[0]; |
| 34 | c.resetDims(cdims); |
| 35 | |
| 36 | int num_a = a.dims()[0]; |
| 37 | |
| 38 | if (num_a == 1) { return c; } |
| 39 | |
| 40 | dim4 ydims = c.dims(); |
| 41 | Array<T> y = createEmptyArray<T>(ydims); |
| 42 | |
| 43 | if (a.ndims() > 1) { |
| 44 | kernel::iir<T, true>(y, c, a); |
| 45 | } else { |
| 46 | kernel::iir<T, false>(y, c, a); |
| 47 | } |
| 48 | return y; |
| 49 | } |
| 50 | |
| 51 | #define INSTANTIATE(T) \ |
| 52 | template Array<T> iir(const Array<T> &b, const Array<T> &a, \ |