[Rcpp-devel] shallow/deep copy

Zhongyi Yuan yuanzygoso at gmail.com
Wed Aug 31 17:59:39 CEST 2011


Thanks for the reply, Xian.

The quick reference is quite helpful. Most of the time, I use 'inline' to
create R functions and I think 'inline' includes Rcpp.h which specifies the
namespace Rcpp.
Very often I will need Armadillo and will be "using namespace arma;". Maybe
I should keep using arma:: too, according to Darren's advice.

Zhongyi

On Wed, Aug 31, 2011 at 6:05 AM, Christian Gunning <xian at unm.edu> wrote:

> On Wed, Aug 31, 2011 at 3:00 AM,
> <rcpp-devel-request at r-forge.wu-wien.ac.at> wrote:
> >
> > Rcpp::NumericVector x = as<Rcpp::NumericVector>(x_);
> > std::vector<double> x = as< std::vector<double> >(x_);
>
> Nice clarification of what's going on under the hood, Darren.
> For the first case, the above is synonymous with:
>
>  Rcpp::NumericVector x(x_);
>
> If you want a deep copy, you can use:
>
>  Rcpp::NumericVector x(clone(x_));
>
> See the quickref pdf for examples
> (
> http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-quickref.pdf)..
> ..
> there, "using namespace Rcpp;" is implied throughout unless otherwise
> noted.
>
> -xian
>
> --
> A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110831/ac8d3848/attachment.htm>


More information about the Rcpp-devel mailing list