Dot optimization

This is a generalization of the proposed optimization T.dot(A, B)[i] --> T.dot(A[i], B) to deal with multiple indices. For example, if A and B are matrices then T.dot(A, B)[:, i] will become T.dot(A, B[:, i]), and similarly for tensors and more indices. The tests have not yet been written.