Demonstration of fast matrix convolution C++

convolve2(a, b)

Arguments

a

a numeric matrix

b

a numeric matrix

Details

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.

See also

convolve

Examples

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