Demonstration of fast row and columns sums in C++
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.
rowSums, colSums
row_sums(matrix(1:9, 3))#> [1] 12 15 18col_sums(matrix(1:9, 3))#> [1] 6 15 24