Python: 1d array circular convolution

前端 未结 2 622
逝去的感伤
逝去的感伤 2021-01-05 13:49

I wonder if there\'s a function in numpy/scipy for 1d array circular convolution. The scipy.signal.convolve() function only provides \"mode\" but not \"boundary\", while the

2条回答
  •  伪装坚强ぢ
    2021-01-05 14:47

    By convolution theorem, you can use Fourier Transform to get circular convolution.

    import numpy as np
    def conv_circ( signal, ker ):
        '''
            signal: real 1D array
            ker: real 1D array
            signal and ker must have same shape
        '''
        return np.real(np.fft.ifft( np.fft.fft(signal)*np.fft.fft(ker) ))
    

提交回复
热议问题