Skip to content

Instantly share code, notes, and snippets.

@kevinushey
Created August 9, 2013 00:06
Show Gist options
  • Select an option

  • Save kevinushey/6190001 to your computer and use it in GitHub Desktop.

Select an option

Save kevinushey/6190001 to your computer and use it in GitHub Desktop.
RcppArmadillo row shuffling
// [[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