Title: | Strided Iterator and Range |
---|---|
Description: | The strided iterator adapts multidimensional buffers to work with the C++ standard library and range-based for-loops. Given a pointer or iterator into a multidimensional data buffer, one can generate an iterator range using make_strided to construct strided versions of the standard library's begin and end. For constructing range-based for-loops, a strided_range class is provided. These help authors to avoid integer-based indexing, which in some cases can impede algorithm performance and introduce indexing errors. This library exists primarily to expose the header file to other R projects. |
Authors: | Tim Keitt [aut, cre] |
Maintainer: | Tim Keitt <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.3 |
Built: | 2024-11-07 04:27:57 UTC |
Source: | https://github.com/thk686/strider |
Demonstration of fast matrix convolution C++
convolve2(a, b)
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.
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)
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)
Demonstration of fast row and columns sums in C++
row_sums(x) col_sums(x)
row_sums(x) col_sums(x)
x |
a numeric matrix |
A very efficient row summing algorithm that demonstrates
the use of the strided pointer concept. The row_sum
algorithm is
roughly twice as fast as rowSums
. The col_sum
algorithm
matches colSums
for speed.
row_sums(matrix(1:9, 3)) col_sums(matrix(1:9, 3))
row_sums(matrix(1:9, 3)) col_sums(matrix(1:9, 3))