Functions to inverse a matrix