- Joined
- 4/8/11
- Messages
- 131
- Points
- 138
Here are time stats for running a max row function 100 times for each implementation using STL versus Armadillo versus Eigen on a matrix 50000 rows by 1000 columns containing random numbers between 0 and 3.
The R code.
On average the Armadillo is faster than the STL and Eigen implementations.
The cpp implementations are attached
The R code.
Code:
library(Rcpp)
library(RcppArmadillo)
library(RcppEigen)
library(microbenchmark)
library(ggplot2)
Dummy <- matrix(runif(50000000,0,3), ncol = 1000)
sourceCpp("algorithm_matrix_STL.cpp")
sourceCpp("algorithm_matrix_Armadillo.cpp")
sourceCpp("algorithm_matrix_eigen.cpp")
tm <- microbenchmark::microbenchmark(MaxColSTL(Dummy), #Using STL algorithm max_element
MaxColArmadillo(Dummy), #Using RcppArmadillo
MaxColEigen(Dummy)) #Using RcppEigen
Code:
Unit: milliseconds
expr min lq mean median uq max neval
MaxColSTL(Dummy) 411.0509 462.6502 523.6478 540.9864 559.2189 640.5903 100
MaxColArmadillo(Dummy) 241.8327 276.9529 374.6993 288.3489 301.6745 8648.5732 100
MaxColEigen(Dummy) 345.9504 385.0690 405.8978 397.7753 422.4927 513.8324 100
On average the Armadillo is faster than the STL and Eigen implementations.
The cpp implementations are attached