Spent the day porting an R implementation to C++. Guess how much time I save with the new implementation. A measly 12.5%. Le sigh.
1
1
#rstats hivemind: I am using an Rcpp::List on the C++ side as a POD and using push_back() to append new objects onto the end of it. The objects are unknown dimension Rcpp::IntegerMatrix and the number of objects that will go onto the Rcpp::List is unknown. Should I use a stack?
1
1
The problem is an unknown size unbalanced tree where each node is an unknown size matrix. I have a class for the matrix that writes to a Rcpp::IntegerMatrix. I can do the conversion up front and use the Rcpp::List for easy output or do the output conversion later.
1
Which is the recommended and documented behavior, and has been for all those years!
Remember: #Rcpp maps R data structures.
And those (generally) do not grow well. So use STL (and alike) in C++ and transfer back to R(cpp) data just prior to return.
Feb 17, 2022 · 12:51 AM UTC
1
4


