[Rcpp-devel] How much speedup for matrix operations?
Xavier Robin
xavier at cbs.dtu.dk
Wed Nov 6 18:35:45 CET 2013
Hi,
I have a pure-R code that spends most of the time performing vector and
matrix operations, as shown by the summary of Rprof:
> self.time self.pct total.time total.pct
> "%*%" 903.24 77.67 903.24 77.67
> "t.default" 76.26 6.56 76.26 6.56
> "-" 36.60 3.15 36.60 3.15
> "+" 24.44 2.10 24.44 2.10
> "/" 24.22 2.08 24.22 2.08
> "exp" 20.26 1.74 20.26 1.74
> "predict.myClass" 17.68 1.52 503.82 43.32
> "*" 11.90 1.02 11.90 1.02
> "t" 9.38 0.81 811.94 69.82
> "update.batch" 8.04 0.69 654.68 56.30
> ...
So mostly matrix %*% matrix multiplications, transpositions, vector +-/*
matrix operations and exponentiations, representing >95% of the
computation time.
I have very few loops and if/else blocks.
I want to speed up this code, and I am considering reimplementing it (or
part of it) with RcppEigen or RcppArmadillo.
However, I read that both Eigen and Amarillo use the underlying BLAS,
like R.
My question is, can I expect any significant speed-up from an Rcpp
re-implementation in this case, given it is already mostly matrix
algebra (which are supposed to be pretty efficient in R)?
Thanks,
Xavier
--
Xavier Robin, PhD
Cellular Signal Integration Group (C-SIG) - http://www.lindinglab.org
Center for Biological Sequence Analysis (CBS) - http://www.cbs.dtu.dk
Department of Systems Biology - Technical University of Denmark (DTU)
Anker Engelundsvej, Building 301, DK-2800 Lyngby, DENMARK.
More information about the Rcpp-devel
mailing list