[Rcpp-devel] RcppArmadillo questions

Douglas Bates bates at stat.wisc.edu
Thu May 27 18:21:29 CEST 2010


On Thu, May 27, 2010 at 11:24 AM, Vinh Nguyen <vinhdizzo at gmail.com> wrote:
> Two questions:
>
> 1.  The main difference when using RcppArmadillo and Rcpp is the
> header declaration and the return type for the function right?
> extern "C" SEXP fastLm(SEXP ys, SEXP Xs) {}
> RcppArmadillo takes this extern stuff whereas Rcpp takes RcppExport?
> RcppExport SEXP newRcppVectorExample(SEXP vector) {}

No.  The main difference is that RcppArmadillo is another package that
depends on Rcpp and provides an interface between Rcpp structures and
the structures in the Armadillo C++ linear algebra library.

If, to borrow a phrase from Duncan Murdoch, you had considered the
situation sufficiently extreme to cause you to read the documentation,
you would have discovered this.

The RcppExport macro is simply another way of writing `extern "C" SEXP'.
> 2.  From the example, if I update the elements of X or Xr, then both
> are updated correct?  Because they are pointing to the same thing.
> Just want to make sure.  I'm dealing with both since Xr is used to
> deal with some R objects, and X is used to do matrix multiplication,
> etc.
> arma::mat X(Xr.begin(), n, k, false);       // reuses memory and
> avoids extra copy
> arma::colvec y(yr.begin(), yr.size(), false);
>
> Thanks.
> Vinh
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>


More information about the Rcpp-devel mailing list