1d linear convolution in ANSI C code?

前端 未结 4 1910
孤城傲影
孤城傲影 2021-02-01 08:49

Rather than reinvent the wheel, I wonder if anyone could refer me to a 1D linear convolution code snippet in ANSI C? I did a search on google and in stack overflow, but couldn\'

4条回答
  •  迷失自我
    2021-02-01 09:32

    Since, we are taking convolution of 2 finite length sequences, hence the desired frequency response is achieved if circular convolution is performed rather than linear convolution. A very simple implementation of circular convolution will achieve the same result as the algorithm given by Alex.

    #define MOD(n, N) ((n<0)? N+n : n)
    ......
    ......
    
    for(n=0; n < signal_Length + Kernel_Length - 1; n++)
    {
        out[n] = 0;
        for(m=0; m < Kernel_Length; m++)
        {
            out[n] = h[m] * x[MOD(n-m, N)];
        }
    }
    

提交回复
热议问题