[Rcpp-devel] redimension help
Douglas Bates
bates at stat.wisc.edu
Tue Jun 7 20:51:19 CEST 2011
On Tue, Jun 7, 2011 at 8:01 AM, Silkworth,David J.
<SILKWODJ at airproducts.com> wrote:
> I want you guys to know that I appreciate all the effort that you put
> into the Rcpp package and this list. I am obviously one of the early
> people to hurdle the new "lowered bar" for C++ development in R.
> I have developed a function that builds a series of vectors and a matrix
> of undetermined size. Rather than attempt dynamic objects (which I
> wouldn't know how to do anyway) I have been able to initialize with row
> dimensions that cannot be exceeded on these objects. I expect that code
> that merely assigns values to these addresses will run faster than code
> that must allocate space for each row entry anyway. But, at the end of
> the process, my code realizes the true extent of these objects. It
> would be really nice to clean these up before return to R.
> I am aware of a Dimension class, but really don't know how to go about
> using this in this case.
>
> For the vectors it was relatively simple to execute a loop of erase()
> methods:
> // this works perfectly
> for(int t=newTimes.size()-1; t>row;t--) {
> newTimes.erase(t);
> }
>
> Alas, for the Rcpp::IntegerMatrix this was not so easy.
>
> Rcpp::IntegerMatrix opd (exists and has been populated)
>
> for(int v=0; v<num_opl v++) {
> for(int t=newTimes.size()-1; t>row;t--) {
> opd(_,0).erase(t);
> }
> }
>
> This results in the compiler error: 'struct Rcpp::Matrix<13>::Column'
> has no member named 'erase'
>
> I'm sorry, but I am stuck.
I think we are stuck too in that we can't tell what you are trying to
do. (Well, at least I can't.).
Why do you bother erasing elements beyond the size() of the vector?
I'm pretty sure that will have no effect.
Perhaps if you were a bit more explicit about what you are trying to
do we could help. As it stands you are telling us that you have tried
to use a method that isn't defined and all we can say is, "Yep, it
isn't defined."
More information about the Rcpp-devel
mailing list