circular-buffer_canonical_realization_1.c

来自「DSP訊號處理的原始碼 開發工具為C和Matlab」· C语言 代码 · 共 34 行

C
34
字号
/* ccan.c - circular buffer implementation of canonical realization */void wrap();                              /* defined in \ref{hardware.sec} */double ccan(M, a, b, w, p, x)             /* usage: y=ccan(M, a, b, w, &p, x); */double *a, *b, *w, **p, x;                /* \(p\) = circular pointer to buffer \(w\) */int M;                                    /* \(a,b\) have common order \(M\) */{       int i;       double y = 0, s0;       **p = x;                                 /* read input sample \(x\) */       s0  = *(*p)++;                           /* \(s\sb{0}=x\) */       wrap(M, w, p);                           /* \(p\) now points to \(s\sb{1}\) */       for (a++, i=1; i<=M; i++) {              /* start with \(a\) incremented to \(a\sb{1}\) */              s0 -= (*a++) * (*(*p)++);              wrap(M, w, p);              }       **p = s0;                                /* \(p\) has wrapped around once */       for (i=0; i<=M; i++) {                   /* numerator part */              y += (*b++) * (*(*p)++);              wrap(M, w, p);                    /* upon exit, \(p\) has wrapped */              }                                 /* around once again */       (*p)--;                                  /* update circular delay line */       wrap(M, w, p);       return y;                                /* output sample */}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?