bug fix in Tensor::diag