Adding routine to find upper/lower triangular elements.