faster position computation in triangular matrix (micro-optimization)