Search code examples
rrcpp

R: where to find the source code for all Rfast functions


I have just found an incredibly useful package called Rfast which uses Rcpp to perform routine operations. So I would like to extend my thanks to them for their work, as well as to the creators of Rcpp of course.

Might be a stupid question but does anyone know where I can get the source code for the Rfast rowOrder function? Doesn't seem to be on their github although the code for another function like Sort is there.


EDIT: I would like to see the actual cpp code of the underlying function that performs the operations, which in the end is called row_order_p


Solution

  • Found it, it was in the col/row utilities at this address: https://github.com/RfastOfficial/Rfast/blob/2cc0ddcaa1f6a4844733871b259ce44b9e48d279/src/col_row_utilities_p.cpp

    IntegerMatrix row_order_p(NumericMatrix x,const bool stable,const bool descending){
      const int ncl=x.ncol(),nrw=x.nrow();
      IntegerMatrix f(nrw,ncl);
      mat xx(x.begin(),nrw,ncl,false);
      imat ff(f.begin(),nrw,ncl,false);
      #ifdef _OPENMP
        #pragma omp parallel for
        #endif
        for(int i=0;i<nrw;++i){
          ff.row(i)=Order<irowvec,rowvec>(xx.row(i),stable,descending,1);
        }
        return f;
    }