[R] building a quicksort function in rcpp

peter dalgaard pdalgd at gmail.com
Sat Jul 25 13:26:03 CEST 2015


> On 24 Jul 2015, at 17:22 , Martin Tully <tulls4472 at gmail.com> wrote:
> 
> Hi I am using RCPP to build a C++ function for quicksort called qsort.
> This function is compiled and loaded through the cxxfunction in R
> I am getting the message in R error: no matching function for call to
> 'qsort(int*&)' The code is below.
> It will not run for me and I was wondering if you could help?

I'm too old to  be good at C++, but this looks wrong:

> 
> 
> 
> library(Rcpp)
> library(inline)
> 
> 
>    incl <- 'int qsort(int xx[], int left, int right) {
> 
> ......
>        return (qsort(xx));
>          }
>          '

It looks wrong on two counts: qsort() calls itself with no conditioning, and even if that is intentional, the call doesn't match the definition. Shouldn't it just be return(xx); ?

-pd

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list