Jeff, A few random comments in addition to Dirk's sound advice:
1. I recommend using bigger matrices for testing just to get a feel. For testing loop speed, you want the proportion of loop time to be *very high* compared to the R interpreter overhead, resolution of your timer, etc. Here, the extra as<arma::mat> and wrap() in armaSrc may add appreciable execution time relative to the loop work -- only testing will tell :) 2. Another advantage of big matrices is testing the relative impact of memory copying versus in-place modification. Both Rcpp and RcppArmadillo allow for both -- for the former, search the quickref for "clone" for an intro. With RcppArmadillo, in-place is a little more involved, but look for this line: "However, if copy_aux_mem is set to false, the matrix will instead directly use the auxiliary memory (ie. no copying). This is faster, but can be dangerous unless you know what you're doing!" http://arma.sourceforge.net/docs.html#Mat 3. I've modified the below to move the +op from the conditional evaluation to the definition. For small thetaEndIndex or simple ops, this won't matter, but for theatEndIndex = 1e12 and something like a vec.size() accessor, it can make a noticeable difference. In general, it's a good habit not to put ops in the conditional unless you really need them. > armaSrc <- ' ... > int thetaEndIndex = as<int>(sthetaEndIndex) - 1; ... > for (int i = thetaStartIndex + 1; i <= thetaEndIndex; i++) { best, Christian -- A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama! _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel