[Rcpp-devel] Misunderstanding about sugar
Michael Hannon
jm_hannon at yahoo.com
Fri Oct 21 08:17:34 CEST 2011
.
.
.
> You also nmeed to disentangle the assignment as there is too much template
> magic. So this just worked for me:
>
>
> R> library(Rcpp)
> R> library(inline)
> R>
> R> xorig <- c(1, -2, 3, -4, 5, -6, 7)
> R>
> R> code <- '
> + NumericVector x(xs);
> + NumericVector xa = sapply( x, ::fabs );
> + return(xa);
> + '
> R>
> R> xabs <- cxxfunction(signature(xs="numeric"),
> + plugin="Rcpp",
> + body=code)
> R>
> R> xabs(xorig)
> [1] 1 2 3 4 5 6 7
> R>
.
.
.
That works perfectly. Thanks, Dirk.
-- Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20111020/9f1213b3/attachment.htm>
More information about the Rcpp-devel
mailing list