[Rcpp-devel] Can one use both RcppArmadillo and RcppEigen in the same package?

Dirk Eddelbuettel edd at debian.org
Wed Aug 27 21:16:57 CEST 2014


On 27 August 2014 at 15:00, Avraham Adler wrote:
| Can one use both RcppArmadillo and RcppEigen in the same package?

I think so. 

| I can "source"
| both in RStudio and get the code to work, but when I try and build, I get
| errors, probably because RcppEigen imports Rcpp and RcppArmadillo complains
| about that.

Yes. We added a test to RcppArmadillo.h to ensure Rcpp.h was not yet
loaded. Worst case you may need to work around that. RcppEigen.h does not
have that as I recall, but may still run into trouble if included after
RcppArmadillo. 

One idea:

   mypackage.h          includes only Rcpp.h
 
   mypackageArma.h      includes  RcppArmadillo.h
   mypackageEigen.h     includes  RcppEigen.h

and you then dispatch by hand.  

At the end of the day, "everything" conforms to

   SEXP someName(SEXP a, SEXP b, SEXP c, ...)

so you should be able to find common ground at these C-language signatures.
 
| The reason I am interested is to compare speed. I use a fast BLAS (OpenBLAS
| 2.10 compiled for Win764). For square symmetric matrices of size about 100 and
| smaller, the Eigen routine is faster, otherwise the Armadillo routine seems to
| be faster.

Maybe. 

I am a little sceptical whether the difference will hold up for the next
user, the next cpu, the next compiler version, ... but if you feel it is
worth your time then by all means go ahead -- and report back how you did it.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list