Created
August 9, 2013 00:06
-
-
Save kevinushey/6190001 to your computer and use it in GitHub Desktop.
RcppArmadillo row shuffling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // [[Rcpp::depends(RcppArmadillo)]] | |
| #include <RcppArmadillo.h> | |
| // [[Rcpp::export]] | |
| arma::imat shuffle(arma::imat A) { | |
| for (int i=0; i < A.n_rows; ++i) { | |
| A.row(i) = shuffle( A.row(i), 1 ); | |
| } | |
| return A; | |
| } | |
| /*** R | |
| mat <- matrix( 1:16, nrow=4, byrow=TRUE) | |
| mat | |
| shuffle(mat) | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment