Completed code for cached inverse matrix function