Transformation matrix with respect to a basis