I checked many examples about how to pass by reference using Rcpp. I see for instance this very great. However I have one question. Suppose that I have a matrix as an object in R and I want to add 1 to the entry [1,1]. The examples i saw work if the matrix is in Cpp but i want to return the update in R without using return statement.
This is an example i did with a list and it works very well
//[[Rcpp::export]]
void test(List& a){
a(0)=0;
}
I need to do similarely with a matrix. something like :
//[[Rcpp::export]]
void test(arma::mat& a){
a(0,0)=0;
}
The second does not update my matrix in R but updates the list.
Can anyone help me ?