I still don't think copying is going to be that
expensive (at least for std::vector -- who knows
what Rcpp::NumericVector is up to).
From the mailing list discussion Jiqiang linked, it looks like
it might involve LESS copying to create the Rcpp::Numeric
vector from an existing std::vector rather than passing
in an Rcpp:Numeric reference as I did with std::vector (because
of the dynamic resizing required in that scenario, each of
which involves a copy, and perhaps over-allocation to boot).
That is, create the std::vector then use the iterator
begin/end constructor for Rcpp::Numeric. Hopefully they'll
do the iterator diff (end - begin) and preallocate then fill.
- Bob
-------- Original Message --------
Subject: [stan-dev] no resize() for Rcpp's Vector
Date: Wed, 30 May 2012 16:07:40 -0400
From: Jiqiang Guo <
guo...@gmail.com>
Reply-To:
stan...@googlegroups.com
To:
stan...@googlegroups.com
You could ignore the following except if you are interested in some Rcpp
stuff.
On Wed, May 30, 2012 at 2:15 PM, Bob Carpenter <
ca...@alias-i.com
<mailto:
ca...@alias-i.com>> wrote:
I was thinking this would mean less change to the code.
Just replace the type with a template.
I wish Rcpp had better doc! There's nowhere to even look
up what Rcpp::NumericVector does. The quickref:
http://cran.r-project.org/web/__packages/Rcpp/vignettes/Rcpp-__quickref.pdf