Message-ID: <4E49D1DC.6030902@dcook.org>
Date: 2011-08-16T02:11:40Z
From: Darren Cook
Subject: [Rcpp-devel] Bug report: need to wrap return of sugar functions
In-Reply-To: <49B98DAFD025E24981E0DC5A9D8100CE458013@DB3PRD0104MB119.eurprd01.prod.exchangelabs.com>
On 2011-08-16 08:34, Wray, Christopher wrote:
> =============
> x=matrix(1:12,4,3);
> print(ifelse(x<5,x*x,x))
>
> src2='
> using namespace Rcpp;
> NumericMatrix x(x_);
> NumericVector y=ifelse(x<5,x*x,x);
> y.attr("dim")=Dimension(x.nrow(),x.ncol());
> return y;
> '
> fun=cxxfunction(signature(x_ ="integer"),src2,plugin="Rcpp")
> print(fun(x))
>
> ===========
> does this do it for you
Hello Christopher,
Thanks for the suggestion. It works perfectly (I suspect some template
magic could make this assignment automatic).
Darren
--
Darren Cook, Software Researcher/Developer
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)