Skip to content
Prev 6939 / 10988 Next

[Rcpp-devel] How to speed up selection of unique unordered pairs

Hello, 

This is a perfect example for using hash sets (std::unordered_set in C++11) with custom implementations of hashing and comparison operators. 

See this gist: https://gist.github.com/romainfrancois/8187193

I have only tested it with Rcpp11 (and therefore using C++11), but I get down to 2 or 3 seconds.
Unit: seconds
                     expr      min       lq   median       uq      max neval
 unordered_pairs(m, 1, 2) 2.534141 2.536889 2.556607 2.714883 2.804312    10

I have used an input matrix of the same size, but probably not the same as yours. I would still expect this code to perform better to your 29 seconds. 

Romain

Le 30 d?c. 2013 ? 19:01, Asis Hallab <asis.hallab at gmail.com> a ?crit :