[Rcpp-devel] Rcpp-quickref patch - Inline, Random
Romain Francois
romain at r-enthusiasts.com
Tue Dec 7 11:23:30 CET 2010
Le 07/12/10 11:15, Christian Gunning a écrit :
> Attached is a patch relative to pkg/Rcpp/inst/doc/Rcpp-quickref.
Thanks. I will have a look tonight if nobody else does it before me
(please do).
> I added Douglas' suggestion to the Matrix section. In addition are
> reference examples for inline and the random functions.
>
> There was a recent list question about dnorm, and I ran across similar
> confusion. Is the default argument cascade the same for all of the d*
> family? For dnorm, assuming numvec contains {-1, 0, 1}, we have:
>
> //Working:
> NumericVector works1, works2;
> works1 = dnorm(numvec, 0, 1, false);
> works2 = dnorm(numvec, 0, false);
>
> As far as I could tell, all other combinations of missing arguments
> fails at compile time.
It is useful if you actually send us what you tried to compile, hoiw it
failed, why you though it would work, etc ...
> Since e.g. rnorm(10) works, this seems a bit
> counter-intuitive. Personally, this isn't a priority for me - just
> trying to figure out the system.
>
> best,
> xian
Consider this:
require( inline )
require( Rcpp )
fx <- cxxfunction( , '
RNGScope scope ;
return List::create(
rnorm(10),
rnorm(10, 10.0),
rnorm(10, 10.0, 100.0)
) ;
', plugin = "Rcpp" )
fx()
You cannot have missing arguments "in the middle" in C++.
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/gpCSpH : Evolution of Rcpp code size
|- http://bit.ly/hovakS : RcppGSL initial release
`- http://bit.ly/iaxTdO : parser 0.0-12
More information about the Rcpp-devel
mailing list