How to invert a matrix