28 return v1.first > v2.first;
33inline auto pairLess = [](
const auto &v1,
const auto &v2) {
34 return v1.first < v2.first;
42template <
typename T1,
typename T2>
43void rankVect(
const std::vector<T1> &vect, T2 &res) {
44 PRECONDITION(res.size() >= vect.size(),
"vector size mismatch");
45 unsigned int nEntries = rdcast<unsigned int>(vect.size());
47 std::vector<unsigned int> indices(nEntries);
48 for (
unsigned int i = 0; i < nEntries; ++i) {
51 std::sort(indices.begin(), indices.end(),
52 [&](
auto i1,
auto i2) { return vect[i1] < vect[i2]; });
55 unsigned int lastIdx = indices[0];
56 for (
auto idx : indices) {
57 if (vect[idx] == vect[lastIdx]) {
60 res[idx] = ++currRank;
#define PRECONDITION(expr, mess)
Utility functionality used to rank sequences.
void rankVect(const std::vector< T1 > &vect, T2 &res)
ranks the entries in a vector