I try to translate some R code into RcppArmadillo and therefore I would also like to do the following:
Assume there is a nonnegative vector v
and a matrix M
, both with for example m
rows. I would like to get rid of all rows in the matrix M
whenever there is a zero in the corresponding row of the vector v
and afterwards also get rid of all entries that are zero in the vector v
. Using R this is simply just the following:
M = M[v>0,]
v = v[v>0]
So my question is if there is a way to do this in RcppArmadillo. Since I am quite new to any programming language I was not able to find anything that could solve my problem, although I think that I am not the first one who asks this maybe quite easy question.