For two matrices A,B to commute, the following must hold: (AB)ij=nΣk=1aikbkj=nΣk=1bikakj=(BA)ij. This can happen if for all i,j,k:
1) aik=akj and bik=bkj
2) aik=bik and akj=bkj, i.e. A=B
3) aik=0 or bik=0, i.e. either matrix is null
4) There are no more possibilities