Re: [Rcpp-devel] tracking volatile bug

2014-11-22 Thread Gabor Grothendieck
On Sat, Nov 22, 2014 at 1:43 PM, Sokol Serguei wrote: > Let try to stick with regular rcpp code > (file: matrix_norm.cpp): > > //[[Rcpp::depends(RcppArmadillo)]] > #include > using namespace Rcpp; > using namespace arma; > > // [[Rcpp::export]] > double nmat(mat A) { >Function Matrix_norm_r_=

Re: [Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Søren Højsgaard
Thanks. May I suggest adding a remark about this in the sugar-vignette (if it is not already there - in which case I apologize for not having seen it!) Cheers Søren |-Original Message- |From: Romain Francois [mailto:rom...@r-enthusiasts.com] |Sent: 22. november 2014 14:36 |To: Søren Højs

Re: [Rcpp-devel] tracking volatile bug

2014-11-22 Thread Sokol Serguei
Dirk Eddelbuettel has written at Sat, 22 Nov 2014 09:57:36 -0600 On 21 November 2014 at 23:50, Sokol Serguei wrote: | If I did not use the protection in my Rcpp code it's because | I did not see it in any example of quick ref guide: | http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-qu

Re: [Rcpp-devel] tracking volatile bug

2014-11-22 Thread Dirk Eddelbuettel
On 21 November 2014 at 23:50, Sokol Serguei wrote: | If I did not use the protection in my Rcpp code it's because | I did not see it in any example of quick ref guide: | http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-quickref.pdf | I didn't see any mention of PROTECT necessity neither

Re: [Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Romain Francois
You get UB if the first is bigger than the second. Envoyé de mon iPhone > Le 22 nov. 2014 à 14:30, Søren Højsgaard a écrit : > > OK; thanks! Shall I read this such as "the behaviour is undefined"? > Søren > > |-Original Message- > |From: Romain Francois [mailto:rom...@r-enthusiasts.co

Re: [Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Søren Højsgaard
OK; thanks! Shall I read this such as "the behaviour is undefined"? Søren |-Original Message- |From: Romain Francois [mailto:rom...@r-enthusiasts.com] |Sent: 22. november 2014 13:25 |To: Søren Højsgaard |Cc: rcpp-devel@lists.r-forge.r-project.org |Subject: Re: [Rcpp-devel] sugar: x+y and y

Re: [Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Romain Francois
This has nothing to do with NA. It's just about the size difference. sugar does not make attempt at recycling. Your responsibility. Romain > Le 22 nov. 2014 à 11:48, Søren Højsgaard a écrit : > > Dear all, > Came across this: > > #include > using namespace Rcpp; > > //[[Rcpp::export]] > Li

[Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Søren Højsgaard
Dear all, Came across this: #include using namespace Rcpp; //[[Rcpp::export]] List sumxy(NumericVector x, NumericVector y){ NumericVector xy = x+y; NumericVector yx = y+x; return List::create(xy, yx); } /*** R x <- c(1,3,5,7) y <- c(NA,2,4,6,8) x+y y+x sumxy(x, y) */ > x <- c(1,3,5,7)