Demonstration of fast matrix convolution C++
convolve2(a, b)
a | a numeric matrix |
---|---|
b | a numeric matrix |
A very efficient matric convolution implementation that demonstrates the use of the strided pointer and strided range concepts. Performance will be improved if the smaller matrix is given as the second argument.
convolve
a = matrix(c(1, 2, 1, 1, 1, 1), 2, 3, byrow = TRUE) b = matrix(c(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0), 4, 3, byrow = TRUE) convolve2(a, b)#> [,1] [,2] [,3] [,4] [,5] #> [1,] 0 0 0 0 0 #> [2,] 0 0 0 0 0 #> [3,] 0 1 2 1 0 #> [4,] 0 1 1 1 0 #> [5,] 0 0 0 0 0