PA2: caching of inversion matrix