Discrete convolution can be performed via the Toeplitz matrix, as shown below (Wiki article):
Note that this is not the exact same form as as the general Toeplitz matrix, but it has experienced various shifts and zero-paddings.
Is there a way to achieve this in numpy purely based on roll
, hstack
etc., i.e. without using any for
loops? I have tried all sorts of shifts but I can't really get it in to the form shown above.