tensor.cc is updated to compute locality, M, and T in each iteration directly