title: How do I find the indices of elements in a vector which are also in another vector using RcppArmadillo?
body: <p>I am stuck trying to find the indices of elements in a vector <code>x</code> whose elements are also in another vector <code>vals</code> using Rcpp Armadillo. Both <code>x</code> and <code>vals</code> are of type <code>arma::uvec</code>.</p>
  <p>In R, this would be straightforward:</p>
  <pre><code>x &lt;- c(1,1,1,4,2,4,4)
  vals &lt;- c(1,4)
  which(v %in% vals)
  </code></pre>
  <p>I've scanned the Armadillo docs and <code>find()</code> was my obvious first try; but it didn't work, since <code>vals</code> is a vector. I've also tried <code>intersect()</code> but it returns only the first <em>unique</em> indices.</p>
  <p>What would be a good/efficient way to do this using Armadillo? Do I have to iterate through the elements in <code>vals</code> using <code>find()</code>?</p>