The purpose of zero-padding g is simply to be able to evaluate g_pad for the required values of n-m+1 while avoiding the programming error of trying to use an undefined vector. Extende f and g with zeros, which doesn’t alter the result, and allows for succinct code.Ĭonv = Conv + f_pad * g_pad.Remove the else statement that makes g periodic.In order to do this, we’ll just do the following: Let’s first write an easy implementation against which to test the FFT implementation we’ll do later. This will get us closer to our goal of FFT acceleration of this function. So we could do all the zero-padding we want to do.Īs a second step, we might want to make our convolution function to resemble a cyclic convolution. That way, their cyclic convolution will have (at least) the correct size of N+M-1.Īs we are performing summation, extending the data with zeros clearly won’t affect the result. So at minimum, it seems that we need to pad both signals with enough zeros so they both have length N+M-1. While the cyclic convolution of two length N signals has length N, the linear convolution of two signals of lenght N and M has length N+M-1. Linear Convolution Length and Zero-Padding The most straightforward way to implement this is by modifying the cyclic convolution code written above as little as possible.Īctually, a convenient way to think about this problem is that we will implement a cyclic convolution (to use FFTs) in addition to zero padding, so the result coincides with the linear convolution we want to compute. Given two continuous functions $ f $ and $ g $, their convolution is usually defined as:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |