Hi, On Tue, Sep 25, 2012 at 4:41 PM, Dirk Eddelbuettel <e...@debian.org> wrote: > > On 25 September 2012 at 13:53, Rodney Sparapani wrote: > | You just need an explicit type conversion like so: > | > | funk2 <- cxxfunction(body='RNGScope scope; > | NumericVector rn(5); > | for (int i=0; i < 5; i++) rn[i] = as<double>(rnorm(1,0,1)); > | return wrap(rn);', > | includes="using namespace Rcpp;\n", plugin="Rcpp") > | > | funk2() > > In the interest of constructive criticism, my version (and I must posted > essentially the same maybe ten times already on this very list): > > R> f3 <- cxxfunction(signature(), plugin="Rcpp", body=' > + RNGScope scope; > + NumericVector rn = Rcpp::rnorm(5,0,1); > + return wrap(rn); > + ') > R> f3() > [1] -0.837983 -0.706765 0.551781 0.662024 0.495562 > R> > > Changes: > > -- no 'using namespace Rcpp;' as inline already does it; I still don't use > it as I prefer to be explicit about provenance of functions and objects
Check > -- no loop (as Doug said) --- rnorm() is a sugar functions and vectorised Roger that > -- no wrap, we already have an Rcpp vector for which wrap is implicit Woops!... we know, though ... "do as I say not as I do" and all that jazz ... ;-) -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel