
# author: N. Matloff

rthsort <- function(x,gpu=F) {
   if (gpu) {
      dyn.load("rthsortgpu.so")
      asfunction <- as.single
      vecfunction <- single
      dupval <- T
   } else {
      dyn.load("rthsort.so")
      asfunction <- as.double
      vecfunction <- double
      dupval <- F
   }
   n <- length(x)
   tmp <- .C("rthsort",asfunction(x),as.integer(n),
             tmpres=vecfunction(n),DUP=dupval)
   return(tmp$tmpres)
}


