Implemented inverse calculation for cached matrices