Template functions for performing convolutions similar to MATLABs conv and conv2.