Rank-compute function