simplify matrix