[Rcpp-devel] bounds checking disabled for RcppEigen?

Dirk Eddelbuettel edd at debian.org
Wed Aug 1 23:34:20 CEST 2012


On 1 August 2012 at 16:05, Douglas Bates wrote:
| On Wed, Aug 1, 2012 at 12:46 PM, Andrew Slaughter
| <andrew.slaughter at gmail.com> wrote:
| > First of all, great job with Rcpp - it's an awesome tool, and finally gave
| > me a reason to go back to my C++ books and get beyond "Hello World"!
| >
| > I did have a question about RcppEigen, though: specifically, when I use
| > RcppEigen through inline, is bounds checking disabled? If not, how could I
| > go about disabling it? I did try adding the eigen_no_debug flag to my
| > includes, but it wouldn't compile. (I know the preferred way might be to
| > build a package, but inline is so much faster for quickly testing changes to
| > my code, I hate to give it up right now.)
| 
| Actually I think the debug checking is, by default, turned off in R
| package compilation with the -DNDEBUG flag unless you work out a way
| to override it.  I'm not sure if that applies in code compiled through
| the inline package.

It is a recent feature of R itself, and comes from its Makeconf file -- in a
well-intenioned-but-really-rather-cruel attempt to get rid of things like
calls to assert().  

But this also has side effects, so for RcppArmadillo we actually undo this at
the bottom of RcppArmadilloConfig.h :

  // R now defines NDEBUG which suppresses a number of useful Armadillo tests
  // Users can still defined it later, and/or define ARMA_NO_DEBUG
  #if defined(NDEBUG)
  #undef NDEBUG
  #endif


As for Andrew's earlier comment re

| > Since RcppArmadillo was much slower than using STL vectors last time I tried
| > it, I decided to benchmark Eigen before rewriting any code (see code below

Could you try to demonstrate that with a quick example? I'd be surprised if
it were generally true, outside of maybe a corner-case or unusual config you
may have hit upon.

Dirk

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


More information about the Rcpp-devel mailing list