Implementation of cached inverse matrix