Diagonal matrix check.