Refactor this matrix into one in which dimensions always occur in the same order, no matter what path is taken.
See Implementation
Refactor this matrix into one in which dimensions always occur in the same order, no matter what path is taken.