calculate ranking matrix