I have two huge commuted Matrices A and B, each one of them contains a large amount of degenerate eigenvalues. Now I compute the eigenvalues and eigenvectors of A. Since [A,B] = 0, if eigenvalue of A is not degenerate, the eigenvector of A should also be the eigenvector of B. However if some eigenvalues of A are degenerate, after I compute these eigenstates using program numerically, these eigenstates might not be the eigenstates of B.
Now I only want those eigenvectors with one specific eigenvalue(say b, which is a number) of B, then how can I get the eigenstates of B with eigenvalue b in these degenerate eigenstates of A? My purpose is trying to reduced matrix A into the subspace of those states with eigenvalue of B, b.