| 48 | } |
| 49 | |
| 50 | af_err af_iir(af_array* y, const af_array b, const af_array a, |
| 51 | const af_array x) { |
| 52 | try { |
| 53 | const ArrayInfo& ainfo = getInfo(a); |
| 54 | const ArrayInfo& binfo = getInfo(b); |
| 55 | const ArrayInfo& xinfo = getInfo(x); |
| 56 | |
| 57 | af_dtype xtype = xinfo.getType(); |
| 58 | |
| 59 | ARG_ASSERT(1, ainfo.getType() == xtype); |
| 60 | ARG_ASSERT(2, binfo.getType() == xtype); |
| 61 | ARG_ASSERT(1, binfo.ndims() == ainfo.ndims()); |
| 62 | |
| 63 | dim4 adims = ainfo.dims(); |
| 64 | dim4 bdims = binfo.dims(); |
| 65 | dim4 xdims = xinfo.dims(); |
| 66 | |
| 67 | if (xinfo.ndims() == 0) { return af_retain_array(y, x); } |
| 68 | |
| 69 | if (xinfo.ndims() > 1) { |
| 70 | if (binfo.ndims() > 1) { |
| 71 | for (int i = 1; i < 3; i++) { |
| 72 | ARG_ASSERT(1, bdims[i] == xdims[i]); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | // If only a0 is available, just normalize b and perform fir |
| 78 | if (adims[0] == 1) { |
| 79 | af_array bnorm = 0; |
| 80 | AF_CHECK(af_div(&bnorm, b, a, true)); |
| 81 | AF_CHECK(af_fir(y, bnorm, x)); |
| 82 | AF_CHECK(af_release_array(bnorm)); |
| 83 | return AF_SUCCESS; |
| 84 | } |
| 85 | |
| 86 | af_array res; |
| 87 | switch (xtype) { |
| 88 | case f32: res = iir<float>(b, a, x); break; |
| 89 | case f64: res = iir<double>(b, a, x); break; |
| 90 | case c32: res = iir<cfloat>(b, a, x); break; |
| 91 | case c64: res = iir<cdouble>(b, a, x); break; |
| 92 | default: TYPE_ERROR(1, xtype); |
| 93 | } |
| 94 | |
| 95 | std::swap(*y, res); |
| 96 | } |
| 97 | CATCHALL; |
| 98 | return AF_SUCCESS; |
| 99 | } |
no test coverage detected