An n-by-n matrix is diagonalizable if and only if the sum of the dimensions of the eigenspaces equals n.

math.la.t.mat.diagonalizable.eigenspace