added diag and upper.tri functions