some userful tensor functions