added upper triangular matrix algorithm