[Rcpp-devel] Bug report: need to wrap return of sugar functions

Wray, Christopher christopher.wray.10 at ucl.ac.uk
Tue Aug 16 01:34:33 CEST 2011


=============
   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

________________________________________
From: rcpp-devel-bounces at r-forge.wu-wien.ac.at [rcpp-devel-bounces at r-forge.wu-wien.ac.at] on behalf of Dirk Eddelbuettel [edd at debian.org]
Sent: 15 August 2011 14:36
To: Darren Cook
Cc: rcpp-devel at r-forge.wu-wien.ac.at
Subject: Re: [Rcpp-devel] Bug report: need to wrap return of sugar functions

On 15 August 2011 at 22:11, Darren Cook wrote:
| > | more minimal examples than the below, but as this is the one from
| > | Rcpp-sugar.pdf I thought it most convincing:
| > | ...
| > No bug.
| >
| > We never said that you could get by an _implicit_ wrap everywhere. Sometimes
| > you do need an explicit wrap. This is just one of these situations.
|
| Thanks for the reply.
| In that case I'm reporting a bug in the documentation :-)

Sigh.

_What_ file? _What_ paragraph? _What_ is your suggested fix?

Dirk

--
Two new Rcpp master classes for R and C++ integration scheduled for
New York (Sep 24) and San Francisco (Oct 8), more details are at
http://dirk.eddelbuettel.com/blog/2011/08/04#rcpp_classes_2011-09_and_2011-10
http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel at lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


More information about the Rcpp-devel mailing list