As highlighted by e.g. this post, matrices can be passed to an arma::mat
object by reference:
// [[Rcpp::export]]
void arma_test_ref( arma::mat& x){}
// [[Rcpp::export]]
void arma_test_const_ref( const arma::mat& x){}
Which other classes foreign to R allow objects to be passed by reference? I am thinking in particular of Armadillo classes like arma::vec
, arma::spmat
, arma::Mat<int>
etc., but am also curious about classes outside Armadillo. There appears to be no list clarifying the issue in the documentation.
And as a supplementary question: does the choice of passing objects to arma::mat by reference or by value affect what the object looks like? Are they stored differently in memory or do they vary in any other regard that may affect the efficiency of their use in the C++ code?