invert a matrix