0

I have a RcppEigen vector and I would like to copy another vector to noncontiguous entries.

For example, using R, I can do

x <- c(0,0,0,1,1,0,1)
y <- rnorm(3)
x[x > 0] <- y

Using Armadillo, I can also do

arma::vec x = {0,0,0,1,1,0,1};
arma::vec y(3, arma::fill::randn);
x(arma::find(x > 0)) = y;

What if I want to do the same thing using RcppEigen?

​I am aware of this post. But the problem here is a bit different because x and y do not have the same dimension.

Ari.stat
  • 463
  • 4
  • 13

0 Answers0