README.md

mops

Optimized matrix operations, such as row/col sums.

library(rbenchmark)
library(mops)

m = 5000
n = 5000
x = matrix(rnorm(m*n), m, n)
cols <- cols <- c("test", "replications", "elapsed", "relative")

benchmark(a <- colSums(x), b <- col_sums(x), columns=cols)
##               test replications elapsed relative
## 1  a <- colSums(x)          100   2.554    2.234
## 2 b <- col_sums(x)          100   1.143    1.000
all.equal(a, b)
## [1] TRUE

benchmark(a <- rowSums(x), b <- row_sums(x), columns=cols)
##               test replications elapsed relative
## 1  a <- rowSums(x)          100   7.102    4.478
## 2 b <- row_sums(x)          100   1.586    1.000
all.equal(a, b)
## [1] TRUE


wrathematics/mops documentation built on May 28, 2017, 6:27 a.m.