Hello list,
I have several std::vector<double> in a STL container and would like to
fill a Rcpp::NumericMatrix row by row with them, is there an easy way to do
it, or should I iterate over all elements as in usual C++?
I saw the `_` in this post on SO but I think it has a different purpose.
cCode <- '
double v_value[] = {1.1,2.4};
vector<double> v(v_value, v_value + sizeof(v_value)/sizeof(double));
NumericMatrix m(3,2);
//Here is what I was hoping for
//for(int i=0; i<3; i++){
// m(i,_) = v;
//}
return m;
';
R)
fillMat <- cxxfunction(signature(), includes='using namespace std;',
plugin="Rcpp", body=cCode)
Regards
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel