ENH: add method='dense' to rank

Addresses #6333.

(Let's see how it goes on Travis; last time there was some strange behaviour which I think turned out to be because of an uninitialized variable which was behaving differently on my system than on the buildbots.)