Invert square matrix