added a lot of matrix and matrix+defect cases