[Rcpp-devel] problem with sample() implemented in Rcpp/RcppArmadillo

Christian Gunning xian at unm.edu
Sun Nov 4 13:07:10 CET 2012


> > Update -- I've implemented all of R's sample (with identical results)
> > except for the walker alias method.  I used Armadillo for
> ProbSampleReplace
> > and ProbSampleNoReplace, since there's no good STL replacement for R's
> > revsort.
>
> Out of curiosity, what does revsort do? It must be something beyond just
> a reverse-order sort?
>
> Darren
>
> P.S. I don't have an R function of that name. Googling found it used in
> random.c but not where its defined!


(BTW, if you CC the poster, it's marginally easier to reply to.)

Today I learned that revsort is an exported function from the R API, and is
therefore in the bible (6:10):
http://cran.r-project.org/doc/manuals/R-exts.html#Utility-functions

revsort just does the following two operations in a single function call
(via scary pointer magic -- Boo!).  Also, boost lambda turns up as another
way to accomplish this:
http://arma.sourceforge.net/docs.html#sort_index
http://arma.sourceforge.net/docs.html#sort

-Christian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121104/5bd0abed/attachment.html>


More information about the Rcpp-devel mailing list