[Rcpp-devel] redimension help

Silkworth,David J. SILKWODJ at airproducts.com
Tue Jun 7 15:01:26 CEST 2011


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.



More information about the Rcpp-devel mailing list