Skip to content
Prev 2740 / 10988 Next

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

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