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