Le 26 août 2013 à 12:19, Simon Zehnder <[email protected]> a écrit :
> Dear Rcpp::Users and Rcpp::Devels, > > I am right now working on a relabeling algorithm where I have a function > taking a permutation matrix of all permutations of the labels. Inside the > function the values should be permuted in respect to a row of this matrix. In > R I would use the following commands: > > values <- matrix(rnorm(4), ncol = 2, nrow = 2, byrow = TRUE) > perm <- as.matrix(expand.grid(seq(1, 2), seq(1, 2))) > index <- perm[which(perm[, 1] != perm[, 2]),] > values[, index[, 1]] > values[, index[, 2]] > > I found this thread on stackoverflow: > http://stackoverflow.com/questions/8435169/selecting-a-non-contiguous-submatrix-in-rcpp. > Are there any proceedings for non-contiguous submatrices in Rcpp? I couldn't > find a hint in the Rcpp-book (neither in chapter 3 nor in chapter 8). I would > like to avoid nested loops and I need the values as Rcpp::NumericMatrix > objects for the functions (so using RcppArmadillo (via non-contiguous views) > is only a path I would choose if no other simpler possibilities are > available). Any suggestions are welcome. Writing loops is what you do in c++. There is no guilty conscience like in R. > @Rcpp::Devels: I try to understand in the doxygen documentation how the > operator '()' works. I see that there is always a VECTOR::Proxy underlying > each Matrix object and I end up at the traits::r_vector_proxy in the > 00_forward_proxy.h file. I assume, that each Matrix object has its type given > by the proxy and acts in regard to this characterization. Where can I look > for more information about this struct? In the source files. You'll have to jump between several files. Not easy to follow, even for us. Good luck. > Best > > Simon > _______________________________________________ > Rcpp-devel mailing list > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
