[Rcpp-devel] Can I fill a matrix row by row with std<vector> (or similar)
stat quant
statquant at outlook.com
Fri Mar 1 17:15:43 CET 2013
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130301/95f4cda9/attachment.html>
More information about the Rcpp-devel
mailing list