Re: [Rcpp-devel] Possible error in setequal ??

2015-01-02 Thread Kevin Ushey
Hi Qiang, I think you're right -- I just took a peek and that looks like the offending bit. I'm going to strip it out, run tests and then commit if everything looks good. Thanks! Kevin On Fri, Jan 2, 2015 at 6:26 PM, Qiang Kou wrote: > It seems fixed after removing that line [1]. > >> library(R

Re: [Rcpp-devel] Possible error in setequal ??

2015-01-02 Thread Qiang Kou
It seems fixed after removing that line [1]. > library(Rcpp) > sourceCpp("seteq.cpp") > seteq1(c(1,2,3), c(3,2,1)) [1] TRUE > seteq1(c(1,2,3), c(3,2,1)) [1] TRUE > seteq1(c("a","b"), c("a","b")) [1] TRUE > seteq1(c(1,2,3), c(3,2)) [1] FALSE > seteq1(c("a","b"), c("a","b","k")) [1] FALSE > seteq1(c

Re: [Rcpp-devel] Possible error in setequal ??

2015-01-02 Thread Qiang Kou
I think the bug is from [1]. This line doesn't make much sense. Best, KK [1] https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/sugar/functions/setdiff.h#L80 On Fri, Jan 2, 2015 at 9:22 PM, Kevin Ushey wrote: > Hi Søren, > > Thanks for the bug report -- it looks like you're righ

Re: [Rcpp-devel] Possible error in setequal ??

2015-01-02 Thread Kevin Ushey
Hi Søren, Thanks for the bug report -- it looks like you're right, `setequal` is broken, and we never knew about it because we don't have any unit tests for it. Whoops! I'll take a look at what's going on and commit a fix + tests soon -- for now, you can use the workaround with `setdiff` which ap

[Rcpp-devel] Possible error in setequal ??

2015-01-02 Thread Søren Højsgaard
Dear all, There might be an error in setequal() from sugar. Consider this #include using namespace Rcpp; //[[Rcpp::export]] bool seteq1(CharacterVector x, CharacterVector y){ return setequal(x,y); } //[[Rcpp::export]] bool seteq2(CharacterVector x, CharacterVector y){ return (((Cha

Re: [Rcpp-devel] Best Practice for Optimize Functions in RCPP

2015-01-02 Thread Mark Clements
Alternatively, one could use the code for Brent_fmin() from the stats library (e.g. https://github.com/lgautier/R-3-0-branch-alt/blob/master/src/library/stats/src/optimize.c). I have done this for the rstpm2 library (https://github.com/mclements/rstpm2/blob/develop/src/c_optim.cpp). This does use