FIR的一直方便算法实现

来源:互联网 发布:java爬虫书籍推荐2016 编辑:程序博客网 时间:2024/05/17 03:58

/******************************************************/

SAMPLE fir_basic(SAMPLE input, int ntaps, const SAMPLE h[], SAMPLE z[])       {    int ii;    SAMPLE accum;        /* store input at the beginning of the delay line */    z[0] = input;    /* calc FIR */    accum = 0;    for (ii = 0; ii < ntaps; ii++) {        accum += h[ii] * z[ii];    }    /* shift delay line */    for (ii = ntaps - 2; ii >= 0; ii--) {        z[ii + 1] = z[ii];    }    return accum;}/******* taps have been reverse before do fir computation *******/
gr_complexgr_fir_ccc_generic::filter (const gr_complex input[]){  static const int N_UNROLL = 2;  gr_complex    acc0 = 0;  gr_complex    acc1 = 0;  unsigned    i = 0;  unsigned    n = (ntaps () / N_UNROLL) * N_UNROLL;  for (i = 0; i < n; i += N_UNROLL){    acc0 += d_taps[i + 0] *  input[i + 0];    acc1 += d_taps[i + 1] *  input[i + 1];  }  for (; i < ntaps (); i++)    acc0 += d_taps[i] *  input[i];  return (gr_complex) (acc0 + acc1);}



原创粉丝点击