Optimized computeRho.