Simplify matrix