title: Strange behavior when incrementally sampling using RcppArmadillo::sample
body: <p>I'm trying to implement some draws using a polya urn scheme using Rcpp.  Basically, I have a matrix I'm drawing from,  and a 2nd matrix with weights proportional to the probabilities.  After each draw, I need to increase the weight of whichever cell I drew.</p>
  
  <p>I was running into some indexing errors which lead me to examine the sampling more generally, and I found that my weight matrix was getting modified by RcppArmadillo::sample.  Two questions (1) is this behavior that I should have expected or is this a bug which I should report somewhere?  (2) Any ideas on current work-around?  Here's a reproducible example:</p>
  
  <pre><code>#include &lt;RcppArmadilloExtensions/sample.h&gt;
  // [[Rcpp::depends(RcppArmadillo)]]
  
  using namespace Rcpp ;
  
  // [[Rcpp::export]]
  void sampler(int N, int inc, NumericMatrix&amp; weight_matrix, int reps) {
  
    IntegerVector wm_tmp = seq_along(weight_matrix);
    Rcout &lt;&lt; "Initial weight_matrix:\n" &lt;&lt; weight_matrix &lt;&lt; "\n";
  
    int x_ind;
    for(int i = 0; i &lt; reps; ++i) {
      x_ind = RcppArmadillo::sample(wm_tmp, 1, true, weight_matrix)(0) - 1;
      Rcout &lt;&lt; "Weight matrix after sample: (rep = " &lt;&lt; i &lt;&lt; ")\n" &lt;&lt; weight_matrix &lt;&lt; "\n";
      Rcout &lt;&lt; "x_ind: " &lt;&lt; x_ind  &lt;&lt; "\n"; 
      // get indices
      weight_matrix[x_ind] = weight_matrix[x_ind] +  inc;
      Rcout &lt;&lt; "Add increment of " &lt;&lt; inc &lt;&lt; " to weight_matrix:\n" &lt;&lt; weight_matrix &lt;&lt; "\n";
    }
  }
  // 
  // // [[Rcpp::export]]
  // IntegerVector seq_cpp(IntegerMatrix x) {
  //   IntegerVector tmp = seq_along(x);
  //   IntegerVector ret = RcppArmadillo::sample(tmp, 2, true);
  //   return ret;
  // }
  
  /*** R
  weight_matrix &lt;- matrix(1, 5, 2)
  sampler(5, 1, weight_matrix, 3)
  
  weight_matrix &lt;- matrix(1, 5, 2)
  sampler(5, 0, weight_matrix, 3)
  */
  </code></pre>
  
  <p>Thanks!</p>